libpurple/protocols/jabber/buddy.c

Thu, 16 Jul 2009 22:53:37 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Thu, 16 Jul 2009 22:53:37 +0000
changeset 27846
9c591a669ffe
parent 27824
fd9271177fb4
child 27965
d2f136953034
permissions
-rw-r--r--

Revert this to what it was originally. Since the Get Info dialog renders "Purple HTML" or "IMHTML", trust the purple_* routine to format the <br/> properly.

7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2 * purple - Jabber Protocol Plugin
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18315
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 #include "debug.h"
7076
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
23 #include "imgstore.h"
9713
bb37562302a1 [gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents: 9466
diff changeset
24 #include "prpl.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25 #include "notify.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26 #include "request.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "util.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
28 #include "xmlnode.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "buddy.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 #include "chat.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "jabber.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 #include "iq.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 #include "presence.h"
25475
ad7612a5d678 Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents: 25391
diff changeset
35 #include "useravatar.h"
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
36 #include "xdata.h"
17787
439329d20337 Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <am@adiumx.com>
parents: 17770
diff changeset
37 #include "pep.h"
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
38 #include "adhoccommands.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
40 typedef struct {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
41 long idle_seconds;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
42 } JabberBuddyInfoResource;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
43
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
44 typedef struct {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
45 JabberStream *js;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
46 JabberBuddy *jb;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
47 char *jid;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
48 GSList *ids;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
49 GHashTable *resources;
27305
ef06405deeb0 Use guint for a timeout handle here, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 27297
diff changeset
50 guint timeout_handle;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
51 GSList *vcard_imgids;
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
52 PurpleNotifyUserInfo *user_info;
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
53 long last_seconds;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
54 gchar *last_message;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
55 } JabberBuddyInfo;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
56
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
57 void jabber_buddy_free(JabberBuddy *jb)
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
58 {
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
59 g_return_if_fail(jb != NULL);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
60
22942
2bf494f8e2a4 Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents: 22928
diff changeset
61 g_free(jb->error_msg);
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
62 while(jb->resources)
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
63 jabber_buddy_resource_free(jb->resources->data);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
64
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
65 g_free(jb);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
66 }
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
67
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 JabberBuddy *jabber_buddy_find(JabberStream *js, const char *name,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69 gboolean create)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 JabberBuddy *jb;
27297
168f268f927d Plug a leak from changing this to use jabber_get_bare_jid instead of normalize.
Paul Aurich <darkrain42@pidgin.im>
parents: 27289
diff changeset
72 char *realname;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73
15143
37451143f5c4 [gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents: 15092
diff changeset
74 if (js->buddies == NULL)
37451143f5c4 [gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents: 15092
diff changeset
75 return NULL;
37451143f5c4 [gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents: 15092
diff changeset
76
27110
05ca719b901b Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents: 27075
diff changeset
77 if(!(realname = jabber_get_bare_jid(name)))
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78 return NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80 jb = g_hash_table_lookup(js->buddies, realname);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
81
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82 if(!jb && create) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83 jb = g_new0(JabberBuddy, 1);
27297
168f268f927d Plug a leak from changing this to use jabber_get_bare_jid instead of normalize.
Paul Aurich <darkrain42@pidgin.im>
parents: 27289
diff changeset
84 g_hash_table_insert(js->buddies, realname, jb);
168f268f927d Plug a leak from changing this to use jabber_get_bare_jid instead of normalize.
Paul Aurich <darkrain42@pidgin.im>
parents: 27289
diff changeset
85 } else
168f268f927d Plug a leak from changing this to use jabber_get_bare_jid instead of normalize.
Paul Aurich <darkrain42@pidgin.im>
parents: 27289
diff changeset
86 g_free(realname);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
87
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
88 return jb;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
89 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
91
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92 JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 const char *resource)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 JabberBuddyResource *jbr = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96 GList *l;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 if(!jb)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 return NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101 for(l = jb->resources; l; l = l->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102 {
24890
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
103 JabberBuddyResource *tmp = (JabberBuddyResource *) l->data;
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
104 if (!jbr && !resource) {
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
105 jbr = tmp;
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
106 } else if (!resource) {
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
107 if (tmp->priority > jbr->priority)
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
108 jbr = tmp;
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
109 else if (tmp->priority == jbr->priority) {
22550
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
110 /* Determine if this resource is more available than the one we've currently chosen */
24890
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
111 switch(tmp->state) {
22550
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
112 case JABBER_BUDDY_STATE_ONLINE:
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
113 case JABBER_BUDDY_STATE_CHAT:
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
114 /* This resource is online/chatty. Prefer to one which isn't either. */
24890
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
115 if (((jbr->state != JABBER_BUDDY_STATE_ONLINE) && (jbr->state != JABBER_BUDDY_STATE_CHAT))
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
116 || (jbr->idle && !tmp->idle)
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
117 || (jbr->idle && tmp->idle && tmp->idle > jbr->idle))
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
118 jbr = tmp;
22550
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
119 break;
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
120 case JABBER_BUDDY_STATE_AWAY:
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
121 case JABBER_BUDDY_STATE_DND:
24827
5e3f3d989002 This technically doesn't matter due to behavior elsewhere in the prpl, but
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
122 /* This resource is away/dnd. Prefer to one which is extended away, unavailable, or unknown. */
24890
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
123 if (((jbr->state == JABBER_BUDDY_STATE_XA) || (jbr->state == JABBER_BUDDY_STATE_UNAVAILABLE) ||
22550
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
124 (jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR))
24890
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
125 || (jbr->idle && !tmp->idle)
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
126 || (jbr->idle && tmp->idle && tmp->idle > jbr->idle))
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
127 jbr = tmp;
22550
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
128 break;
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
129 case JABBER_BUDDY_STATE_XA:
24827
5e3f3d989002 This technically doesn't matter due to behavior elsewhere in the prpl, but
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
130 /* This resource is extended away. That's better than unavailable or unknown. */
5e3f3d989002 This technically doesn't matter due to behavior elsewhere in the prpl, but
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
131 if ((jbr->state == JABBER_BUDDY_STATE_UNAVAILABLE) || (jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR))
24890
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
132 jbr = tmp;
24827
5e3f3d989002 This technically doesn't matter due to behavior elsewhere in the prpl, but
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
133 break;
5e3f3d989002 This technically doesn't matter due to behavior elsewhere in the prpl, but
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
134 case JABBER_BUDDY_STATE_UNAVAILABLE:
5e3f3d989002 This technically doesn't matter due to behavior elsewhere in the prpl, but
Paul Aurich <darkrain42@pidgin.im>
parents: 24816
diff changeset
135 /* This resource is unavailable. That's better than unknown. */
22550
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
136 if ((jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR))
24890
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
137 jbr = tmp;
22550
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
138 break;
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
139 case JABBER_BUDDY_STATE_UNKNOWN:
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
140 case JABBER_BUDDY_STATE_ERROR:
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
141 /* These are never preferable. */
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
142 break;
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
143 }
bbfe56f7ad40 Prefer more available resources to less available ones when priorities are the same. Fixes #5079.
Evan Schoenberg <evands@pidgin.im>
parents: 22425
diff changeset
144 }
24890
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
145 } else if(tmp->name) {
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
146 if(!strcmp(tmp->name, resource)) {
22983bf7615b Fix merge
Marcus Lundblad <malu@pidgin.im>
parents: 24889
diff changeset
147 jbr = tmp;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
151 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
152
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
153 return jbr;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
156 JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource,
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
157 int priority, JabberBuddyState state, const char *status)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
158 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
159 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160 if(!jbr) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
161 jbr = g_new0(JabberBuddyResource, 1);
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
162 jbr->jb = jb;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 jbr->name = g_strdup(resource);
27746
4b3f015977d9 For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27696
diff changeset
164 jbr->capabilities = JABBER_CAP_NONE;
25822
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
165 jbr->tz_off = PURPLE_NO_TZ_OFF;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166 jb->resources = g_list_append(jb->resources, jbr);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168 jbr->priority = priority;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 jbr->state = state;
22928
6bd622930dba Simplify
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
170 g_free(jbr->status);
27775
b8569a76e02e Don't pre-escape jbr->status. Almost every place required it in unescaped
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27696
diff changeset
171 jbr->status = g_strdup(status);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
172
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
173 return jbr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
176 void jabber_buddy_resource_free(JabberBuddyResource *jbr)
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
177 {
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
178 g_return_if_fail(jbr != NULL);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
179
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
180 jbr->jb->resources = g_list_remove(jbr->jb->resources, jbr);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
181
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
182 while(jbr->commands) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
183 JabberAdHocCommands *cmd = jbr->commands->data;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
184 g_free(cmd->jid);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
185 g_free(cmd->node);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
186 g_free(cmd->name);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
187 g_free(cmd);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
188 jbr->commands = g_list_delete_link(jbr->commands, jbr->commands);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
189 }
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
190
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
191 if (jbr->caps.exts) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
192 g_list_foreach(jbr->caps.exts, (GFunc)g_free, NULL);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
193 g_list_free(jbr->caps.exts);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
194 }
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
195 g_free(jbr->name);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
196 g_free(jbr->status);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
197 g_free(jbr->thread_id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
198 g_free(jbr->client.name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
199 g_free(jbr->client.version);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
200 g_free(jbr->client.os);
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
201 g_free(jbr);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
202 }
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
203
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204 void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 if(!jbr)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
211 jabber_buddy_resource_free(jbr);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
213
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214 /*******
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
215 * This is the old vCard stuff taken from the old prpl. vCards, by definition
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
216 * are a temporary thing until jabber can get its act together and come up
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
217 * with a format for user information, hence the namespace of 'vcard-temp'
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
218 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
219 * Since I don't feel like putting that much work into something that's
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
220 * _supposed_ to go away, i'm going to just copy the kludgy old code here,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
221 * and make it purdy when jabber comes up with a standards-track JEP to
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
222 * replace vcard-temp
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
223 * --Nathan
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224 *******/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
225
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
226 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227 /* Jabber "set info" (vCard) support */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
228 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
229
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231 * V-Card format:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
232 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
233 * <vCard prodid='' version='' xmlns=''>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
234 * <FN></FN>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
235 * <N>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
236 * <FAMILY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237 * <GIVEN/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 * </N>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239 * <NICKNAME/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240 * <URL/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241 * <ADR>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 * <STREET/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243 * <EXTADD/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244 * <LOCALITY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
245 * <REGION/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 * <PCODE/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247 * <COUNTRY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248 * </ADR>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249 * <TEL/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250 * <EMAIL/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251 * <ORG>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
252 * <ORGNAME/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253 * <ORGUNIT/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
254 * </ORG>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
255 * <TITLE/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
256 * <ROLE/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
257 * <DESC/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
258 * <BDAY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
259 * </vCard>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
260 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
261 * See also:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
262 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
263 * http://docs.jabber.org/proto/html/vcard-temp.html
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264 * http://www.vcard-xml.org/dtd/vCard-XML-v2-20010520.dtd
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
265 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
266
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
267 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
268 * Cross-reference user-friendly V-Card entry labels to vCard XML tags
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269 * and attributes.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
271 * Order is (or should be) unimportant. For example: we have no way of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
272 * knowing in what order real data will arrive.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
273 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274 * Format: Label, Pre-set text, "visible" flag, "editable" flag, XML tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 * name, XML tag's parent tag "path" (relative to vCard node).
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 * List is terminated by a NULL label pointer.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279 * Entries with no label text, but with XML tag and parent tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280 * entries, are used by V-Card XML construction routines to
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 * "automagically" construct the appropriate XML node tree.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283 * Thoughts on future direction/expansion
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 * This is a "simple" vCard.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
287 * It is possible for nodes other than the "vCard" node to have
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
288 * attributes. Should that prove necessary/desirable, add an
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289 * "attributes" pointer to the vcard_template struct, create the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290 * necessary tag_attr structs, and add 'em to the vcard_dflt_data
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
291 * array.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
292 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
293 * The above changes will (obviously) require changes to the vCard
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
294 * construction routines.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
295 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
296
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
297 struct vcard_template {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
298 char *label; /* label text pointer */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
299 char *tag; /* tag text */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
300 char *ptag; /* parent tag "path" text */
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
301 } const vcard_template_data[] = {
26563
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
302 {N_("Full Name"), "FN", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
303 {N_("Family Name"), "FAMILY", "N"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
304 {N_("Given Name"), "GIVEN", "N"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
305 {N_("Nickname"), "NICKNAME", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
306 {N_("URL"), "URL", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
307 {N_("Street Address"), "STREET", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
308 {N_("Extended Address"), "EXTADD", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
309 {N_("Locality"), "LOCALITY", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
310 {N_("Region"), "REGION", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
311 {N_("Postal Code"), "PCODE", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
312 {N_("Country"), "CTRY", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
313 {N_("Telephone"), "NUMBER", "TEL"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
314 {N_("Email"), "USERID", "EMAIL"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
315 {N_("Organization Name"), "ORGNAME", "ORG"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
316 {N_("Organization Unit"), "ORGUNIT", "ORG"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
317 {N_("Title"), "TITLE", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
318 {N_("Role"), "ROLE", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
319 {N_("Birthday"), "BDAY", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
320 {N_("Description"), "DESC", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
321 {"", "N", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
322 {"", "ADR", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
323 {"", "ORG", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
324 {NULL, NULL, NULL}
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
325 };
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
326
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
327 /*
8735
01248ea222d3 [gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents: 8401
diff changeset
328 * The "vCard" tag's attribute list...
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
330 struct tag_attr {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
331 char *attr;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
332 char *value;
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
333 } const vcard_tag_attr_list[] = {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
334 {"prodid", "-//HandGen//NONSGML vGen v1.0//EN"},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
335 {"version", "2.0", },
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336 {"xmlns", "vcard-temp", },
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
337 {NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
338 };
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
339
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
340
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
341 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
342 * Insert a tag node into an xmlnode tree, recursively inserting parent tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
343 * nodes as necessary
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
344 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
345 * Returns pointer to inserted node
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
346 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
347 * Note to hackers: this code is designed to be re-entrant (it's recursive--it
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
348 * calls itself), so don't put any "static"s in here!
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
349 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
350 static xmlnode *insert_tag_to_parent_tag(xmlnode *start, const char *parent_tag, const char *new_tag)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
351 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
352 xmlnode *x = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
353
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
354 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
355 * If the parent tag wasn't specified, see if we can get it
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
356 * from the vCard template struct.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
357 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
358 if(parent_tag == NULL) {
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
359 const struct vcard_template *vc_tp = vcard_template_data;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
360
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
361 while(vc_tp->label != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
362 if(strcmp(vc_tp->tag, new_tag) == 0) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
363 parent_tag = vc_tp->ptag;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
364 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
365 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
366 ++vc_tp;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
367 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
368 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
369
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
370 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
371 * If we have a parent tag...
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
372 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
373 if(parent_tag != NULL ) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
374 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
375 * Try to get the parent node for a tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
376 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
377 if((x = xmlnode_get_child(start, parent_tag)) == NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
378 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
379 * Descend?
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
380 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
381 char *grand_parent = g_strdup(parent_tag);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
382 char *parent;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
383
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
384 if((parent = strrchr(grand_parent, '/')) != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
385 *(parent++) = '\0';
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
386 x = insert_tag_to_parent_tag(start, grand_parent, parent);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
387 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
388 x = xmlnode_new_child(start, grand_parent);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
389 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
390 g_free(grand_parent);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
391 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
392 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
393 * We found *something* to be the parent node.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
394 * Note: may be the "root" node!
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
395 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
396 xmlnode *y;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
397 if((y = xmlnode_get_child(x, new_tag)) != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
398 return(y);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
399 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
400 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
401 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
402
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
403 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
404 * insert the new tag into its parent node
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
405 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
406 return(xmlnode_new_child((x == NULL? start : x), new_tag));
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
407 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
408
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
409 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
410 * Send vCard info to Jabber server
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
411 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
412 void jabber_set_info(PurpleConnection *gc, const char *info)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
413 {
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
414 PurpleStoredImage *img;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
415 JabberIq *iq;
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
416 JabberStream *js = purple_connection_get_protocol_data(gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
417 xmlnode *vc_node;
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
418 const struct tag_attr *tag_attr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
419
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
420 /* if we have't grabbed the remote vcard yet, we can't
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
421 * assume that what we have here is correct */
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
422 if(!js->vcard_fetched)
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
423 return;
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
424
15273
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
425 g_free(js->avatar_hash);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
426 js->avatar_hash = NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
427
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
428 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
429 * Send only if there's actually any *information* to send
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
430 */
11388
3c8b093b5cfe [gaim-migrate @ 13616]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
431 vc_node = info ? xmlnode_from_str(info, -1) : NULL;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
432
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
433 if (vc_node && (!vc_node->name ||
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
434 g_ascii_strncasecmp(vc_node->name, "vCard", 5))) {
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
435 xmlnode_free(vc_node);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
436 vc_node = NULL;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
437 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
438
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
439 if ((img = purple_buddy_icons_find_account_icon(gc->account))) {
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
440 gconstpointer avatar_data;
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
441 gsize avatar_len;
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
442 xmlnode *photo, *binval, *type;
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
443 gchar *enc;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
444
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
445 if(!vc_node) {
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
446 vc_node = xmlnode_new("vCard");
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
447 for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr)
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
448 xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value);
15273
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
449 }
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
450
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
451 avatar_data = purple_imgstore_get_data(img);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
452 avatar_len = purple_imgstore_get_size(img);
25386
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
453 /* Get rid of an old PHOTO if one exists.
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
454 * TODO: This may want to be modified to remove all old PHOTO
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
455 * children, at the moment some people have managed to get
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
456 * multiple PHOTO entries in their vCard. */
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
457 if((photo = xmlnode_get_child(vc_node, "PHOTO"))) {
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
458 xmlnode_free(photo);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
459 }
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
460 photo = xmlnode_new_child(vc_node, "PHOTO");
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
461 type = xmlnode_new_child(photo, "TYPE");
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
462 xmlnode_insert_data(type, "image/png", -1);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
463 binval = xmlnode_new_child(photo, "BINVAL");
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
464 enc = purple_base64_encode(avatar_data, avatar_len);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
465
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 25109
diff changeset
466 js->avatar_hash = jabber_calculate_data_sha1sum(avatar_data, avatar_len);
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
467
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
468 xmlnode_insert_data(binval, enc, -1);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
469 g_free(enc);
25386
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
470 } else if (vc_node) {
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
471 xmlnode *photo;
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
472 /* TODO: Remove all PHOTO children? (see above note) */
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
473 if ((photo = xmlnode_get_child(vc_node, "PHOTO"))) {
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
474 xmlnode_free(photo);
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
475 }
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
476 }
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
477
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
478 if (vc_node != NULL) {
15273
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
479 iq = jabber_iq_new(js, JABBER_IQ_SET);
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
480 xmlnode_insert_child(iq->node, vc_node);
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
481 jabber_iq_send(iq);
25478
0a7f22678a35 Send presence updates from jabber_set_info, not jabber_set_buddy_icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
482
0a7f22678a35 Send presence updates from jabber_set_info, not jabber_set_buddy_icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
483 /* Send presence to update vcard-temp:x:update */
26958
a955bd42f529 propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
parents: 26764 26950
diff changeset
484 jabber_presence_send(js, FALSE);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
485 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
486 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
487
16538
c7e61e2917c9 Updates for the account buddy icon stuff. This doesn't yet work fully (and maybe not even partly), but it compiles.
Richard Laager <rlaager@pidgin.im>
parents: 16534
diff changeset
488 void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
489 {
25811
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
490 PurpleAccount *account = purple_connection_get_account(gc);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
491
26950
842628304397 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents: 26947
diff changeset
492 /* Publish the avatar as specified in XEP-0084 */
842628304397 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents: 26947
diff changeset
493 jabber_avatar_set(gc->proto_data, img);
842628304397 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents: 26947
diff changeset
494 /* Set the image in our vCard */
25811
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
495 jabber_set_info(gc, purple_account_get_user_info(account));
25385
158a12123bc8 Paul noticed that the conditional blocks here were backwards. I'm surprised no
Paul Aurich <darkrain42@pidgin.im>
parents: 25110
diff changeset
496
25811
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
497 /* TODO: Fake image to ourselves, since a number of servers do not echo
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
498 * back our presence to us. To do this without uselessly copying the data
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
499 * of the image, we need purple_buddy_icons_set_for_user_image (i.e. takes
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
500 * an existing icon/stored image). */
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
501 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
502
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
503 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
504 * This is the callback from the "ok clicked" for "set vCard"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
505 *
25391
363cb62aa353 Correct a comment, I don't imagine anyone will actually need this but better
Etan Reisner <deryni@pidgin.im>
parents: 25386
diff changeset
506 * Sets the vCard with data from PurpleRequestFields.
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
507 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
508 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
509 jabber_format_info(PurpleConnection *gc, PurpleRequestFields *fields)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
510 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
511 xmlnode *vc_node;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
512 PurpleRequestField *field;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
513 const char *text;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
514 char *p;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
515 const struct vcard_template *vc_tp;
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
516 const struct tag_attr *tag_attr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
517
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
518 vc_node = xmlnode_new("vCard");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
519
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
520 for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
521 xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
522
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
523 for (vc_tp = vcard_template_data; vc_tp->label != NULL; vc_tp++) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
524 if (*vc_tp->label == '\0')
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
525 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
526
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
527 field = purple_request_fields_get_field(fields, vc_tp->tag);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
528 text = purple_request_field_string_get_value(field);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
529
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
530
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
531 if (text != NULL && *text != '\0') {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
532 xmlnode *xp;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
533
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
534 purple_debug(PURPLE_DEBUG_INFO, "jabber",
9339
31f4980a09ea [gaim-migrate @ 10147]
Nathan Walp <nwalp@pidgin.im>
parents: 9285
diff changeset
535 "Setting %s to '%s'\n", vc_tp->tag, text);
31f4980a09ea [gaim-migrate @ 10147]
Nathan Walp <nwalp@pidgin.im>
parents: 9285
diff changeset
536
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
537 if ((xp = insert_tag_to_parent_tag(vc_node,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
538 NULL, vc_tp->tag)) != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
539
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
540 xmlnode_insert_data(xp, text, -1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
541 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
542 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
543 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
544
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7445
diff changeset
545 p = xmlnode_to_str(vc_node, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
546 xmlnode_free(vc_node);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
547
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
548 purple_account_set_user_info(purple_connection_get_account(gc), p);
14669
df3f48ab4aff [gaim-migrate @ 17335]
Mark Doliner <markdoliner@pidgin.im>
parents: 14525
diff changeset
549 serv_set_info(gc, p);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
550
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
551 g_free(p);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
552 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
553
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
554 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
555 * This gets executed by the proto action
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
556 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
557 * Creates a new PurpleRequestFields struct, gets the XML-formatted user_info
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
558 * string (if any) into GSLists for the (multi-entry) edit dialog and
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
559 * calls the set_vcard dialog.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
560 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
561 void jabber_setup_set_info(PurplePluginAction *action)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
562 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
563 PurpleConnection *gc = (PurpleConnection *) action->context;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
564 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
565 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
566 PurpleRequestField *field;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
567 const struct vcard_template *vc_tp;
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
568 const char *user_info;
14130
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
569 char *cdata = NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
570 xmlnode *x_vc_data = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
571
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
572 fields = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
573 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
574 purple_request_fields_add_group(fields, group);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
575
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
576 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
577 * Get existing, XML-formatted, user info
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
578 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
579 if((user_info = purple_account_get_user_info(gc->account)) != NULL)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
580 x_vc_data = xmlnode_from_str(user_info, -1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
581
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
582 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
583 * Set up GSLists for edit with labels from "template," data from user info
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
584 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
585 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
586 xmlnode *data_node;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
587 if((vc_tp->label)[0] == '\0')
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
588 continue;
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
589
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
590 if (x_vc_data != NULL) {
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
591 if(vc_tp->ptag == NULL) {
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
592 data_node = xmlnode_get_child(x_vc_data, vc_tp->tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
593 } else {
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
594 gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
595 data_node = xmlnode_get_child(x_vc_data, tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
596 g_free(tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
597 }
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
598 if(data_node)
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
599 cdata = xmlnode_get_data(data_node);
14130
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
600 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
601
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
602 if(strcmp(vc_tp->tag, "DESC") == 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
603 field = purple_request_field_string_new(vc_tp->tag,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
604 _(vc_tp->label), cdata,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
605 TRUE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
606 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
607 field = purple_request_field_string_new(vc_tp->tag,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
608 _(vc_tp->label), cdata,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
609 FALSE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
610 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
611
14130
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
612 g_free(cdata);
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
613 cdata = NULL;
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
614
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
615 purple_request_field_group_add_field(group, field);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
616 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
617
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
618 if(x_vc_data != NULL)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
619 xmlnode_free(x_vc_data);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
620
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
621 purple_request_fields(gc, _("Edit XMPP vCard"),
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16799
diff changeset
622 _("Edit XMPP vCard"),
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
623 _("All items below are optional. Enter only the "
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
624 "information with which you feel comfortable."),
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
625 fields,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
626 _("Save"), G_CALLBACK(jabber_format_info),
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
627 _("Cancel"), NULL,
16490
68c22924d66b Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents: 15884
diff changeset
628 purple_connection_get_account(gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
629 gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
630 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
631
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
632 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
633 /* End Jabber "set info" (vCard) support */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
634 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
635
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
636 /******
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
637 * end of that ancient crap that needs to die
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
638 ******/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
639
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
640 static void jabber_buddy_info_destroy(JabberBuddyInfo *jbi)
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
641 {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
642 /* Remove the timeout, which would otherwise trigger jabber_buddy_get_info_timeout() */
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
643 if (jbi->timeout_handle > 0)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
644 purple_timeout_remove(jbi->timeout_handle);
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
645
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
646 g_free(jbi->jid);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
647 g_hash_table_destroy(jbi->resources);
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
648 g_free(jbi->last_message);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
649 purple_notify_user_info_destroy(jbi->user_info);
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
650 g_free(jbi);
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
651 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
652
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
653 static void
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
654 add_jbr_info(JabberBuddyInfo *jbi, const char *resource,
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
655 JabberBuddyResource *jbr)
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
656 {
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
657 JabberBuddyInfoResource *jbir;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
658 PurpleNotifyUserInfo *user_info;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
659
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
660 jbir = g_hash_table_lookup(jbi->resources, resource);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
661 user_info = jbi->user_info;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
662
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
663 if (jbr && jbr->client.name) {
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
664 char *tmp =
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
665 g_strdup_printf("%s%s%s", jbr->client.name,
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
666 (jbr->client.version ? " " : ""),
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
667 (jbr->client.version ? jbr->client.version : ""));
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
668 purple_notify_user_info_prepend_pair(user_info, _("Client"), tmp);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
669 g_free(tmp);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
670
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
671 if (jbr->client.os)
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
672 purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
673 }
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
674
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
675 if (jbr && jbr->tz_off != PURPLE_NO_TZ_OFF) {
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
676 time_t now_t;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
677 struct tm *now;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
678 char *timestamp;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
679 time(&now_t);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
680 now_t += jbr->tz_off;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
681 now = gmtime(&now_t);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
682
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
683 timestamp =
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
684 g_strdup_printf("%s %c%02d%02d", purple_time_format(now),
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
685 jbr->tz_off < 0 ? '-' : '+',
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
686 abs(jbr->tz_off / (60*60)),
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
687 abs((jbr->tz_off % (60*60)) / 60));
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
688 purple_notify_user_info_prepend_pair(user_info, _("Local Time"), timestamp);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
689 g_free(timestamp);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
690 }
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
691
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
692 if (jbir && jbir->idle_seconds > 0) {
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
693 char *idle = purple_str_seconds_to_string(jbir->idle_seconds);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
694 purple_notify_user_info_prepend_pair(user_info, _("Idle"), idle);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
695 g_free(idle);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
696 }
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
697
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
698 if (jbr) {
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
699 char *purdy = NULL;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
700 char *tmp;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
701 char priority[12];
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
702 const char *status_name = jabber_buddy_state_get_name(jbr->state);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
703
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
704 if (jbr->status) {
27846
9c591a669ffe Revert this to what it was originally. Since the Get Info dialog renders "Purple HTML" or "IMHTML", trust the purple_* routine to format the <br/> properly.
Paul Aurich <darkrain42@pidgin.im>
parents: 27824
diff changeset
705 purdy = purple_strdup_withhtml(jbr->status);
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
706
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
707 if (purple_strequal(status_name, purdy))
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
708 status_name = NULL;
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
709 }
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
710
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
711 tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""),
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
712 ((status_name && purdy) ? ": " : ""),
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
713 (purdy ? purdy : ""));
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
714 purple_notify_user_info_prepend_pair(user_info, _("Status"), tmp);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
715
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
716 g_snprintf(priority, sizeof(priority), "%d", jbr->priority);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
717 purple_notify_user_info_prepend_pair(user_info, _("Priority"), priority);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
718
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
719 g_free(tmp);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
720 g_free(purdy);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
721 } else {
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
722 purple_notify_user_info_prepend_pair(user_info, _("Status"), _("Unknown"));
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
723 }
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
724 }
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
725
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
726 static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
727 {
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
728 char *resource_name;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
729 JabberBuddyResource *jbr;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
730 GList *resources;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
731 PurpleNotifyUserInfo *user_info;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
732
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
733 /* not yet */
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
734 if (jbi->ids)
11361
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
735 return;
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
736
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
737 user_info = jbi->user_info;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
738 resource_name = jabber_get_resource(jbi->jid);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
739
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
740 /* If we have one or more pairs from the vcard, put a section break above it */
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
741 if (purple_notify_user_info_get_entries(user_info))
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
742 purple_notify_user_info_prepend_section_break(user_info);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
743
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
744 /* Add the information about the user's resource(s) */
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
745 if (resource_name) {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
746 jbr = jabber_buddy_find_resource(jbi->jb, resource_name);
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
747 add_jbr_info(jbi, resource_name, jbr);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
748 } else {
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
749 for (resources = jbi->jb->resources; resources; resources = resources->next) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
750 jbr = resources->data;
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
751
27053
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
752 /* put a section break between resources, this is not needed if
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
753 we are at the first, because one was already added for the vcard
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
754 section */
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
755 if (resources != jbi->jb->resources)
27053
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
756 purple_notify_user_info_prepend_section_break(user_info);
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
757
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
758 add_jbr_info(jbi, jbr->name, jbr);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
759
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
760 if (jbr->name)
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
761 purple_notify_user_info_prepend_pair(user_info, _("Resource"), jbr->name);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
762 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
763 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
764
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
765 if (!jbi->jb->resources) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
766 /* the buddy is offline */
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
767 gchar *status =
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
768 g_strdup_printf("%s%s%s", _("Offline"),
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
769 jbi->last_message ? ": " : "",
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
770 jbi->last_message ? jbi->last_message : "");
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
771 if (jbi->last_seconds > 0) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
772 char *last = purple_str_seconds_to_string(jbi->last_seconds);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
773 gchar *message = g_strdup_printf(_("%s ago"), last);
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
774 purple_notify_user_info_prepend_pair(user_info,
27552
9041e5b96953 Change "Logged off" to "Logged Off" to match the rest of the labels
Paul Aurich <darkrain42@pidgin.im>
parents: 27551
diff changeset
775 _("Logged Off"), message);
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
776 g_free(last);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
777 g_free(message);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
778 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
779 purple_notify_user_info_prepend_pair(user_info, _("Status"), status);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
780 g_free(status);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
781 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
782
7306
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
783 g_free(resource_name);
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
784
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
785 purple_notify_userinfo(jbi->js->gc, jbi->jid, user_info, NULL, NULL);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
786
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
787 while (jbi->vcard_imgids) {
16437
7ff7c3405ea2 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
788 purple_imgstore_unref_by_id(GPOINTER_TO_INT(jbi->vcard_imgids->data));
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
789 jbi->vcard_imgids = g_slist_delete_link(jbi->vcard_imgids, jbi->vcard_imgids);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
790 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
791
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
792 jbi->js->pending_buddy_info_requests = g_slist_remove(jbi->js->pending_buddy_info_requests, jbi);
14155
c754f6e5be1f [gaim-migrate @ 16719]
Mark Doliner <markdoliner@pidgin.im>
parents: 14130
diff changeset
793
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
794 jabber_buddy_info_destroy(jbi);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
795 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
796
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
797 static void jabber_buddy_info_remove_id(JabberBuddyInfo *jbi, const char *id)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
798 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
799 GSList *l = jbi->ids;
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
800 char *comp_id;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
801
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
802 if(!id)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
803 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
804
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
805 while(l) {
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
806 comp_id = l->data;
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
807 if(!strcmp(id, comp_id)) {
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
808 jbi->ids = g_slist_remove(jbi->ids, comp_id);
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
809 g_free(comp_id);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
810 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
811 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
812 l = l->next;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
813 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
814 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
815
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
816 static void jabber_vcard_save_mine(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
817 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
818 xmlnode *packet, gpointer data)
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
819 {
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
820 xmlnode *vcard, *photo, *binval;
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
821 char *txt, *vcard_hash = NULL;
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
822
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
823 if (type == JABBER_IQ_ERROR) {
27418
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
824 xmlnode *error;
27417
2693e524de1f Missing newline
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
825 purple_debug_warning("jabber", "Server returned error while retrieving vCard\n");
27418
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
826
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
827 error = xmlnode_get_child(packet, "error");
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
828 if (!error || !xmlnode_get_child(error, "item-not-found"))
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
829 return;
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
830 }
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
831
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
832 if((vcard = xmlnode_get_child(packet, "vCard")) ||
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
833 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp")))
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
834 {
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
835 txt = xmlnode_to_str(vcard, NULL);
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
836 purple_account_set_user_info(purple_connection_get_account(js->gc), txt);
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
837
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
838 g_free(txt);
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
839 } else {
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
840 /* if we have no vCard, then lets not overwrite what we might have locally */
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
841 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
842
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
843 js->vcard_fetched = TRUE;
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
844
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
845 if (vcard && (photo = xmlnode_get_child(vcard, "PHOTO")) &&
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
846 (binval = xmlnode_get_child(photo, "BINVAL"))) {
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
847 gsize size;
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
848 char *bintext = xmlnode_get_data(binval);
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
849 guchar *data = purple_base64_decode(bintext, &size);
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
850 g_free(bintext);
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
851
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
852 if (data) {
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
853 vcard_hash = jabber_calculate_data_sha1sum(data, size);
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
854 g_free(data);
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
855 }
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
856 }
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
857
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
858 /* Republish our vcard if the photo is different than the server's */
26947
176ef2bfef9f Use purple_strequal and g_str_equal
Paul Aurich <darkrain42@pidgin.im>
parents: 26946
diff changeset
859 if (!purple_strequal(vcard_hash, js->initial_avatar_hash)) {
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
860 PurpleAccount *account = purple_connection_get_account(js->gc);
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
861 jabber_set_info(js->gc, purple_account_get_user_info(account));
25811
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
862 } else if (js->initial_avatar_hash) {
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
863 /* Our photo is in the vcard, so advertise vcard-temp updates */
25811
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
864 js->avatar_hash = g_strdup(js->initial_avatar_hash);
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
865 }
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
866
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
867 g_free(vcard_hash);
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
868 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
869
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
870 void jabber_vcard_fetch_mine(JabberStream *js)
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
871 {
21957
0ce77f86c7f3 Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents: 21681
diff changeset
872 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
873
21957
0ce77f86c7f3 Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents: 21681
diff changeset
874 xmlnode *vcard = xmlnode_new_child(iq->node, "vCard");
0ce77f86c7f3 Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents: 21681
diff changeset
875 xmlnode_set_namespace(vcard, "vcard-temp");
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
876 jabber_iq_set_callback(iq, jabber_vcard_save_mine, NULL);
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
877
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
878 jabber_iq_send(iq);
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
879 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
880
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
881 static void jabber_vcard_parse(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
882 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
883 xmlnode *packet, gpointer data)
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
884 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
885 char *bare_jid;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
886 char *text;
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
887 char *serverside_alias = NULL;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
888 xmlnode *vcard;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
889 PurpleBuddy *b;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
890 JabberBuddyInfo *jbi = data;
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
891 PurpleNotifyUserInfo *user_info;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
892
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
893 if(!jbi)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
894 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
895
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
896 jabber_buddy_info_remove_id(jbi, id);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
897
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
898 if(!from)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
899 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
900
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
901 if(!jabber_buddy_find(js, from, FALSE))
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
902 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
903
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
904 /* XXX: handle the error case */
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
905
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
906 user_info = jbi->user_info;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
907 bare_jid = jabber_get_bare_jid(from);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
908
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
909 b = purple_find_buddy(js->gc->account, bare_jid);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
910
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
911 if((vcard = xmlnode_get_child(packet, "vCard")) ||
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
912 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
913 xmlnode *child;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
914 for(child = vcard->child; child; child = child->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
915 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
916 xmlnode *child2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
917
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
918 if(child->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
919 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
920
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
921 text = xmlnode_get_data(child);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
922 if(text && !strcmp(child->name, "FN")) {
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
923 if (!serverside_alias)
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
924 serverside_alias = g_strdup(text);
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
925
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
926 purple_notify_user_info_add_pair(user_info, _("Full Name"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
927 } else if(!strcmp(child->name, "N")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
928 for(child2 = child->child; child2; child2 = child2->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
929 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
930 char *text2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
931
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
932 if(child2->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
933 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
934
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
935 text2 = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
936 if(text2 && !strcmp(child2->name, "FAMILY")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
937 purple_notify_user_info_add_pair(user_info, _("Family Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
938 } else if(text2 && !strcmp(child2->name, "GIVEN")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
939 purple_notify_user_info_add_pair(user_info, _("Given Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
940 } else if(text2 && !strcmp(child2->name, "MIDDLE")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
941 purple_notify_user_info_add_pair(user_info, _("Middle Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
942 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
943 g_free(text2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
944 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
945 } else if(text && !strcmp(child->name, "NICKNAME")) {
24200
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
946 /* Prefer the Nickcname to the Full Name as the serverside alias if it's not just part of the jid.
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
947 * Ignore it if it's part of the jid. */
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
948 if (strstr(bare_jid, text) == NULL) {
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
949 g_free(serverside_alias);
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
950 serverside_alias = g_strdup(text);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
951
24200
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
952 purple_notify_user_info_add_pair(user_info, _("Nickname"), text);
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
953 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
954 } else if(text && !strcmp(child->name, "BDAY")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
955 purple_notify_user_info_add_pair(user_info, _("Birthday"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
956 } else if(!strcmp(child->name, "ADR")) {
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
957 gboolean address_line_added = FALSE;
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
958
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
959 for(child2 = child->child; child2; child2 = child2->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
960 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
961 char *text2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
962
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
963 if(child2->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
964 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
965
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
966 text2 = xmlnode_get_data(child2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
967 if (text2 == NULL)
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
968 continue;
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
969
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
970 /* We do this here so that it's not added if all the child
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
971 * elements are empty. */
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
972 if (!address_line_added)
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
973 {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
974 purple_notify_user_info_add_section_header(user_info, _("Address"));
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
975 address_line_added = TRUE;
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
976 }
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
977
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
978 if(!strcmp(child2->name, "POBOX")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
979 purple_notify_user_info_add_pair(user_info, _("P.O. Box"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
980 } else if(!strcmp(child2->name, "EXTADR")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
981 purple_notify_user_info_add_pair(user_info, _("Extended Address"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
982 } else if(!strcmp(child2->name, "STREET")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
983 purple_notify_user_info_add_pair(user_info, _("Street Address"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
984 } else if(!strcmp(child2->name, "LOCALITY")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
985 purple_notify_user_info_add_pair(user_info, _("Locality"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
986 } else if(!strcmp(child2->name, "REGION")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
987 purple_notify_user_info_add_pair(user_info, _("Region"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
988 } else if(!strcmp(child2->name, "PCODE")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
989 purple_notify_user_info_add_pair(user_info, _("Postal Code"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
990 } else if(!strcmp(child2->name, "CTRY")
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
991 || !strcmp(child2->name, "COUNTRY")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
992 purple_notify_user_info_add_pair(user_info, _("Country"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
993 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
994 g_free(text2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
995 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
996
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
997 if (address_line_added)
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
998 purple_notify_user_info_add_section_break(user_info);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
999
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1000 } else if(!strcmp(child->name, "TEL")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1001 char *number;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1002 if((child2 = xmlnode_get_child(child, "NUMBER"))) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1003 /* show what kind of number it is */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1004 number = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1005 if(number) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1006 purple_notify_user_info_add_pair(user_info, _("Telephone"), number);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1007 g_free(number);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1008 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1009 } else if((number = xmlnode_get_data(child))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1010 /* lots of clients (including purple) do this, but it's
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1011 * out of spec */
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1012 purple_notify_user_info_add_pair(user_info, _("Telephone"), number);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1013 g_free(number);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1014 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1015 } else if(!strcmp(child->name, "EMAIL")) {
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1016 char *userid, *escaped;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1017 if((child2 = xmlnode_get_child(child, "USERID"))) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1018 /* show what kind of email it is */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1019 userid = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1020 if(userid) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1021 char *mailto;
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1022 escaped = g_markup_escape_text(userid, -1);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1023 mailto = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", escaped, escaped);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1024 purple_notify_user_info_add_pair(user_info, _("Email"), mailto);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1025
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1026 g_free(mailto);
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1027 g_free(escaped);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1028 g_free(userid);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1029 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1030 } else if((userid = xmlnode_get_data(child))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1031 /* lots of clients (including purple) do this, but it's
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1032 * out of spec */
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1033 char *mailto;
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1034
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1035 escaped = g_markup_escape_text(userid, -1);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1036 mailto = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", escaped, escaped);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1037 purple_notify_user_info_add_pair(user_info, _("Email"), mailto);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1038
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1039 g_free(mailto);
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1040 g_free(escaped);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1041 g_free(userid);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1042 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1043 } else if(!strcmp(child->name, "ORG")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1044 for(child2 = child->child; child2; child2 = child2->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1045 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1046 char *text2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1047
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
1048 if(child2->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1049 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1050
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1051 text2 = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1052 if(text2 && !strcmp(child2->name, "ORGNAME")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1053 purple_notify_user_info_add_pair(user_info, _("Organization Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1054 } else if(text2 && !strcmp(child2->name, "ORGUNIT")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1055 purple_notify_user_info_add_pair(user_info, _("Organization Unit"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1056 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1057 g_free(text2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1058 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1059 } else if(text && !strcmp(child->name, "TITLE")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1060 purple_notify_user_info_add_pair(user_info, _("Title"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1061 } else if(text && !strcmp(child->name, "ROLE")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1062 purple_notify_user_info_add_pair(user_info, _("Role"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1063 } else if(text && !strcmp(child->name, "DESC")) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1064 purple_notify_user_info_add_pair(user_info, _("Description"), text);
7076
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
1065 } else if(!strcmp(child->name, "PHOTO") ||
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
1066 !strcmp(child->name, "LOGO")) {
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1067 char *bintext = NULL;
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1068 xmlnode *binval;
11361
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
1069
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
1070 if( ((binval = xmlnode_get_child(child, "BINVAL")) &&
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
1071 (bintext = xmlnode_get_data(binval))) ||
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
1072 (bintext = xmlnode_get_data(child))) {
11127
5e539d9d26a4 [gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents: 10941
diff changeset
1073 gsize size;
11137
cf40226ddff7 [gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents: 11127
diff changeset
1074 guchar *data;
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1075 gboolean photo = (strcmp(child->name, "PHOTO") == 0);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1076
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1077 data = purple_base64_decode(bintext, &size);
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1078 if (data) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1079 char *img_text;
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 25109
diff changeset
1080 char *hash;
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1081
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1082 jbi->vcard_imgids = g_slist_prepend(jbi->vcard_imgids, GINT_TO_POINTER(purple_imgstore_add_with_id(g_memdup(data, size), size, "logo.png")));
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1083 img_text = g_strdup_printf("<img id='%d'>", GPOINTER_TO_INT(jbi->vcard_imgids->data));
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1084
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1085 purple_notify_user_info_add_pair(user_info, (photo ? _("Photo") : _("Logo")), img_text);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1086
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 25109
diff changeset
1087 hash = jabber_calculate_data_sha1sum(data, size);
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1088 purple_buddy_icons_set_for_user(js->gc->account, bare_jid,
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1089 data, size, hash);
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 25109
diff changeset
1090 g_free(hash);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1091 g_free(img_text);
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1092 }
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 25109
diff changeset
1093 g_free(bintext);
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1094 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1095 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1096 g_free(text);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1097 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1098 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1099
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1100 if (serverside_alias) {
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1101 /* If we found a serverside alias, set it and tell the core */
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1102 serv_got_alias(js->gc, from, serverside_alias);
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1103 if (b) {
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1104 purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", serverside_alias);
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1105 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1106
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1107 g_free(serverside_alias);
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1108 }
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1109
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1110 g_free(bare_jid);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1111
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1112 jabber_buddy_info_show_if_ready(jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1113 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1114
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1115 static void jabber_buddy_info_resource_free(gpointer data)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1116 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1117 JabberBuddyInfoResource *jbri = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1118 g_free(jbri);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1119 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1120
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1121 static void jabber_version_parse(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1122 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1123 xmlnode *packet, gpointer data)
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1124 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1125 JabberBuddyInfo *jbi = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1126 xmlnode *query;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1127 char *resource_name;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1128
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1129 g_return_if_fail(jbi != NULL);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1130
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1131 jabber_buddy_info_remove_id(jbi, id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1132
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1133 if(!from)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1134 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1135
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1136 resource_name = jabber_get_resource(from);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1137
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1138 if(resource_name) {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1139 if (type == JABBER_IQ_RESULT) {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1140 if((query = xmlnode_get_child(packet, "query"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1141 JabberBuddyResource *jbr = jabber_buddy_find_resource(jbi->jb, resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1142 if(jbr) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1143 xmlnode *node;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1144 if((node = xmlnode_get_child(query, "name"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1145 jbr->client.name = xmlnode_get_data(node);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1146 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1147 if((node = xmlnode_get_child(query, "version"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1148 jbr->client.version = xmlnode_get_data(node);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1149 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1150 if((node = xmlnode_get_child(query, "os"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1151 jbr->client.os = xmlnode_get_data(node);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1152 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1153 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1154 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1155 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1156 g_free(resource_name);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1157 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1158
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1159 jabber_buddy_info_show_if_ready(jbi);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1160 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1161
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1162 static void jabber_last_parse(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1163 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1164 xmlnode *packet, gpointer data)
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1165 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1166 JabberBuddyInfo *jbi = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1167 xmlnode *query;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1168 char *resource_name;
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1169 const char *seconds;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1170
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1171 g_return_if_fail(jbi != NULL);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1172
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1173 jabber_buddy_info_remove_id(jbi, id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1174
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1175 if(!from)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1176 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1177
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1178 resource_name = jabber_get_resource(from);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1179
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1180 if(resource_name) {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1181 if (type == JABBER_IQ_RESULT) {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1182 if((query = xmlnode_get_child(packet, "query"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1183 seconds = xmlnode_get_attrib(query, "seconds");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1184 if(seconds) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1185 char *end = NULL;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1186 long sec = strtol(seconds, &end, 10);
27135
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1187 JabberBuddy *jb = NULL;
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1188 char *resource = NULL;
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1189 char *buddy_name = NULL;
25493
8bf093c656a5 When getting info from a buddy, update the idle status to the libpurple core
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
1190 JabberBuddyResource *jbr = NULL;
26958
a955bd42f529 propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
parents: 26764 26950
diff changeset
1191
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1192 if(end != seconds) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1193 JabberBuddyInfoResource *jbir = g_hash_table_lookup(jbi->resources, resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1194 if(jbir) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1195 jbir->idle_seconds = sec;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1196 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1197 }
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
1198 /* Update the idle time of the buddy resource, if we got it.
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
1199 This will correct the value when a server doesn't mark
27135
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1200 delayed presence and we got the presence when signing on */
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1201 jb = jabber_buddy_find(js, from, FALSE);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1202 if (jb) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1203 resource = jabber_get_resource(from);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1204 buddy_name = jabber_get_bare_jid(from);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1205 /* if the resource already has an idle time set, we
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1206 must have gotten it originally from a presence. In
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1207 this case we update it. Otherwise don't update it, to
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1208 avoid setting an idle and not getting informed about
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1209 the resource getting unidle */
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1210 if (resource && buddy_name) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1211 jbr = jabber_buddy_find_resource(jb, resource);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1212 if (jbr) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1213 if (jbr->idle) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1214 if (sec) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1215 jbr->idle = time(NULL) - sec;
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1216 } else {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1217 jbr->idle = 0;
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1218 }
27134
c7e25dd005c4 Fix a NULL deref if the resource has gone offline by the time we're parsing this reply.
Paul Aurich <darkrain42@pidgin.im>
parents: 27110
diff changeset
1219
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
1220 if (jbr ==
27135
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1221 jabber_buddy_find_resource(jb, NULL)) {
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
1222 purple_prpl_got_user_idle(js->gc->account,
27135
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1223 buddy_name, jbr->idle, jbr->idle);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1224 }
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1225 }
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1226 }
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1227 }
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1228 g_free(resource);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1229 g_free(buddy_name);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1230 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1231 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1232 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1233 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1234 g_free(resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1235 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1236
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1237 jabber_buddy_info_show_if_ready(jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1238 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1239
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1240 static void jabber_last_offline_parse(JabberStream *js, const char *from,
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1241 JabberIqType type, const char *id,
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1242 xmlnode *packet, gpointer data)
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1243 {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1244 JabberBuddyInfo *jbi = data;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1245 xmlnode *query;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1246 const char *seconds;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1247
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1248 g_return_if_fail(jbi != NULL);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1249
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1250 jabber_buddy_info_remove_id(jbi, id);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1251
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1252 if(!from)
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1253 return;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1254
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1255 if (type == JABBER_IQ_RESULT) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1256 if((query = xmlnode_get_child(packet, "query"))) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1257 seconds = xmlnode_get_attrib(query, "seconds");
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1258 if(seconds) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1259 char *end = NULL;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1260 long sec = strtol(seconds, &end, 10);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1261 if(end != seconds) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1262 jbi->last_seconds = sec;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1263 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1264 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1265 jbi->last_message = xmlnode_get_data(query);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1266 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1267 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1268
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1269 jabber_buddy_info_show_if_ready(jbi);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1270 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1271
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1272 static void jabber_time_parse(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1273 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1274 xmlnode *packet, gpointer data)
25822
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1275 {
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1276 JabberBuddyInfo *jbi = data;
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1277 JabberBuddyResource *jbr;
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1278 char *resource_name;
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1279
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1280 g_return_if_fail(jbi != NULL);
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1281
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1282 jabber_buddy_info_remove_id(jbi, id);
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1283
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1284 if (!from)
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1285 return;
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1286
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1287 resource_name = jabber_get_resource(from);
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1288 jbr = resource_name ? jabber_buddy_find_resource(jbi->jb, resource_name) : NULL;
25827
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1289 g_free(resource_name);
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1290 if (jbr) {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1291 if (type == JABBER_IQ_RESULT) {
25822
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1292 xmlnode *time = xmlnode_get_child(packet, "time");
25823
f17d4d5e59b4 Actually display the buddy's local time.
Paul Aurich <darkrain42@pidgin.im>
parents: 25822
diff changeset
1293 xmlnode *tzo = time ? xmlnode_get_child(time, "tzo") : NULL;
25827
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1294 char *tzo_data = tzo ? xmlnode_get_data(tzo) : NULL;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1295 if (tzo_data) {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1296 char *c = tzo_data;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1297 int hours, minutes;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1298 if (tzo_data[0] == 'Z' && tzo_data[1] == '\0') {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1299 jbr->tz_off = 0;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1300 } else {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1301 gboolean offset_positive = (tzo_data[0] == '+');
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1302 /* [+-]HH:MM */
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1303 if (((*c == '+' || *c == '-') && (c = c + 1)) &&
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1304 sscanf(c, "%02d:%02d", &hours, &minutes) == 2) {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1305 jbr->tz_off = 60*60*hours + 60*minutes;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1306 if (!offset_positive)
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1307 jbr->tz_off *= -1;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1308 } else {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1309 purple_debug_info("jabber", "Ignoring malformed timezone %s",
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1310 tzo_data);
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1311 }
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1312 }
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1313
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1314 g_free(tzo_data);
25822
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1315 }
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1316 }
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1317 }
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1318
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1319 jabber_buddy_info_show_if_ready(jbi);
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1320 }
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1321
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1322 void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js)
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1323 {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1324 if (js->pending_buddy_info_requests)
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1325 {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1326 JabberBuddyInfo *jbi;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1327 GSList *l = js->pending_buddy_info_requests;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1328 while (l) {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1329 jbi = l->data;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1330
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1331 g_slist_free(jbi->ids);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1332 jabber_buddy_info_destroy(jbi);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1333
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
1334 l = l->next;
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1335 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1336
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1337 g_slist_free(js->pending_buddy_info_requests);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1338 js->pending_buddy_info_requests = NULL;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1339 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1340 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1341
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1342 static gboolean jabber_buddy_get_info_timeout(gpointer data)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1343 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1344 JabberBuddyInfo *jbi = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1345
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1346 /* remove the pending callbacks */
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1347 while(jbi->ids) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1348 char *id = jbi->ids->data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1349 jabber_iq_remove_callback_by_id(jbi->js, id);
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1350 jbi->ids = g_slist_remove(jbi->ids, id);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1351 g_free(id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1352 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1353
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1354 jbi->js->pending_buddy_info_requests = g_slist_remove(jbi->js->pending_buddy_info_requests, jbi);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1355 jbi->timeout_handle = 0;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1356
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1357 jabber_buddy_info_show_if_ready(jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1358
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1359 return FALSE;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1360 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1361
17029
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1362 static gboolean _client_is_blacklisted(JabberBuddyResource *jbr, const char *ns)
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1363 {
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1364 /* can't be blacklisted if we don't know what you're running yet */
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1365 if(!jbr->client.name)
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1366 return FALSE;
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1367
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1368 if(!strcmp(ns, "jabber:iq:last")) {
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1369 if(!strcmp(jbr->client.name, "Trillian")) {
20350
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1370 /* verified by nwalp 2007/05/09 */
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1371 if(!strcmp(jbr->client.version, "3.1.0.121") ||
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1372 /* verified by nwalp 2007/09/19 */
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1373 !strcmp(jbr->client.version, "3.1.7.0")) {
17029
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1374 return TRUE;
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1375 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1376 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1377 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1378
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1379 return FALSE;
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1380 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1381
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1382 static void
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1383 dispatch_queries_for_resource(JabberStream *js, JabberBuddyInfo *jbi,
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1384 gboolean is_bare_jid, const char *jid,
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1385 JabberBuddyResource *jbr)
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1386 {
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1387 JabberIq *iq;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1388 JabberBuddyInfoResource *jbir;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1389 char *full_jid = NULL;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1390 const char *to;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1391
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1392 g_return_if_fail(jbr->name != NULL);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1393
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1394 if (is_bare_jid) {
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1395 full_jid = g_strdup_printf("%s/%s", jid, jbr->name);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1396 to = full_jid;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1397 } else
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1398 to = jid;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1399
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1400 jbir = g_new0(JabberBuddyInfoResource, 1);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1401 g_hash_table_insert(jbi->resources, g_strdup(jbr->name), jbir);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1402
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1403 if(!jbr->client.name) {
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1404 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:version");
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1405 xmlnode_set_attrib(iq->node, "to", to);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1406 jabber_iq_set_callback(iq, jabber_version_parse, jbi);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1407 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1408 jabber_iq_send(iq);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1409 }
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1410
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1411 /* this is to fix the feeling of irritation I get when trying
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1412 * to get info on a friend running Trillian, which doesn't
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1413 * respond (with an error or otherwise) to jabber:iq:last
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1414 * requests. There are a number of Trillian users in my
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1415 * office. */
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1416 if(!_client_is_blacklisted(jbr, "jabber:iq:last")) {
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1417 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:last");
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1418 xmlnode_set_attrib(iq->node, "to", to);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1419 jabber_iq_set_callback(iq, jabber_last_parse, jbi);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1420 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1421 jabber_iq_send(iq);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1422 }
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1423
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1424 if (jbr->tz_off == PURPLE_NO_TZ_OFF &&
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1425 (!jbr->caps.info ||
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1426 jabber_resource_has_capability(jbr, "urn:xmpp:time"))) {
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1427 xmlnode *child;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1428 iq = jabber_iq_new(js, JABBER_IQ_GET);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1429 xmlnode_set_attrib(iq->node, "to", to);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1430 child = xmlnode_new_child(iq->node, "time");
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1431 xmlnode_set_namespace(child, "urn:xmpp:time");
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1432 jabber_iq_set_callback(iq, jabber_time_parse, jbi);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1433 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1434 jabber_iq_send(iq);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1435 }
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1436
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1437 g_free(full_jid);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1438 }
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1439
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1440 static void jabber_buddy_get_info_for_jid(JabberStream *js, const char *jid)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1441 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1442 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1443 xmlnode *vcard;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1444 GList *resources;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1445 JabberBuddy *jb;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1446 JabberBuddyInfo *jbi;
27485
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1447 const char *slash;
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1448 gboolean is_bare_jid;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1449
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1450 jb = jabber_buddy_find(js, jid, TRUE);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1451
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1452 /* invalid JID */
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1453 if(!jb)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1454 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1455
27485
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1456 slash = strchr(jid, '/');
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1457 is_bare_jid = (slash == NULL);
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1458
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1459 jbi = g_new0(JabberBuddyInfo, 1);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1460 jbi->jid = g_strdup(jid);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1461 jbi->js = js;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1462 jbi->jb = jb;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1463 jbi->resources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, jabber_buddy_info_resource_free);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1464 jbi->user_info = purple_notify_user_info_new();
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1465
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1466 iq = jabber_iq_new(js, JABBER_IQ_GET);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1467
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1468 xmlnode_set_attrib(iq->node, "to", jid);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1469 vcard = xmlnode_new_child(iq->node, "vCard");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13794
diff changeset
1470 xmlnode_set_namespace(vcard, "vcard-temp");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1471
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1472 jabber_iq_set_callback(iq, jabber_vcard_parse, jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1473 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1474
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1475 jabber_iq_send(iq);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1476
27485
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1477 if (is_bare_jid) {
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1478 for(resources = jb->resources; resources; resources = resources->next) {
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1479 JabberBuddyResource *jbr = resources->data;
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1480 dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr);
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1481 }
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1482 } else {
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1483 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, slash + 1);
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1484 if (jbr)
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1485 dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr);
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1486 else
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1487 purple_debug_warning("jabber", "jabber_buddy_get_info_for_jid() "
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1488 "was passed JID %s, but there is no corresponding "
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1489 "JabberBuddyResource!\n", jid);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1490 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1491
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1492 if (!jb->resources && is_bare_jid) {
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1493 /* user is offline, send a jabber:iq:last to find out last time online */
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1494 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:last");
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1495 xmlnode_set_attrib(iq->node, "to", jid);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1496 jabber_iq_set_callback(iq, jabber_last_offline_parse, jbi);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1497 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1498 jabber_iq_send(iq);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1499 }
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
1500
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1501 js->pending_buddy_info_requests = g_slist_prepend(js->pending_buddy_info_requests, jbi);
25716
1b5be208d5ba applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents: 25575
diff changeset
1502 jbi->timeout_handle = purple_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1503 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1504
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1505 void jabber_buddy_get_info(PurpleConnection *gc, const char *who)
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1506 {
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1507 JabberStream *js = purple_connection_get_protocol_data(gc);
24829
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1508 JabberID *jid = jabber_id_new(who);
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1509
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1510 if (!jid)
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1511 return;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1512
25575
9fbf7bf38146 A JID can have no node (the part before the @), but a chat must have one,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25454
diff changeset
1513 if (jid->node && jabber_chat_find(js, jid->node, jid->domain)) {
24829
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1514 /* For a conversation, include the resource (indicates the user). */
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1515 jabber_buddy_get_info_for_jid(js, who);
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1516 } else {
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1517 char *bare_jid = jabber_get_bare_jid(who);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1518 jabber_buddy_get_info_for_jid(js, bare_jid);
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1519 g_free(bare_jid);
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1520 }
24829
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1521
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1522 jabber_id_free(jid);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1523 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1524
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1525 static void jabber_buddy_set_invisibility(JabberStream *js, const char *who,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1526 gboolean invisible)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1527 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1528 PurplePresence *gpresence;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1529 PurpleAccount *account;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1530 PurpleStatus *status;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1531 JabberBuddy *jb = jabber_buddy_find(js, who, TRUE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1532 xmlnode *presence;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1533 JabberBuddyState state;
14525
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1534 char *msg;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1535 int priority;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1536
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1537 account = purple_connection_get_account(js->gc);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1538 gpresence = purple_account_get_presence(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1539 status = purple_presence_get_active_status(gpresence);
9944
71ef020ec4b0 [gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents: 9797
diff changeset
1540
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1541 purple_status_to_jabber(status, &state, &msg, &priority);
17770
e67998927a3c Added the ability to define extensions to caps
Andreas Monitzer <am@adiumx.com>
parents: 17051
diff changeset
1542 presence = jabber_presence_create_js(js, state, msg, priority);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1543
14525
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1544 g_free(msg);
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1545
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1546 xmlnode_set_attrib(presence, "to", who);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1547 if(invisible) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1548 xmlnode_set_attrib(presence, "type", "invisible");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1549 jb->invisible |= JABBER_INVIS_BUDDY;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1550 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1551 jb->invisible &= ~JABBER_INVIS_BUDDY;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1552 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1553
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1554 jabber_send(js, presence);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1555 xmlnode_free(presence);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1556 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1557
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1558 static void jabber_buddy_make_invisible(PurpleBlistNode *node, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1559 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1560 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1561 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1562 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1563
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1564 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1565
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1566 buddy = (PurpleBuddy *) node;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1567 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1568 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1569
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1570 jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), TRUE);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1571 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1572
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1573 static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1574 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1575 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1576 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1577 JabberStream *js;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1578
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1579 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1580
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1581 buddy = (PurpleBuddy *) node;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1582 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1583 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1584
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1585 jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), FALSE);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1586 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1587
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1588 static void jabber_buddy_cancel_presence_notification(PurpleBlistNode *node,
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1589 gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1590 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1591 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1592 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1593 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1594
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1595 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1596
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1597 buddy = (PurpleBuddy *) node;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1598 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1599 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1600
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1601 /* I wonder if we should prompt the user before doing this */
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1602 jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribed");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1603 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1604
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1605 static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data)
7250
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1606 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1607 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1608 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1609 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1610
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1611 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
7250
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1612
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1613 buddy = (PurpleBuddy *) node;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1614 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1615 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1616
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1617 jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "subscribe");
7250
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1618 }
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1619
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1620
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1621 static void jabber_buddy_unsubscribe(PurpleBlistNode *node, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1622 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1623 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1624 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1625 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1626
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1627 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1628
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1629 buddy = (PurpleBuddy *) node;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1630 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1631 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1632
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1633 jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribe");
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1634 }
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1635
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1636 static void jabber_buddy_login(PurpleBlistNode *node, gpointer data) {
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1637 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1638 /* simply create a directed presence of the current status */
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1639 PurpleBuddy *buddy = (PurpleBuddy *) node;
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1640 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1641 JabberStream *js = purple_connection_get_protocol_data(gc);
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1642 PurpleAccount *account = purple_connection_get_account(gc);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1643 PurplePresence *gpresence = purple_account_get_presence(account);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1644 PurpleStatus *status = purple_presence_get_active_status(gpresence);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1645 xmlnode *presence;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1646 JabberBuddyState state;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1647 char *msg;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1648 int priority;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1649
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1650 purple_status_to_jabber(status, &state, &msg, &priority);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1651 presence = jabber_presence_create_js(js, state, msg, priority);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1652
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1653 g_free(msg);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1654
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1655 xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy));
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1656
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1657 jabber_send(js, presence);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1658 xmlnode_free(presence);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1659 }
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1660 }
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1661
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1662 static void jabber_buddy_logout(PurpleBlistNode *node, gpointer data) {
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1663 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1664 /* simply create a directed unavailable presence */
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1665 PurpleBuddy *buddy = (PurpleBuddy *) node;
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1666 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1667 JabberStream *js = purple_connection_get_protocol_data(gc);
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1668 xmlnode *presence;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1669
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1670 presence = jabber_presence_create_js(js, JABBER_BUDDY_STATE_UNAVAILABLE, NULL, 0);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1671
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1672 xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy));
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1673
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1674 jabber_send(js, presence);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1675 xmlnode_free(presence);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1676 }
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1677 }
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1678
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1679 static GList *jabber_buddy_menu(PurpleBuddy *buddy)
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1680 {
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1681 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1682 JabberStream *js = purple_connection_get_protocol_data(gc);
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1683 const char *name = purple_buddy_get_name(buddy);
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1684 JabberBuddy *jb = jabber_buddy_find(js, name, TRUE);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1685 GList *jbrs;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1686
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1687 GList *m = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1688 PurpleMenuAction *act;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1689
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1690 if(!jb)
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1691 return m;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1692
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1693 /* XXX: fix the NOT ME below */
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1694
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1695 if(js->protocol_version == JABBER_PROTO_0_9 /* && NOT ME */) {
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1696 if(jb->invisible & JABBER_INVIS_BUDDY) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1697 act = purple_menu_action_new(_("Un-hide From"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1698 PURPLE_CALLBACK(jabber_buddy_make_visible),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1699 NULL, NULL);
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1700 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1701 act = purple_menu_action_new(_("Temporarily Hide From"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1702 PURPLE_CALLBACK(jabber_buddy_make_invisible),
13019
71d729443516 [gaim-migrate @ 15372]
Etan Reisner <deryni@pidgin.im>
parents: 12933
diff changeset
1703 NULL, NULL);
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1704 }
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1705 m = g_list_append(m, act);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1706 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1707
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1708 if(jb->subscription & JABBER_SUB_FROM /* && NOT ME */) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1709 act = purple_menu_action_new(_("Cancel Presence Notification"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1710 PURPLE_CALLBACK(jabber_buddy_cancel_presence_notification),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1711 NULL, NULL);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1712 m = g_list_append(m, act);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1713 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1714
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1715 if(!(jb->subscription & JABBER_SUB_TO)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1716 act = purple_menu_action_new(_("(Re-)Request authorization"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1717 PURPLE_CALLBACK(jabber_buddy_rerequest_auth),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1718 NULL, NULL);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1719 m = g_list_append(m, act);
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1720
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1721 } else /* if(NOT ME) */{
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1722
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1723 /* shouldn't this just happen automatically when the buddy is
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1724 removed? */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1725 act = purple_menu_action_new(_("Unsubscribe"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1726 PURPLE_CALLBACK(jabber_buddy_unsubscribe),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1727 NULL, NULL);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1728 m = g_list_append(m, act);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1729 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1730
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1731 /*
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1732 * This if-condition implements parts of XEP-0100: Gateway Interaction
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1733 *
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1734 * According to stpeter, there is no way to know if a jid on the roster is a gateway without sending a disco#info.
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1735 * However, since the gateway might appear offline to us, we cannot get that information. Therefore, I just assume
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1736 * that gateways on the roster can be identified by having no '@' in their jid. This is a faily safe assumption, since
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1737 * people don't tend to have a server or other service there.
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1738 */
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1739 if (g_utf8_strchr(name, -1, '@') == NULL) {
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1740 act = purple_menu_action_new(_("Log In"),
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1741 PURPLE_CALLBACK(jabber_buddy_login),
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1742 NULL, NULL);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1743 m = g_list_append(m, act);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1744 act = purple_menu_action_new(_("Log Out"),
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1745 PURPLE_CALLBACK(jabber_buddy_logout),
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1746 NULL, NULL);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1747 m = g_list_append(m, act);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1748 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1749
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1750 /* add all ad hoc commands to the action menu */
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1751 for(jbrs = jb->resources; jbrs; jbrs = g_list_next(jbrs)) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1752 JabberBuddyResource *jbr = jbrs->data;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1753 GList *commands;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1754 if (!jbr->commands)
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1755 continue;
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1756 for(commands = jbr->commands; commands; commands = g_list_next(commands)) {
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1757 JabberAdHocCommands *cmd = commands->data;
17818
ebd51078c0e6 Now all ad-hoc commands have to be sent through jabber_adhoc_execute to be properly executed (including the form steps). This cleans up the code a bit, and avoids DOS attacks by flooding the client with malicious ad-hoc command forms that were not requested.
Andreas Monitzer <am@adiumx.com>
parents: 17816
diff changeset
1758 act = purple_menu_action_new(cmd->name, PURPLE_CALLBACK(jabber_adhoc_execute_action), cmd, NULL);
17816
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1759 m = g_list_append(m, act);
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1760 }
1b7362b4a7a2 Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents: 17808
diff changeset
1761 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1762
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1763 return m;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1764 }
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1765
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1766 GList *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1767 jabber_blist_node_menu(PurpleBlistNode *node)
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1768 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1769 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1770 return jabber_buddy_menu((PurpleBuddy *) node);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1771 } else {
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1772 return NULL;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1773 }
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1774 }
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1775
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1776
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1777 const char *
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1778 jabber_buddy_state_get_name(JabberBuddyState state)
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1779 {
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1780 switch(state) {
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1781 case JABBER_BUDDY_STATE_UNKNOWN:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1782 return _("Unknown");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1783 case JABBER_BUDDY_STATE_ERROR:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1784 return _("Error");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1785 case JABBER_BUDDY_STATE_UNAVAILABLE:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1786 return _("Offline");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1787 case JABBER_BUDDY_STATE_ONLINE:
12467
94948d1eb8cf [gaim-migrate @ 14777]
Richard Laager <rlaager@pidgin.im>
parents: 12323
diff changeset
1788 return _("Available");
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1789 case JABBER_BUDDY_STATE_CHAT:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1790 return _("Chatty");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1791 case JABBER_BUDDY_STATE_AWAY:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1792 return _("Away");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1793 case JABBER_BUDDY_STATE_XA:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1794 return _("Extended Away");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1795 case JABBER_BUDDY_STATE_DND:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1796 return _("Do Not Disturb");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1797 }
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1798
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1799 return _("Unknown");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1800 }
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1801
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1802 JabberBuddyState jabber_buddy_status_id_get_state(const char *id) {
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1803 if(!id)
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1804 return JABBER_BUDDY_STATE_UNKNOWN;
11540
ad0321374664 [gaim-migrate @ 13795]
Mark Doliner <markdoliner@pidgin.im>
parents: 11533
diff changeset
1805 if(!strcmp(id, "available"))
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1806 return JABBER_BUDDY_STATE_ONLINE;
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1807 if(!strcmp(id, "freeforchat"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1808 return JABBER_BUDDY_STATE_CHAT;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1809 if(!strcmp(id, "away"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1810 return JABBER_BUDDY_STATE_AWAY;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1811 if(!strcmp(id, "extended_away"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1812 return JABBER_BUDDY_STATE_XA;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1813 if(!strcmp(id, "dnd"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1814 return JABBER_BUDDY_STATE_DND;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1815 if(!strcmp(id, "offline"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1816 return JABBER_BUDDY_STATE_UNAVAILABLE;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1817 if(!strcmp(id, "error"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1818 return JABBER_BUDDY_STATE_ERROR;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1819
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1820 return JABBER_BUDDY_STATE_UNKNOWN;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1821 }
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1822
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1823 const struct {
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1824 const char *name;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1825 JabberBuddyState state;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1826 } show_state_pairs[] = {
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1827 { "available", JABBER_BUDDY_STATE_ONLINE },
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1828 { "chat", JABBER_BUDDY_STATE_CHAT },
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1829 { "away", JABBER_BUDDY_STATE_AWAY },
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1830 { "xa", JABBER_BUDDY_STATE_XA },
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1831 { "dnd", JABBER_BUDDY_STATE_DND },
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1832 { "offline", JABBER_BUDDY_STATE_UNAVAILABLE },
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1833 { "error", JABBER_BUDDY_STATE_ERROR },
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1834 { NULL, JABBER_BUDDY_STATE_UNKNOWN }
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1835 };
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1836
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1837 JabberBuddyState jabber_buddy_show_get_state(const char *id)
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1838 {
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1839 int i;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1840
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1841 g_return_val_if_fail(id != NULL, JABBER_BUDDY_STATE_UNKNOWN);
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1842
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1843 for (i = 0; show_state_pairs[i].name; ++i)
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1844 if (g_str_equal(id, show_state_pairs[i].name))
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1845 return show_state_pairs[i].state;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1846
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1847 purple_debug_warning("jabber", "Invalid value of presence <show/> "
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1848 "attribute: %s\n", id);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1849 return JABBER_BUDDY_STATE_UNKNOWN;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1850 }
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1851
27619
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1852 const char *
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1853 jabber_buddy_state_get_show(JabberBuddyState state)
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1854 {
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1855 int i;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1856
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1857 for (i = 0; show_state_pairs[i].name; ++i)
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1858 if (state == show_state_pairs[i].state)
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1859 return show_state_pairs[i].name;
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1860
3600b7157ab7 Various minor changes to jabber_presence_parse. No functionality changes.
Paul Aurich <darkrain42@pidgin.im>
parents: 27552
diff changeset
1861 /* purple_debug_warning("jabber", "Unknown buddy state: %d\n", state); */
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1862 return NULL;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1863 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1864
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1865 const char *jabber_buddy_state_get_status_id(JabberBuddyState state) {
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1866 switch(state) {
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1867 case JABBER_BUDDY_STATE_CHAT:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1868 return "freeforchat";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1869 case JABBER_BUDDY_STATE_AWAY:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1870 return "away";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1871 case JABBER_BUDDY_STATE_XA:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1872 return "extended_away";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1873 case JABBER_BUDDY_STATE_DND:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1874 return "dnd";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1875 case JABBER_BUDDY_STATE_ONLINE:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1876 return "available";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1877 case JABBER_BUDDY_STATE_UNKNOWN:
13758
431e33afd630 [gaim-migrate @ 16167]
Sean Egan <seanegan@pidgin.im>
parents: 13715
diff changeset
1878 return "available";
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1879 case JABBER_BUDDY_STATE_ERROR:
13758
431e33afd630 [gaim-migrate @ 16167]
Sean Egan <seanegan@pidgin.im>
parents: 13715
diff changeset
1880 return "error";
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1881 case JABBER_BUDDY_STATE_UNAVAILABLE:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1882 return "offline";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1883 }
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1884 return NULL;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1885 }
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1886
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1887 static void user_search_result_add_buddy_cb(PurpleConnection *gc, GList *row, void *user_data)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1888 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1889 /* XXX find out the jid */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1890 purple_blist_request_add_buddy(purple_connection_get_account(gc),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1891 g_list_nth_data(row, 0), NULL, NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1892 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1893
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1894 static void user_search_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1895 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1896 xmlnode *packet, gpointer data)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1897 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1898 PurpleNotifySearchResults *results;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1899 PurpleNotifySearchColumn *column;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1900 xmlnode *x, *query, *item, *field;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1901
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1902 /* XXX error checking? */
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1903 if(!(query = xmlnode_get_child(packet, "query")))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1904 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1905
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1906 results = purple_notify_searchresults_new();
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1907 if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1908 xmlnode *reported;
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1909 GSList *column_vars = NULL;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1910
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1911 purple_debug_info("jabber", "new-skool\n");
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1912
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1913 if((reported = xmlnode_get_child(x, "reported"))) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1914 xmlnode *field = xmlnode_get_child(reported, "field");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1915 while(field) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1916 const char *var = xmlnode_get_attrib(field, "var");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1917 const char *label = xmlnode_get_attrib(field, "label");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1918 if(var) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1919 column = purple_notify_searchresults_column_new(label ? label : var);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1920 purple_notify_searchresults_column_add(results, column);
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1921 column_vars = g_slist_append(column_vars, (char *)var);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1922 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1923 field = xmlnode_get_next_twin(field);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1924 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1925 }
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1926
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1927 item = xmlnode_get_child(x, "item");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1928 while(item) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1929 GList *row = NULL;
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1930 GSList *l;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1931 xmlnode *valuenode;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1932 const char *var;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1933
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1934 for (l = column_vars; l != NULL; l = l->next) {
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1935 /*
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1936 * Build a row containing the strings that correspond
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1937 * to each column of the search results.
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1938 */
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1939 for (field = xmlnode_get_child(item, "field");
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1940 field != NULL;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1941 field = xmlnode_get_next_twin(field))
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1942 {
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1943 if ((var = xmlnode_get_attrib(field, "var")) &&
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1944 !strcmp(var, l->data) &&
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1945 (valuenode = xmlnode_get_child(field, "value")))
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1946 {
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1947 char *value = xmlnode_get_data(valuenode);
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1948 row = g_list_append(row, value);
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1949 break;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1950 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1951 }
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1952 if (field == NULL)
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1953 /* No data for this column */
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1954 row = g_list_append(row, NULL);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1955 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1956 purple_notify_searchresults_row_add(results, row);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1957 item = xmlnode_get_next_twin(item);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1958 }
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1959
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1960 g_slist_free(column_vars);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1961 } else {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1962 /* old skool */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1963 purple_debug_info("jabber", "old-skool\n");
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1964
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1965 column = purple_notify_searchresults_column_new(_("JID"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1966 purple_notify_searchresults_column_add(results, column);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1967 column = purple_notify_searchresults_column_new(_("First Name"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1968 purple_notify_searchresults_column_add(results, column);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1969 column = purple_notify_searchresults_column_new(_("Last Name"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1970 purple_notify_searchresults_column_add(results, column);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1971 column = purple_notify_searchresults_column_new(_("Nickname"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1972 purple_notify_searchresults_column_add(results, column);
23325
a374a26fe217 Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents: 23026
diff changeset
1973 column = purple_notify_searchresults_column_new(_("Email"));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1974 purple_notify_searchresults_column_add(results, column);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1975
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1976 for(item = xmlnode_get_child(query, "item"); item; item = xmlnode_get_next_twin(item)) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1977 const char *jid;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1978 xmlnode *node;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1979 GList *row = NULL;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1980
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1981 if(!(jid = xmlnode_get_attrib(item, "jid")))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1982 continue;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1983
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1984 row = g_list_append(row, g_strdup(jid));
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1985 node = xmlnode_get_child(item, "first");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1986 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1987 node = xmlnode_get_child(item, "last");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1988 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1989 node = xmlnode_get_child(item, "nick");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1990 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1991 node = xmlnode_get_child(item, "email");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1992 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
22622
1ecb840b5101 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents: 22586
diff changeset
1993 purple_debug_info("jabber", "row=%p\n", row);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1994 purple_notify_searchresults_row_add(results, row);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1995 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1996 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1997
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1998 purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD,
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1999 user_search_result_add_buddy_cb);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2000
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2001 purple_notify_searchresults(js->gc, NULL, NULL, _("The following are the results of your search"), results, NULL, NULL);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2002 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2003
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2004 static void user_search_x_data_cb(JabberStream *js, xmlnode *result, gpointer data)
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2005 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2006 xmlnode *query;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2007 JabberIq *iq;
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2008 char *dir_server = data;
21388
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2009 const char *type;
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2010
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2011 /* if they've cancelled the search, we're
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2012 * just going to get an error if we send
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2013 * a cancel, so skip it */
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2014 type = xmlnode_get_attrib(result, "type");
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2015 if(type && !strcmp(type, "cancel")) {
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2016 g_free(dir_server);
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2017 return;
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2018 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2019
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2020 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2021 query = xmlnode_get_child(iq->node, "query");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2022
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2023 xmlnode_insert_child(query, result);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2024
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2025 jabber_iq_set_callback(iq, user_search_result_cb, NULL);
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2026 xmlnode_set_attrib(iq->node, "to", dir_server);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2027 jabber_iq_send(iq);
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2028 g_free(dir_server);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2029 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2030
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2031 struct user_search_info {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2032 JabberStream *js;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2033 char *directory_server;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2034 };
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2035
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2036 static void user_search_cancel_cb(struct user_search_info *usi, PurpleRequestFields *fields)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2037 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2038 g_free(usi->directory_server);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2039 g_free(usi);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2040 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2041
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2042 static void user_search_cb(struct user_search_info *usi, PurpleRequestFields *fields)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2043 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2044 JabberStream *js = usi->js;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2045 JabberIq *iq;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2046 xmlnode *query;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2047 GList *groups, *flds;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2048
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2049 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2050 query = xmlnode_get_child(iq->node, "query");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2051
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2052 for(groups = purple_request_fields_get_groups(fields); groups; groups = groups->next) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2053 for(flds = purple_request_field_group_get_fields(groups->data);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2054 flds; flds = flds->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2055 PurpleRequestField *field = flds->data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2056 const char *id = purple_request_field_get_id(field);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2057 const char *value = purple_request_field_string_get_value(field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2058
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2059 if(value && (!strcmp(id, "first") || !strcmp(id, "last") || !strcmp(id, "nick") || !strcmp(id, "email"))) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2060 xmlnode *y = xmlnode_new_child(query, id);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2061 xmlnode_insert_data(y, value, -1);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2062 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2063 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2064 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2065
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2066 jabber_iq_set_callback(iq, user_search_result_cb, NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2067 xmlnode_set_attrib(iq->node, "to", usi->directory_server);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2068 jabber_iq_send(iq);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2069
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2070 g_free(usi->directory_server);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2071 g_free(usi);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2072 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2073
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2074 #if 0
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2075 /* This is for gettext only -- it will see this even though there's an #if 0. */
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2076
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2077 /*
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2078 * An incomplete list of server generated original language search
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2079 * comments for Jabber User Directories
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2080 *
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2081 * See discussion thread "Search comment for Jabber is not translatable"
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2082 * in purple-i18n@lists.sourceforge.net (March 2006)
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2083 */
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2084 static const char * jabber_user_dir_comments [] = {
19894
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18798
diff changeset
2085 /* current comment from Jabber User Directory users.jabber.org */
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18798
diff changeset
2086 N_("Find a contact by entering the search criteria in the given fields. "
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18798
diff changeset
2087 "Note: Each field supports wild card searches (%)"),
b273d0db2bdd Fixed code indenting, some spaces were still left and now replaced by tabs.
Andreas Monitzer <am@adiumx.com>
parents: 18798
diff changeset
2088 NULL
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2089 };
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2090 #endif
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2091
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2092 static void user_search_fields_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2093 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2094 xmlnode *packet, gpointer data)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2095 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2096 xmlnode *query, *x;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2097
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2098 if (!from)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2099 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2100
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2101 if (type == JABBER_IQ_ERROR) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20350
diff changeset
2102 char *msg = jabber_parse_error(js, packet, NULL);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2103
13634
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2104 if(!msg)
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2105 msg = g_strdup(_("Unknown error"));
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2106
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2107 purple_notify_error(js->gc, _("Directory Query Failed"),
13634
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2108 _("Could not query the directory server."), msg);
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2109 g_free(msg);
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2110
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2111 return;
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2112 }
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2113
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2114
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2115 if(!(query = xmlnode_get_child(packet, "query")))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2116 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2117
13330
33fb51d94dfd [gaim-migrate @ 15699]
Nathan Walp <nwalp@pidgin.im>
parents: 13019
diff changeset
2118 if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) {
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2119 jabber_x_data_request(js, x, user_search_x_data_cb, g_strdup(from));
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2120 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2121 } else {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2122 struct user_search_info *usi;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2123 xmlnode *instnode;
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2124 char *instructions = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2125 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2126 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2127 PurpleRequestField *field;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2128
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2129 /* old skool */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2130 fields = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2131 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2132 purple_request_fields_add_group(fields, group);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2133
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2134 if((instnode = xmlnode_get_child(query, "instructions")))
13574
433001d94e3e [gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents: 13572
diff changeset
2135 {
433001d94e3e [gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents: 13572
diff changeset
2136 char *tmp = xmlnode_get_data(instnode);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2137
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2138 if(tmp)
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2139 {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2140 /* Try to translate the message (see static message
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2141 list in jabber_user_dir_comments[]) */
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2142 instructions = g_strdup_printf(_("Server Instructions: %s"), _(tmp));
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2143 g_free(tmp);
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2144 }
13574
433001d94e3e [gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents: 13572
diff changeset
2145 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2146
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2147 if(!instructions)
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2148 {
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2149 instructions = g_strdup(_("Fill in one or more fields to search "
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16799
diff changeset
2150 "for any matching XMPP users."));
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2151 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2152
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2153 if(xmlnode_get_child(query, "first")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2154 field = purple_request_field_string_new("first", _("First Name"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2155 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2156 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2157 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2158 if(xmlnode_get_child(query, "last")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2159 field = purple_request_field_string_new("last", _("Last Name"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2160 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2161 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2162 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2163 if(xmlnode_get_child(query, "nick")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2164 field = purple_request_field_string_new("nick", _("Nickname"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2165 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2166 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2167 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2168 if(xmlnode_get_child(query, "email")) {
23325
a374a26fe217 Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents: 23026
diff changeset
2169 field = purple_request_field_string_new("email", _("Email Address"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2170 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2171 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2172 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2173
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2174 usi = g_new0(struct user_search_info, 1);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2175 usi->js = js;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2176 usi->directory_server = g_strdup(from);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2177
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2178 purple_request_fields(js->gc, _("Search for XMPP users"),
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16799
diff changeset
2179 _("Search for XMPP users"), instructions, fields,
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2180 _("Search"), G_CALLBACK(user_search_cb),
16490
68c22924d66b Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents: 15884
diff changeset
2181 _("Cancel"), G_CALLBACK(user_search_cancel_cb),
17798
45d377fdb3c3 Fixed weird bug that caused not supplying the account when searching for users.
Andreas Monitzer <am@adiumx.com>
parents: 17789
diff changeset
2182 purple_connection_get_account(js->gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2183 usi);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2184
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2185 g_free(instructions);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2186 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2187 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2188
17807
d98844d33c37 Exposed the user search function, so that directory searches can be performed directly when the jid is known.
Andreas Monitzer <am@adiumx.com>
parents: 17798
diff changeset
2189 void jabber_user_search(JabberStream *js, const char *directory)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2190 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2191 JabberIq *iq;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2192
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2193 /* XXX: should probably better validate the directory we're given */
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2194 if(!directory || !*directory) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2195 purple_notify_error(js->gc, _("Invalid Directory"), _("Invalid Directory"), NULL);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2196 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2197 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2198
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2199 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:search");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2200 xmlnode_set_attrib(iq->node, "to", directory);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2201
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2202 jabber_iq_set_callback(iq, user_search_fields_result_cb, NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2203
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2204 jabber_iq_send(iq);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2205 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2206
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2207 void jabber_user_search_begin(PurplePluginAction *action)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2208 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2209 PurpleConnection *gc = (PurpleConnection *) action->context;
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
2210 JabberStream *js = purple_connection_get_protocol_data(gc);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2211
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2212 purple_request_input(gc, _("Enter a User Directory"), _("Enter a User Directory"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2213 _("Select a user directory to search"),
17007
66c0fa6e5e2a Removes 'jabber.org' defaults from XMPP. I think we had agreed this was a good idea.
Sean Egan <seanegan@pidgin.im>
parents: 16961
diff changeset
2214 js->user_directories ? js->user_directories->data : NULL,
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2215 FALSE, FALSE, NULL,
17807
d98844d33c37 Exposed the user search function, so that directory searches can be performed directly when the jid is known.
Andreas Monitzer <am@adiumx.com>
parents: 17798
diff changeset
2216 _("Search Directory"), PURPLE_CALLBACK(jabber_user_search),
16490
68c22924d66b Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents: 15884
diff changeset
2217 _("Cancel"), NULL,
68c22924d66b Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents: 15884
diff changeset
2218 NULL, NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2219 js);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2220 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2221
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2222 gboolean
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2223 jabber_resource_has_capability(const JabberBuddyResource *jbr, const gchar *cap)
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2224 {
24802
eb481e98ac6a Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
2225 const GList *node = NULL;
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2226 const JabberCapsNodeExts *exts;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2227
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2228 if (!jbr->caps.info) {
27696
2cd9b9331f06 Lower the severity of this message.
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
2229 purple_debug_info("jabber",
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2230 "Unable to find caps: nothing known about buddy\n");
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2231 return FALSE;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2232 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2233
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2234 node = g_list_find_custom(jbr->caps.info->features, cap, (GCompareFunc)strcmp);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2235 if (!node && jbr->caps.exts && jbr->caps.info->exts) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2236 const GList *ext;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2237 exts = jbr->caps.info->exts;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2238 /* Walk through all the enabled caps, checking each list for the cap.
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2239 * Don't check it twice, though. */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2240 for (ext = jbr->caps.exts; ext && !node; ext = ext->next) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2241 GList *features = g_hash_table_lookup(exts->exts, ext->data);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2242 if (features)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2243 node = g_list_find_custom(features, cap, (GCompareFunc)strcmp);
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2244 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2245 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2246
24802
eb481e98ac6a Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
2247 return (node != NULL);
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2248 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2249
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2250 gboolean
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2251 jabber_buddy_has_capability(const JabberBuddy *jb, const gchar *cap)
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2252 {
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2253 JabberBuddyResource *jbr = jabber_buddy_find_resource((JabberBuddy*)jb, NULL);
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2254
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2255 if (!jbr) {
25454
9a1500ef24bd This happens anytime you IM an offline user, and is totally not an error
Mark Doliner <markdoliner@pidgin.im>
parents: 25391
diff changeset
2256 purple_debug_info("jabber",
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2257 "Unable to find caps: buddy might be offline\n");
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2258 return FALSE;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2259 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2260
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2261 return jabber_resource_has_capability(jbr, cap);
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2262 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2263
25577
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2264 const gchar *
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2265 jabber_resource_get_identity_category_type(const JabberBuddyResource *jbr,
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2266 const gchar *category)
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2267 {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2268 const GList *iter = NULL;
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2269
27286
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
2270 if (jbr->caps.info) {
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
2271 for (iter = jbr->caps.info->identities ; iter ; iter = g_list_next(iter)) {
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
2272 const JabberIdentity *identity =
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
2273 (JabberIdentity *) iter->data;
25577
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2274
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2275 if (strcmp(identity->category, category) == 0) {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2276 return identity->type;
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2277 }
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2278 }
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2279 }
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2280
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2281 return NULL;
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2282 }

mercurial