libpurple/protocols/jabber/buddy.c

Sat, 09 Aug 2008 01:58:27 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Sat, 09 Aug 2008 01:58:27 +0000
changeset 24012
913d6f18cb95
parent 23501
55185be28a1b
child 24200
6c6870d15155
child 26117
69b9346d3e48
permissions
-rw-r--r--

Restrict buddy icon downloads from arbitrary urls to 200kB.
Also, cancel buddy icon downloads when disconnecting.

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"
10684
0325b164a7eb [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10662
diff changeset
22 #include "cipher.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "debug.h"
7076
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
24 #include "imgstore.h"
9713
bb37562302a1 [gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents: 9466
diff changeset
25 #include "prpl.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26 #include "notify.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "request.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "util.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
29 #include "xmlnode.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 #include "buddy.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "chat.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 #include "jabber.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 #include "iq.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 #include "presence.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
24012
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
40 #define MAX_HTTP_BUDDYICON_BYTES (200 * 1024)
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
41
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
42 typedef struct {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
43 long idle_seconds;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
44 } JabberBuddyInfoResource;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
45
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
46 typedef struct {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
47 JabberStream *js;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
48 JabberBuddy *jb;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
49 char *jid;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
50 GSList *ids;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
51 GHashTable *resources;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
52 int timeout_handle;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
53 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
54 PurpleNotifyUserInfo *user_info;
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;
7445
f325eaaabe1c [gaim-migrate @ 8052]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
72 const 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
7445
f325eaaabe1c [gaim-migrate @ 8052]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
77 if(!(realname = jabber_normalize(js->gc->account, 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);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84 g_hash_table_insert(js->buddies, g_strdup(realname), jb);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
87 return jb;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
88 }
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 JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92 const char *resource)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 JabberBuddyResource *jbr = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 GList *l;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97 if(!jb)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 return NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 for(l = jb->resources; l; l = l->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102 if(!jbr && !resource) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 jbr = l->data;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 } else if(!resource) {
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
105 if(((JabberBuddyResource *)l->data)->priority > jbr->priority)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 jbr = l->data;
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
107 else if(((JabberBuddyResource *)l->data)->priority == jbr->priority) {
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
108 /* Determine if this resource is more available than the one we've currently chosen */
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
109 switch(((JabberBuddyResource *)l->data)->state) {
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 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
111 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
112 /* This resource is online/chatty. Prefer to one which isn't either. */
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 if ((jbr->state != JABBER_BUDDY_STATE_ONLINE) && (jbr->state != 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 jbr = l->data;
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
115 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
116 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
117 case JABBER_BUDDY_STATE_DND:
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
118 case JABBER_BUDDY_STATE_UNAVAILABLE:
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 /* This resource is away/dnd/unavailable. Prefer to one which is extended away or 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
120 if ((jbr->state == JABBER_BUDDY_STATE_XA) ||
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 (jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == 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
122 jbr = l->data;
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
123 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
124 case JABBER_BUDDY_STATE_XA:
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
125 /* This resource is extended away. That's better than 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
126 if ((jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == 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
127 jbr = l->data;
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_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
130 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
131 /* 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
132 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
133 }
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
134 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
135 } else if(((JabberBuddyResource *)l->data)->name) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
136 if(!strcmp(((JabberBuddyResource *)l->data)->name, resource)) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
137 jbr = l->data;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
138 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
139 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
141 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 return jbr;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
145
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
146 JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource,
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
147 int priority, JabberBuddyState state, const char *status)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150 if(!jbr) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
151 jbr = g_new0(JabberBuddyResource, 1);
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
152 jbr->jb = jb;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
153 jbr->name = g_strdup(resource);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154 jbr->capabilities = JABBER_CAP_XHTML;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155 jb->resources = g_list_append(jb->resources, jbr);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
156 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157 jbr->priority = priority;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
158 jbr->state = state;
22928
6bd622930dba Simplify
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
159 g_free(jbr->status);
6bd622930dba Simplify
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
160 jbr->status = status != NULL ? g_markup_escape_text(status, -1) : NULL;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
161
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
162 return jbr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
165 void jabber_buddy_resource_free(JabberBuddyResource *jbr)
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
166 {
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
167 g_return_if_fail(jbr != NULL);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
168
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
169 jbr->jb->resources = g_list_remove(jbr->jb->resources, jbr);
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
170
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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178 }
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
179
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
180 jabber_caps_free_clientinfo(jbr->caps);
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
181
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
182 g_free(jbr->name);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
183 g_free(jbr->status);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
184 g_free(jbr->thread_id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
185 g_free(jbr->client.name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
186 g_free(jbr->client.version);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
187 g_free(jbr->client.os);
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
188 g_free(jbr);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
189 }
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
190
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
191 void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
192 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
193 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
194
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195 if(!jbr)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
196 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
197
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
198 jabber_buddy_resource_free(jbr);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
199 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
200
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
201 const char *jabber_buddy_get_status_msg(JabberBuddy *jb)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
203 JabberBuddyResource *jbr;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205 if(!jb)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206 return NULL;
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 jbr = jabber_buddy_find_resource(jb, NULL);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210 if(!jbr)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211 return NULL;
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 return jbr->status;
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
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
216 /*******
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
217 * 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
218 * 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
219 * with a format for user information, hence the namespace of 'vcard-temp'
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
220 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
221 * 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
222 * _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
223 * 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
224 * replace vcard-temp
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
225 * --Nathan
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
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 /* Jabber "set info" (vCard) support */
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
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 * V-Card format:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
234 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
235 * <vCard prodid='' version='' xmlns=''>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
236 * <FN></FN>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237 * <N>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 * <FAMILY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239 * <GIVEN/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240 * </N>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241 * <NICKNAME/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 * <URL/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243 * <ADR>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244 * <STREET/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
245 * <EXTADD/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 * <LOCALITY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247 * <REGION/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248 * <PCODE/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249 * <COUNTRY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250 * </ADR>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251 * <TEL/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
252 * <EMAIL/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253 * <ORG>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
254 * <ORGNAME/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
255 * <ORGUNIT/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
256 * </ORG>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
257 * <TITLE/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
258 * <ROLE/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
259 * <DESC/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
260 * <BDAY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
261 * </vCard>
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 * See also:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
265 * http://docs.jabber.org/proto/html/vcard-temp.html
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
266 * http://www.vcard-xml.org/dtd/vCard-XML-v2-20010520.dtd
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
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270 * Cross-reference user-friendly V-Card entry labels to vCard XML tags
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
271 * and attributes.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
272 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
273 * 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
274 * knowing in what order real data will arrive.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276 * Format: Label, Pre-set text, "visible" flag, "editable" flag, XML tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 * name, XML tag's parent tag "path" (relative to vCard node).
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 * List is terminated by a NULL label pointer.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 * Entries with no label text, but with XML tag and parent tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282 * entries, are used by V-Card XML construction routines to
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283 * "automagically" construct the appropriate XML node tree.
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 * Thoughts on future direction/expansion
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 * This is a "simple" vCard.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
288 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289 * It is possible for nodes other than the "vCard" node to have
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290 * attributes. Should that prove necessary/desirable, add an
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
291 * "attributes" pointer to the vcard_template struct, create the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
292 * necessary tag_attr structs, and add 'em to the vcard_dflt_data
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
293 * array.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
294 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
295 * The above changes will (obviously) require changes to the vCard
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
296 * construction routines.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
297 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
298
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
299 struct vcard_template {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
300 char *label; /* label text pointer */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
301 char *text; /* entry text pointer */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
302 int visible; /* should entry field be "visible?" */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
303 int editable; /* should entry field be editable? */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
304 char *tag; /* tag text */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
305 char *ptag; /* parent tag "path" text */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
306 char *url; /* vCard display format if URL */
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
307 } const vcard_template_data[] = {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
308 {N_("Full Name"), NULL, TRUE, TRUE, "FN", NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
309 {N_("Family Name"), NULL, TRUE, TRUE, "FAMILY", "N", NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
310 {N_("Given Name"), NULL, TRUE, TRUE, "GIVEN", "N", NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
311 {N_("Nickname"), NULL, TRUE, TRUE, "NICKNAME", NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
312 {N_("URL"), NULL, TRUE, TRUE, "URL", NULL, "<A HREF=\"%s\">%s</A>"},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
313 {N_("Street Address"), NULL, TRUE, TRUE, "STREET", "ADR", NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
314 {N_("Extended Address"), NULL, TRUE, TRUE, "EXTADD", "ADR", NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
315 {N_("Locality"), NULL, TRUE, TRUE, "LOCALITY", "ADR", NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
316 {N_("Region"), NULL, TRUE, TRUE, "REGION", "ADR", NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
317 {N_("Postal Code"), NULL, TRUE, TRUE, "PCODE", "ADR", NULL},
13332
03c8a5392116 [gaim-migrate @ 15701]
Nathan Walp <nwalp@pidgin.im>
parents: 13330
diff changeset
318 {N_("Country"), NULL, TRUE, TRUE, "CTRY", "ADR", NULL},
11361
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
319 {N_("Telephone"), NULL, TRUE, TRUE, "NUMBER", "TEL", NULL},
23325
a374a26fe217 Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents: 23026
diff changeset
320 {N_("Email"), NULL, TRUE, TRUE, "USERID", "EMAIL", "<A HREF=\"mailto:%s\">%s</A>"},
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
321 {N_("Organization Name"), NULL, TRUE, TRUE, "ORGNAME", "ORG", NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
322 {N_("Organization Unit"), NULL, TRUE, TRUE, "ORGUNIT", "ORG", NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
323 {N_("Title"), NULL, TRUE, TRUE, "TITLE", NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
324 {N_("Role"), NULL, TRUE, TRUE, "ROLE", NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
325 {N_("Birthday"), NULL, TRUE, TRUE, "BDAY", NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
326 {N_("Description"), NULL, TRUE, TRUE, "DESC", NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
327 {"", NULL, TRUE, TRUE, "N", NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
328 {"", NULL, TRUE, TRUE, "ADR", NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329 {"", NULL, TRUE, TRUE, "ORG", NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
330 {NULL, NULL, 0, 0, NULL, NULL, NULL}
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
331 };
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
332
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
333 /*
8735
01248ea222d3 [gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents: 8401
diff changeset
334 * The "vCard" tag's attribute list...
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
335 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336 struct tag_attr {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
337 char *attr;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
338 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
339 } const vcard_tag_attr_list[] = {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
340 {"prodid", "-//HandGen//NONSGML vGen v1.0//EN"},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
341 {"version", "2.0", },
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
342 {"xmlns", "vcard-temp", },
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
343 {NULL, NULL},
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
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 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
348 * Insert a tag node into an xmlnode tree, recursively inserting parent tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
349 * nodes as necessary
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
350 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
351 * Returns pointer to inserted node
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
352 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
353 * 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
354 * calls itself), so don't put any "static"s in here!
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
355 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
356 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
357 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
358 xmlnode *x = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
359
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 * 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
362 * from the vCard template struct.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
363 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
364 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
365 const struct vcard_template *vc_tp = vcard_template_data;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
366
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
367 while(vc_tp->label != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
368 if(strcmp(vc_tp->tag, new_tag) == 0) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
369 parent_tag = vc_tp->ptag;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
370 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
371 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
372 ++vc_tp;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
373 }
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
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 we have a parent tag...
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 if(parent_tag != NULL ) {
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 * Try to get the parent node for a tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
382 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
383 if((x = xmlnode_get_child(start, parent_tag)) == NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
384 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
385 * Descend?
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
386 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
387 char *grand_parent = g_strdup(parent_tag);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
388 char *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 if((parent = strrchr(grand_parent, '/')) != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
391 *(parent++) = '\0';
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
392 x = insert_tag_to_parent_tag(start, grand_parent, parent);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
393 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
394 x = xmlnode_new_child(start, grand_parent);
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 g_free(grand_parent);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
397 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
398 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
399 * We found *something* to be the parent node.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
400 * Note: may be the "root" node!
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 xmlnode *y;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
403 if((y = xmlnode_get_child(x, new_tag)) != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
404 return(y);
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 }
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 * insert the new tag into its parent node
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
411 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
412 return(xmlnode_new_child((x == NULL? start : x), new_tag));
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
413 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
414
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
415 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
416 * Send vCard info to Jabber server
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
417 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
418 void jabber_set_info(PurpleConnection *gc, const char *info)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
419 {
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
420 PurpleStoredImage *img;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
421 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
422 JabberStream *js = gc->proto_data;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
423 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
424 const struct tag_attr *tag_attr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
425
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
426 /* 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
427 * 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
428 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
429 return;
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
430
15273
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
431 g_free(js->avatar_hash);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
432 js->avatar_hash = NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
433
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
434 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
435 * Send only if there's actually any *information* to send
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
436 */
11388
3c8b093b5cfe [gaim-migrate @ 13616]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
437 vc_node = info ? xmlnode_from_str(info, -1) : NULL;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
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 (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
440 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
441 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
442 vc_node = NULL;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
443 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
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 ((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
446 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
447 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
448 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
449 gchar *enc;
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
450 int i;
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 unsigned char hashval[20];
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 char *p, hash[41];
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
453
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
454 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
455 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
456 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
457 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
458 }
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
459
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
460 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
461 avatar_len = purple_imgstore_get_size(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
462 /* have to get rid of the old PHOTO if it exists */
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 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
464 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
465 }
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
466 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
467 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
468 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
469 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
470 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
471
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
472 purple_cipher_digest_region("sha1", 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
473 avatar_len, sizeof(hashval),
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
474 hashval, NULL);
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
475
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 purple_imgstore_unref(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
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 p = hash;
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
479 for(i=0; i<20; i++, p+=2)
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
480 snprintf(p, 3, "%02x", hashval[i]);
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
481 js->avatar_hash = g_strdup(hash);
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
482
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
483 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
484 g_free(enc);
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
485 }
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
486
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
487 if (vc_node != NULL) {
15273
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
488 iq = jabber_iq_new(js, JABBER_IQ_SET);
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
489 xmlnode_insert_child(iq->node, vc_node);
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
490 jabber_iq_send(iq);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
491 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
492 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
493
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
494 void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
495 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
496 PurplePresence *gpresence;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
497 PurpleStatus *status;
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
498
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
499 if(((JabberStream*)gc->proto_data)->pep) {
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
500 /* XEP-0084: User Avatars */
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
501 if(img) {
22942
2bf494f8e2a4 Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents: 22928
diff changeset
502 /*
2bf494f8e2a4 Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents: 22928
diff changeset
503 * TODO: This is pretty gross. The Jabber PRPL really shouldn't
2bf494f8e2a4 Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents: 22928
diff changeset
504 * do voodoo to try to determine the image type, height
2bf494f8e2a4 Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents: 22928
diff changeset
505 * and width.
2bf494f8e2a4 Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents: 22928
diff changeset
506 */
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
507 /* A PNG header, including the IHDR, but nothing else */
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
508 const struct {
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
509 guchar signature[8]; /* must be hex 89 50 4E 47 0D 0A 1A 0A */
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
510 struct {
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
511 guint32 length; /* must be 0x0d */
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
512 guchar type[4]; /* must be 'I' 'H' 'D' 'R' */
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
513 guint32 width;
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
514 guint32 height;
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
515 guchar bitdepth;
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
516 guchar colortype;
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
517 guchar compression;
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
518 guchar filter;
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
519 guchar interlace;
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
520 } ihdr;
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
521 } *png = purple_imgstore_get_data(img); /* ATTN: this is in network byte order! */
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
522
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
523 /* check if the data is a valid png file (well, at least to some extend) */
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
524 if(png->signature[0] == 0x89 &&
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
525 png->signature[1] == 0x50 &&
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
526 png->signature[2] == 0x4e &&
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
527 png->signature[3] == 0x47 &&
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
528 png->signature[4] == 0x0d &&
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
529 png->signature[5] == 0x0a &&
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
530 png->signature[6] == 0x1a &&
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
531 png->signature[7] == 0x0a &&
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
532 ntohl(png->ihdr.length) == 0x0d &&
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
533 png->ihdr.type[0] == 'I' &&
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
534 png->ihdr.type[1] == 'H' &&
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
535 png->ihdr.type[2] == 'D' &&
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
536 png->ihdr.type[3] == 'R') {
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
537 /* parse PNG header to get the size of the image (yes, this is required) */
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
538 guint32 width = ntohl(png->ihdr.width);
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
539 guint32 height = ntohl(png->ihdr.height);
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
540 xmlnode *publish, *item, *data, *metadata, *info;
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
541 char *lengthstring, *widthstring, *heightstring;
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
542
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
543 /* compute the sha1 hash */
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
544 PurpleCipherContext *ctx;
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
545 unsigned char digest[20];
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
546 char *hash;
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
547 char *base64avatar;
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
548
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
549 ctx = purple_cipher_context_new_by_name("sha1", NULL);
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
550 purple_cipher_context_append(ctx, purple_imgstore_get_data(img), purple_imgstore_get_size(img));
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
551 purple_cipher_context_digest(ctx, sizeof(digest), digest, NULL);
23026
361e8a25262b Leak fix
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 22942
diff changeset
552 purple_cipher_context_destroy(ctx);
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
553
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
554 /* convert digest to a string */
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
555 hash = g_strdup_printf("%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x",digest[0],digest[1],digest[2],digest[3],digest[4],digest[5],digest[6],digest[7],digest[8],digest[9],digest[10],digest[11],digest[12],digest[13],digest[14],digest[15],digest[16],digest[17],digest[18],digest[19]);
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
556
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
557 publish = xmlnode_new("publish");
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
558 xmlnode_set_attrib(publish,"node",AVATARNAMESPACEDATA);
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
559
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
560 item = xmlnode_new_child(publish, "item");
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
561 xmlnode_set_attrib(item, "id", hash);
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
562
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
563 data = xmlnode_new_child(item, "data");
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
564 xmlnode_set_namespace(data,AVATARNAMESPACEDATA);
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
565
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
566 base64avatar = purple_base64_encode(purple_imgstore_get_data(img), purple_imgstore_get_size(img));
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
567 xmlnode_insert_data(data,base64avatar,-1);
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
568 g_free(base64avatar);
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
569
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
570 /* publish the avatar itself */
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
571 jabber_pep_publish((JabberStream*)gc->proto_data, publish);
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
572
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
573 /* next step: publish the metadata */
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
574 publish = xmlnode_new("publish");
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
575 xmlnode_set_attrib(publish,"node",AVATARNAMESPACEMETA);
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
576
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
577 item = xmlnode_new_child(publish, "item");
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
578 xmlnode_set_attrib(item, "id", hash);
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
579
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
580 metadata = xmlnode_new_child(item, "metadata");
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
581 xmlnode_set_namespace(metadata,AVATARNAMESPACEMETA);
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
582
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
583 info = xmlnode_new_child(metadata, "info");
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
584 xmlnode_set_attrib(info, "id", hash);
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
585 xmlnode_set_attrib(info, "type", "image/png");
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
586 lengthstring = g_strdup_printf("%u", (unsigned)purple_imgstore_get_size(img));
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
587 xmlnode_set_attrib(info, "bytes", lengthstring);
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
588 g_free(lengthstring);
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
589 widthstring = g_strdup_printf("%u", width);
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
590 xmlnode_set_attrib(info, "width", widthstring);
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
591 g_free(widthstring);
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
592 heightstring = g_strdup_printf("%u", height);
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
593 xmlnode_set_attrib(info, "height", heightstring);
21681
80530c8be0a1 Fix a double-free and a leak at the same time.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21630
diff changeset
594 g_free(heightstring);
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
595
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
596 /* publish the metadata */
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
597 jabber_pep_publish((JabberStream*)gc->proto_data, publish);
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
598
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
599 g_free(hash);
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
600 } else { /* if(img) */
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
601 /* remove the metadata */
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
602 xmlnode *metadata, *item;
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
603 xmlnode *publish = xmlnode_new("publish");
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
604 xmlnode_set_attrib(publish,"node",AVATARNAMESPACEMETA);
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
605
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
606 item = xmlnode_new_child(publish, "item");
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
607
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
608 metadata = xmlnode_new_child(item, "metadata");
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
609 xmlnode_set_namespace(metadata,AVATARNAMESPACEMETA);
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
610
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
611 xmlnode_new_child(metadata, "stop");
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
612
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
613 /* publish the metadata */
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
614 jabber_pep_publish((JabberStream*)gc->proto_data, publish);
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
615 }
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
616 } else {
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
617 purple_debug(PURPLE_DEBUG_ERROR, "jabber",
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
618 "jabber_set_buddy_icon received non-png data");
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
619 }
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
620 }
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
621
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
622 /* even when the image is not png, we can still publish the vCard, since this
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
623 one doesn't require a specific image type */
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
624
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
625 /* publish vCard for those poor older clients */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
626 jabber_set_info(gc, purple_account_get_user_info(gc->account));
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
627
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
628 gpresence = purple_account_get_presence(gc->account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
629 status = purple_presence_get_active_status(gpresence);
10216
37091349650c [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10215
diff changeset
630 jabber_presence_send(gc->account, status);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
631 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
632
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
633 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
634 * This is the callback from the "ok clicked" for "set vCard"
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 * Formats GSList data into XML-encoded string and returns a pointer
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
637 * to said string.
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 * g_free()'ing the returned string space is the responsibility of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
640 * the caller.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
641 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
642 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
643 jabber_format_info(PurpleConnection *gc, PurpleRequestFields *fields)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
644 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
645 xmlnode *vc_node;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
646 PurpleRequestField *field;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
647 const char *text;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
648 char *p;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
649 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
650 const struct tag_attr *tag_attr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
651
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
652 vc_node = xmlnode_new("vCard");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
653
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
654 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
655 xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
656
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
657 for (vc_tp = vcard_template_data; vc_tp->label != NULL; vc_tp++) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
658 if (*vc_tp->label == '\0')
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
659 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
660
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
661 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
662 text = purple_request_field_string_get_value(field);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
663
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
664
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
665 if (text != NULL && *text != '\0') {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
666 xmlnode *xp;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
667
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
668 purple_debug(PURPLE_DEBUG_INFO, "jabber",
9339
31f4980a09ea [gaim-migrate @ 10147]
Nathan Walp <nwalp@pidgin.im>
parents: 9285
diff changeset
669 "Setting %s to '%s'\n", vc_tp->tag, text);
31f4980a09ea [gaim-migrate @ 10147]
Nathan Walp <nwalp@pidgin.im>
parents: 9285
diff changeset
670
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
671 if ((xp = insert_tag_to_parent_tag(vc_node,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
672 NULL, vc_tp->tag)) != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
673
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
674 xmlnode_insert_data(xp, text, -1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
675 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
676 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
677 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
678
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7445
diff changeset
679 p = xmlnode_to_str(vc_node, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
680 xmlnode_free(vc_node);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
681
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
682 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
683 serv_set_info(gc, p);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
684
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
685 g_free(p);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
686 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
687
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
688 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
689 * This gets executed by the proto action
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
690 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
691 * Creates a new PurpleRequestFields struct, gets the XML-formatted user_info
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
692 * string (if any) into GSLists for the (multi-entry) edit dialog and
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
693 * calls the set_vcard dialog.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
694 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
695 void jabber_setup_set_info(PurplePluginAction *action)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
696 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
697 PurpleConnection *gc = (PurpleConnection *) action->context;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
698 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
699 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
700 PurpleRequestField *field;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
701 const struct vcard_template *vc_tp;
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
702 const char *user_info;
14130
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
703 char *cdata = NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
704 xmlnode *x_vc_data = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
705
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
706 fields = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
707 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
708 purple_request_fields_add_group(fields, group);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
709
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
710 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
711 * Get existing, XML-formatted, user info
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
712 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
713 if((user_info = purple_account_get_user_info(gc->account)) != NULL)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
714 x_vc_data = xmlnode_from_str(user_info, -1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
715
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
716 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
717 * 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
718 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
719 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
720 xmlnode *data_node;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
721 if((vc_tp->label)[0] == '\0')
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
722 continue;
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
723
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
724 if (x_vc_data != NULL) {
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
725 if(vc_tp->ptag == NULL) {
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
726 data_node = xmlnode_get_child(x_vc_data, vc_tp->tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
727 } else {
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
728 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
729 data_node = xmlnode_get_child(x_vc_data, tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
730 g_free(tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
731 }
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
732 if(data_node)
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
733 cdata = xmlnode_get_data(data_node);
14130
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
734 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
735
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
736 if(strcmp(vc_tp->tag, "DESC") == 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
737 field = purple_request_field_string_new(vc_tp->tag,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
738 _(vc_tp->label), cdata,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
739 TRUE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
740 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
741 field = purple_request_field_string_new(vc_tp->tag,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
742 _(vc_tp->label), cdata,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
743 FALSE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
744 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
745
14130
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
746 g_free(cdata);
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
747 cdata = NULL;
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
748
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
749 purple_request_field_group_add_field(group, field);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
750 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
751
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
752 if(x_vc_data != NULL)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
753 xmlnode_free(x_vc_data);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
754
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
755 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
756 _("Edit XMPP vCard"),
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
757 _("All items below are optional. Enter only the "
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
758 "information with which you feel comfortable."),
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
759 fields,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
760 _("Save"), G_CALLBACK(jabber_format_info),
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
761 _("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
762 purple_connection_get_account(gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
763 gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
764 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
765
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
766 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
767 /* End Jabber "set info" (vCard) support */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
768 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
769
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
770 /******
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
771 * end of that ancient crap that needs to die
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
772 ******/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
773
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
774 static void jabber_buddy_info_destroy(JabberBuddyInfo *jbi)
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
775 {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
776 /* 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
777 if (jbi->timeout_handle > 0)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
778 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
779
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
780 g_free(jbi->jid);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
781 g_hash_table_destroy(jbi->resources);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
782 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
783 g_free(jbi);
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
784 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
785
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
786 static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
787 {
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15143
diff changeset
788 char *resource_name, *tmp;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
789 JabberBuddyResource *jbr;
15092
e7c5edee202e [gaim-migrate @ 17813]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 14669
diff changeset
790 JabberBuddyInfoResource *jbir = NULL;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
791 GList *resources;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
792 PurpleNotifyUserInfo *user_info;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
793
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
794 /* not yet */
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
795 if(jbi->ids)
11361
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
796 return;
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
797
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
798 user_info = jbi->user_info;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
799 resource_name = jabber_get_resource(jbi->jid);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
800
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
801 /* 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
802 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
803 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
804
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
805 /* Prepend the primary buddy info to user_info so that it goes before the vcard. */
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
806 if(resource_name) {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
807 jbr = jabber_buddy_find_resource(jbi->jb, resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
808 jbir = g_hash_table_lookup(jbi->resources, resource_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
809 if(jbr && jbr->client.name) {
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
810 tmp = g_strdup_printf("%s%s%s", jbr->client.name,
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
811 (jbr->client.version ? " " : ""),
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
812 (jbr->client.version ? jbr->client.version : ""));
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
813 purple_notify_user_info_add_pair(user_info, _("Client"), tmp);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
814 g_free(tmp);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
815
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
816 if(jbr->client.os) {
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
817 purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
818 }
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
819 }
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
820 if(jbir) {
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
821 if(jbir->idle_seconds > 0) {
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
822 char *idle = purple_str_seconds_to_string(jbir->idle_seconds);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
823 purple_notify_user_info_prepend_pair(user_info, _("Idle"), idle);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
824 g_free(idle);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
825 }
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
826 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
827 if(jbr) {
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
828 char *purdy = NULL;
23404
836828ff554c Remove compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23393
diff changeset
829 const char *status_name = jabber_buddy_state_get_name(jbr->state);
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
830 if(jbr->status)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
831 purdy = purple_strdup_withhtml(jbr->status);
23393
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
832 if(status_name && purdy && !strcmp(status_name, purdy))
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
833 status_name = NULL;
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
834
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
835 tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""),
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
836 ((status_name && purdy) ? ": " : ""),
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15143
diff changeset
837 (purdy ? purdy : ""));
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
838 purple_notify_user_info_prepend_pair(user_info, _("Status"), tmp);
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15143
diff changeset
839 g_free(tmp);
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15143
diff changeset
840 g_free(purdy);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
841 } else {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
842 purple_notify_user_info_prepend_pair(user_info, _("Status"), _("Unknown"));
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
843 }
19921
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
844 #if 0
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
845 /* #if 0 this for now; I think this would be far more useful if we limited this to a particular set of features
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
846 * of particular interest (-vv jumps out as one). As it is now, I don't picture people getting all excited: "Oh sweet crap!
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
847 * So-and-so supports 'jabber:x:data' AND 'Collaborative Data Objects'!"
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
848 */
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
849
18798
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
850 if(jbr && jbr->caps) {
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
851 GString *tmp = g_string_new("");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
852 GList *iter;
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
853 for(iter = jbr->caps->features; iter; iter = g_list_next(iter)) {
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
854 const char *feature = iter->data;
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
855
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
856 if(!strcmp(feature, "jabber:iq:last"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
857 feature = _("Last Activity");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
858 else if(!strcmp(feature, "http://jabber.org/protocol/disco#info"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
859 feature = _("Service Discovery Info");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
860 else if(!strcmp(feature, "http://jabber.org/protocol/disco#items"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
861 feature = _("Service Discovery Items");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
862 else if(!strcmp(feature, "http://jabber.org/protocol/address"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
863 feature = _("Extended Stanza Addressing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
864 else if(!strcmp(feature, "http://jabber.org/protocol/muc"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
865 feature = _("Multi-User Chat");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
866 else if(!strcmp(feature, "http://jabber.org/protocol/muc#user"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
867 feature = _("Multi-User Chat Extended Presence Information");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
868 else if(!strcmp(feature, "http://jabber.org/protocol/ibb"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
869 feature = _("In-Band Bytestreams");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
870 else if(!strcmp(feature, "http://jabber.org/protocol/commands"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
871 feature = _("Ad-Hoc Commands");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
872 else if(!strcmp(feature, "http://jabber.org/protocol/pubsub"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
873 feature = _("PubSub Service");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
874 else if(!strcmp(feature, "http://jabber.org/protocol/bytestreams"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
875 feature = _("SOCKS5 Bytestreams");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
876 else if(!strcmp(feature, "jabber:x:oob"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
877 feature = _("Out of Band Data");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
878 else if(!strcmp(feature, "http://jabber.org/protocol/xhtml-im"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
879 feature = _("XHTML-IM");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
880 else if(!strcmp(feature, "jabber:iq:register"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
881 feature = _("In-Band Registration");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
882 else if(!strcmp(feature, "http://jabber.org/protocol/geoloc"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
883 feature = _("User Location");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
884 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0084.html"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
885 feature = _("User Avatar");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
886 else if(!strcmp(feature, "http://jabber.org/protocol/chatstates"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
887 feature = _("Chat State Notifications");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
888 else if(!strcmp(feature, "jabber:iq:version"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
889 feature = _("Software Version");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
890 else if(!strcmp(feature, "http://jabber.org/protocol/si"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
891 feature = _("Stream Initiation");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
892 else if(!strcmp(feature, "http://jabber.org/protocol/si/profile/file-transfer"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
893 feature = _("File Transfer");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
894 else if(!strcmp(feature, "http://jabber.org/protocol/mood"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
895 feature = _("User Mood");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
896 else if(!strcmp(feature, "http://jabber.org/protocol/activity"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
897 feature = _("User Activity");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
898 else if(!strcmp(feature, "http://jabber.org/protocol/caps"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
899 feature = _("Entity Capabilities");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
900 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0116.html"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
901 feature = _("Encrypted Session Negotiations");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
902 else if(!strcmp(feature, "http://jabber.org/protocol/tune"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
903 feature = _("User Tune");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
904 else if(!strcmp(feature, "http://jabber.org/protocol/rosterx"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
905 feature = _("Roster Item Exchange");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
906 else if(!strcmp(feature, "http://jabber.org/protocol/reach"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
907 feature = _("Reachability Address");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
908 else if(!strcmp(feature, "http://jabber.org/protocol/profile"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
909 feature = _("User Profile");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
910 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0166.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
911 feature = _("Jingle");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
912 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0167.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
913 feature = _("Jingle Audio");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
914 else if(!strcmp(feature, "http://jabber.org/protocol/nick"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
915 feature = _("User Nickname");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
916 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0176.html#ns-udp"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
917 feature = _("Jingle ICE UDP");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
918 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0176.html#ns-tcp"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
919 feature = _("Jingle ICE TCP");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
920 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0177.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
921 feature = _("Jingle Raw UDP");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
922 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0180.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
923 feature = _("Jingle Video");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
924 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0181.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
925 feature = _("Jingle DTMF");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
926 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0184.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
927 feature = _("Message Receipts");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
928 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0189.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
929 feature = _("Public Key Publishing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
930 else if(!strcmp(feature, "http://jabber.org/protocol/chatting"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
931 feature = _("User Chatting");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
932 else if(!strcmp(feature, "http://jabber.org/protocol/browsing"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
933 feature = _("User Browsing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
934 else if(!strcmp(feature, "http://jabber.org/protocol/gaming"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
935 feature = _("User Gaming");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
936 else if(!strcmp(feature, "http://jabber.org/protocol/viewing"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
937 feature = _("User Viewing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
938 else if(!strcmp(feature, "urn:xmpp:ping") || !strcmp(feature, "http://www.xmpp.org/extensions/xep-0199.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
939 feature = _("Ping");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
940 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0200.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
941 feature = _("Stanza Encryption");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
942 else if(!strcmp(feature, "urn:xmpp:time"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
943 feature = _("Entity Time");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
944 else if(!strcmp(feature, "urn:xmpp:delay"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
945 feature = _("Delayed Delivery");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
946 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0204.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
947 feature = _("Collaborative Data Objects");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
948 else if(!strcmp(feature, "http://jabber.org/protocol/fileshare"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
949 feature = _("File Repository and Sharing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
950 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0215.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
951 feature = _("STUN Service Discovery for Jingle");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
952 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0116.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
953 feature = _("Simplified Encrypted Session Negotiation");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
954 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0219.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
955 feature = _("Hop Check");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
956 else if(g_str_has_suffix(feature, "+notify"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
957 feature = NULL;
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
958 if(feature)
19921
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
959 g_string_append_printf(tmp, "%s<br/>", feature);
18798
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
960 }
19921
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
961
18798
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
962 if(strlen(tmp->str) > 0)
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
963 purple_notify_user_info_prepend_pair(user_info, _("Capabilities"), tmp->str);
18798
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
964
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
965 g_string_free(tmp, TRUE);
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
966 }
19921
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
967 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
968 } else {
23367
6de6bf268665 Use g_list_length(jbi->jb->resources) here, as it's clearer since that's
Evan Schoenberg <evands@pidgin.im>
parents: 23364
diff changeset
969 gboolean multiple_resources = jbi->jb->resources && (g_list_length(jbi->jb->resources) > 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
970
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
971 for(resources = jbi->jb->resources; resources; resources = resources->next) {
23404
836828ff554c Remove compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23393
diff changeset
972 char *purdy = NULL;
836828ff554c Remove compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23393
diff changeset
973 const char *status_name = NULL;
836828ff554c Remove compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 23393
diff changeset
974
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
975 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
976
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
977 if(jbr->client.name) {
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
978 tmp = g_strdup_printf("%s%s%s", jbr->client.name,
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
979 (jbr->client.version ? " " : ""),
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
980 (jbr->client.version ? jbr->client.version : ""));
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_prepend_pair(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
982 _("Client"), tmp);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
983 g_free(tmp);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
984
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
985 if(jbr->client.os) {
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
986 purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
987 }
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
988 }
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
989
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
990 if(jbr->name && (jbir = g_hash_table_lookup(jbi->resources, jbr->name))) {
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
991 if(jbir->idle_seconds > 0) {
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
992 char *idle = purple_str_seconds_to_string(jbir->idle_seconds);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
993 purple_notify_user_info_prepend_pair(user_info, _("Idle"), idle);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
994 g_free(idle);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
995 }
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
996 }
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
997
23393
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
998 status_name = jabber_buddy_state_get_name(jbr->state);
7145
c77dd3b09666 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
999 if(jbr->status)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1000 purdy = purple_strdup_withhtml(jbr->status);
23393
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
1001 if(status_name && purdy && !strcmp(status_name, purdy))
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
1002 status_name = NULL;
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
1003
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
1004 tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""),
7b640ff909dc If the status name and status message are the same for a jabber buddy,
Evan Schoenberg <evands@pidgin.im>
parents: 23367
diff changeset
1005 ((status_name && purdy) ? ": " : ""),
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15143
diff changeset
1006 (purdy ? purdy : ""));
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1007 purple_notify_user_info_prepend_pair(user_info, _("Status"), tmp);
15205
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15143
diff changeset
1008 g_free(tmp);
f642029b2f97 [gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents: 15143
diff changeset
1009 g_free(purdy);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1010
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1011 if(multiple_resources) {
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1012 tmp = g_strdup_printf("%d", jbr->priority);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1013 purple_notify_user_info_prepend_pair(user_info, _("Priority"), tmp);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1014 g_free(tmp);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1015 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1016
15092
e7c5edee202e [gaim-migrate @ 17813]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 14669
diff changeset
1017 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
1018 purple_notify_user_info_prepend_pair(user_info, _("Resource"), jbr->name);
19921
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
1019 #if 0
18798
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1020 if(jbr && jbr->caps) {
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1021 GString *tmp = g_string_new("");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1022 GList *iter;
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1023 for(iter = jbr->caps->features; iter; iter = g_list_next(iter)) {
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1024 const char *feature = iter->data;
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1025
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1026 if(!strcmp(feature, "jabber:iq:last"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1027 feature = _("Last Activity");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1028 else if(!strcmp(feature, "http://jabber.org/protocol/disco#info"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1029 feature = _("Service Discovery Info");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1030 else if(!strcmp(feature, "http://jabber.org/protocol/disco#items"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1031 feature = _("Service Discovery Items");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1032 else if(!strcmp(feature, "http://jabber.org/protocol/address"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1033 feature = _("Extended Stanza Addressing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1034 else if(!strcmp(feature, "http://jabber.org/protocol/muc"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1035 feature = _("Multi-User Chat");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1036 else if(!strcmp(feature, "http://jabber.org/protocol/muc#user"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1037 feature = _("Multi-User Chat Extended Presence Information");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1038 else if(!strcmp(feature, "http://jabber.org/protocol/ibb"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1039 feature = _("In-Band Bytestreams");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1040 else if(!strcmp(feature, "http://jabber.org/protocol/commands"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1041 feature = _("Ad-Hoc Commands");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1042 else if(!strcmp(feature, "http://jabber.org/protocol/pubsub"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1043 feature = _("PubSub Service");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1044 else if(!strcmp(feature, "http://jabber.org/protocol/bytestreams"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1045 feature = _("SOCKS5 Bytestreams");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1046 else if(!strcmp(feature, "jabber:x:oob"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1047 feature = _("Out of Band Data");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1048 else if(!strcmp(feature, "http://jabber.org/protocol/xhtml-im"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1049 feature = _("XHTML-IM");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1050 else if(!strcmp(feature, "jabber:iq:register"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1051 feature = _("In-Band Registration");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1052 else if(!strcmp(feature, "http://jabber.org/protocol/geoloc"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1053 feature = _("User Location");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1054 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0084.html"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1055 feature = _("User Avatar");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1056 else if(!strcmp(feature, "http://jabber.org/protocol/chatstates"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1057 feature = _("Chat State Notifications");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1058 else if(!strcmp(feature, "jabber:iq:version"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1059 feature = _("Software Version");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1060 else if(!strcmp(feature, "http://jabber.org/protocol/si"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1061 feature = _("Stream Initiation");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1062 else if(!strcmp(feature, "http://jabber.org/protocol/si/profile/file-transfer"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1063 feature = _("File Transfer");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1064 else if(!strcmp(feature, "http://jabber.org/protocol/mood"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1065 feature = _("User Mood");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1066 else if(!strcmp(feature, "http://jabber.org/protocol/activity"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1067 feature = _("User Activity");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1068 else if(!strcmp(feature, "http://jabber.org/protocol/caps"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1069 feature = _("Entity Capabilities");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1070 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0116.html"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1071 feature = _("Encrypted Session Negotiations");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1072 else if(!strcmp(feature, "http://jabber.org/protocol/tune"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1073 feature = _("User Tune");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1074 else if(!strcmp(feature, "http://jabber.org/protocol/rosterx"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1075 feature = _("Roster Item Exchange");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1076 else if(!strcmp(feature, "http://jabber.org/protocol/reach"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1077 feature = _("Reachability Address");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1078 else if(!strcmp(feature, "http://jabber.org/protocol/profile"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1079 feature = _("User Profile");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1080 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0166.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1081 feature = _("Jingle");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1082 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0167.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1083 feature = _("Jingle Audio");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1084 else if(!strcmp(feature, "http://jabber.org/protocol/nick"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1085 feature = _("User Nickname");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1086 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0176.html#ns-udp"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1087 feature = _("Jingle ICE UDP");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1088 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0176.html#ns-tcp"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1089 feature = _("Jingle ICE TCP");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1090 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0177.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1091 feature = _("Jingle Raw UDP");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1092 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0180.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1093 feature = _("Jingle Video");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1094 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0181.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1095 feature = _("Jingle DTMF");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1096 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0184.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1097 feature = _("Message Receipts");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1098 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0189.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1099 feature = _("Public Key Publishing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1100 else if(!strcmp(feature, "http://jabber.org/protocol/chatting"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1101 feature = _("User Chatting");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1102 else if(!strcmp(feature, "http://jabber.org/protocol/browsing"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1103 feature = _("User Browsing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1104 else if(!strcmp(feature, "http://jabber.org/protocol/gaming"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1105 feature = _("User Gaming");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1106 else if(!strcmp(feature, "http://jabber.org/protocol/viewing"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1107 feature = _("User Viewing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1108 else if(!strcmp(feature, "urn:xmpp:ping") || !strcmp(feature, "http://www.xmpp.org/extensions/xep-0199.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1109 feature = _("Ping");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1110 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0200.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1111 feature = _("Stanza Encryption");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1112 else if(!strcmp(feature, "urn:xmpp:time"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1113 feature = _("Entity Time");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1114 else if(!strcmp(feature, "urn:xmpp:delay"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1115 feature = _("Delayed Delivery");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1116 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0204.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1117 feature = _("Collaborative Data Objects");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1118 else if(!strcmp(feature, "http://jabber.org/protocol/fileshare"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1119 feature = _("File Repository and Sharing");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1120 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0215.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1121 feature = _("STUN Service Discovery for Jingle");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1122 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0116.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1123 feature = _("Simplified Encrypted Session Negotiation");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1124 else if(!strcmp(feature, "http://www.xmpp.org/extensions/xep-0219.html#ns"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1125 feature = _("Hop Check");
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1126 else if(g_str_has_suffix(feature, "+notify"))
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1127 feature = NULL;
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1128
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1129 if(feature)
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1130 g_string_append_printf(tmp, "%s\n", feature);
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1131 }
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1132 if(strlen(tmp->str) > 0)
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1133 purple_notify_user_info_prepend_pair(user_info, _("Capabilities"), tmp->str);
18798
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1134
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1135 g_string_free(tmp, TRUE);
148a6c45b6f7 Now displaying a contact's client's capabilities in the info text if that client supports the caps extension.
Andreas Monitzer <am@adiumx.com>
parents: 18718
diff changeset
1136 }
19921
d920ce72002e Dont spam the buddy info window with esoteric capabilities
Sean Egan <seanegan@pidgin.im>
parents: 19897
diff changeset
1137 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1138 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1139 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1140
7306
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
1141 g_free(resource_name);
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
1142
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1143 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
1144
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1145 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
1146 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
1147 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
1148 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1149
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1150 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
1151
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1152 jabber_buddy_info_destroy(jbi);
13794
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 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
1156 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1157 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
1158 char *comp_id;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1159
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1160 if(!id)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1161 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1162
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1163 while(l) {
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
1164 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
1165 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
1166 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
1167 g_free(comp_id);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1168 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1169 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1170 l = l->next;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1171 }
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
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1174 static void jabber_vcard_save_mine(JabberStream *js, xmlnode *packet, gpointer data)
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1175 {
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1176 xmlnode *vcard;
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1177 char *txt;
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1178 PurpleStoredImage *img;
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1179
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1180 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
1181 (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
1182 {
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1183 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
1184 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
1185
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1186 g_free(txt);
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1187 } else {
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1188 /* 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
1189 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1190
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1191 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
1192
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1193 if(NULL != (img = purple_buddy_icons_find_account_icon(js->gc->account))) {
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1194 jabber_set_buddy_icon(js->gc, img);
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1195 purple_imgstore_unref(img);
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1196 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1197 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1198
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1199 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
1200 {
21957
0ce77f86c7f3 Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents: 21681
diff changeset
1201 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET);
0ce77f86c7f3 Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents: 21681
diff changeset
1202
0ce77f86c7f3 Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents: 21681
diff changeset
1203 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
1204 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
1205 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
1206
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1207 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
1208 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1209
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1210 static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1211 {
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
1212 const char *id, *from;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1213 char *bare_jid;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1214 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
1215 char *serverside_alias = NULL;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1216 xmlnode *vcard;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1217 PurpleBuddy *b;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1218 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
1219 PurpleNotifyUserInfo *user_info;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1220
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1221 from = xmlnode_get_attrib(packet, "from");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1222 id = xmlnode_get_attrib(packet, "id");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1223
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1224 if(!jbi)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1225 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1226
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
1227 jabber_buddy_info_remove_id(jbi, id);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
1228
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1229 if(!from)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1230 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1231
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
1232 if(!jabber_buddy_find(js, from, FALSE))
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1233 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1234
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1235 /* XXX: handle the error case */
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1236
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1237 user_info = jbi->user_info;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1238 bare_jid = jabber_get_bare_jid(from);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1239
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1240 b = purple_find_buddy(js->gc->account, bare_jid);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1241
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1242 if((vcard = xmlnode_get_child(packet, "vCard")) ||
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1243 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1244 xmlnode *child;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1245 for(child = vcard->child; child; child = child->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1246 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1247 xmlnode *child2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1248
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
1249 if(child->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1250 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1251
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1252 text = xmlnode_get_data(child);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1253 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
1254 /* If we havne't found a name yet, use this one as the serverside name */
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
1255 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
1256 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
1257
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1258 purple_notify_user_info_add_pair(user_info, _("Full Name"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1259 } else if(!strcmp(child->name, "N")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1260 for(child2 = child->child; child2; child2 = child2->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1261 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1262 char *text2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1263
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
1264 if(child2->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1265 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1266
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1267 text2 = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1268 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
1269 purple_notify_user_info_add_pair(user_info, _("Family Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1270 } 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
1271 purple_notify_user_info_add_pair(user_info, _("Given Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1272 } 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
1273 purple_notify_user_info_add_pair(user_info, _("Middle Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1274 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1275 g_free(text2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1276 }
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
1277 } else if(text && !strcmp(child->name, "NICKNAME")) {
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
1278 /* Prefer the Nickcname to the Full Name as the 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
1279 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
1280 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
1281
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1282 purple_notify_user_info_add_pair(user_info, _("Nickname"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1283 } 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
1284 purple_notify_user_info_add_pair(user_info, _("Birthday"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1285 } else if(!strcmp(child->name, "ADR")) {
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1286 gboolean address_line_added = FALSE;
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1287
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1288 for(child2 = child->child; child2; child2 = child2->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1289 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1290 char *text2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1291
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
1292 if(child2->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1293 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1294
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1295 text2 = xmlnode_get_data(child2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1296 if (text2 == NULL)
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1297 continue;
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1298
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1299 /* 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
1300 * elements are empty. */
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1301 if (!address_line_added)
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1302 {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1303 purple_notify_user_info_add_section_header(user_info, _("Address"));
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1304 address_line_added = TRUE;
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1305 }
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1306
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1307 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
1308 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
1309 } 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
1310 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
1311 } 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
1312 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
1313 } 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
1314 purple_notify_user_info_add_pair(user_info, _("Locality"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1315 } 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
1316 purple_notify_user_info_add_pair(user_info, _("Region"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1317 } 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
1318 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
1319 } else if(!strcmp(child2->name, "CTRY")
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1320 || !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
1321 purple_notify_user_info_add_pair(user_info, _("Country"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1322 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1323 g_free(text2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1324 }
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1325
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1326 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
1327 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
1328
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1329 } else if(!strcmp(child->name, "TEL")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1330 char *number;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1331 if((child2 = xmlnode_get_child(child, "NUMBER"))) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1332 /* show what kind of number it is */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1333 number = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1334 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
1335 purple_notify_user_info_add_pair(user_info, _("Telephone"), number);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1336 g_free(number);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1337 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1338 } else if((number = xmlnode_get_data(child))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1339 /* lots of clients (including purple) do this, but it's
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1340 * 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
1341 purple_notify_user_info_add_pair(user_info, _("Telephone"), number);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1342 g_free(number);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1343 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1344 } 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
1345 char *userid, *escaped;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1346 if((child2 = xmlnode_get_child(child, "USERID"))) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1347 /* show what kind of email it is */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1348 userid = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1349 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
1350 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
1351 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
1352 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
1353 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
1354
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1355 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
1356 g_free(escaped);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1357 g_free(userid);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1358 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1359 } else if((userid = xmlnode_get_data(child))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1360 /* lots of clients (including purple) do this, but it's
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1361 * 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
1362 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
1363
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1364 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
1365 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
1366 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
1367
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1368 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
1369 g_free(escaped);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1370 g_free(userid);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1371 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1372 } else if(!strcmp(child->name, "ORG")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1373 for(child2 = child->child; child2; child2 = child2->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1374 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1375 char *text2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1376
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
1377 if(child2->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1378 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1379
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1380 text2 = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1381 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
1382 purple_notify_user_info_add_pair(user_info, _("Organization Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1383 } 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
1384 purple_notify_user_info_add_pair(user_info, _("Organization Unit"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1385 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1386 g_free(text2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1387 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1388 } 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
1389 purple_notify_user_info_add_pair(user_info, _("Title"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1390 } 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
1391 purple_notify_user_info_add_pair(user_info, _("Role"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1392 } 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
1393 purple_notify_user_info_add_pair(user_info, _("Description"), text);
7076
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
1394 } else if(!strcmp(child->name, "PHOTO") ||
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
1395 !strcmp(child->name, "LOGO")) {
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1396 char *bintext = NULL;
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1397 xmlnode *binval;
11361
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
1398
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
1399 if( ((binval = xmlnode_get_child(child, "BINVAL")) &&
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
1400 (bintext = xmlnode_get_data(binval))) ||
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
1401 (bintext = xmlnode_get_data(child))) {
11127
5e539d9d26a4 [gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents: 10941
diff changeset
1402 gsize size;
11137
cf40226ddff7 [gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents: 11127
diff changeset
1403 guchar *data;
11127
5e539d9d26a4 [gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents: 10941
diff changeset
1404 int i;
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1405 unsigned char hashval[20];
11127
5e539d9d26a4 [gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents: 10941
diff changeset
1406 char *p, hash[41];
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1407 gboolean photo = (strcmp(child->name, "PHOTO") == 0);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1408
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1409 data = purple_base64_decode(bintext, &size);
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1410 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
1411 char *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
1412
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1413 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
1414 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
1415
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1416 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
1417
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1418 purple_cipher_digest_region("sha1", (guchar *)data, size,
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1419 sizeof(hashval), hashval, NULL);
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1420 p = hash;
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1421 for(i=0; i<20; i++, p+=2)
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1422 snprintf(p, 3, "%02x", hashval[i]);
7076
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
1423
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1424 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
1425 data, size, hash);
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1426 g_free(bintext);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1427 g_free(img_text);
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1428 }
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1429 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1430 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1431 g_free(text);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1432 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1433 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1434
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
1435 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
1436 /* 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
1437 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
1438 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
1439 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
1440 }
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
1441
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
1442 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
1443 }
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
1444
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1445 g_free(bare_jid);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1446
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1447 jabber_buddy_info_show_if_ready(jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1448 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1449
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1450 typedef struct _JabberBuddyAvatarUpdateURLInfo {
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1451 JabberStream *js;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1452 char *from;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1453 char *id;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1454 } JabberBuddyAvatarUpdateURLInfo;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1455
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1456 static void do_buddy_avatar_update_fromurl(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message) {
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1457 JabberBuddyAvatarUpdateURLInfo *info = user_data;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1458 if(!url_text) {
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1459 purple_debug(PURPLE_DEBUG_ERROR, "jabber",
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1460 "do_buddy_avatar_update_fromurl got error \"%s\"", error_message);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1461 return;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1462 }
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1463
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1464 purple_buddy_icons_set_for_user(purple_connection_get_account(info->js->gc), info->from, (void*)url_text, len, info->id);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1465 g_free(info->from);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1466 g_free(info->id);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1467 g_free(info);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1468 }
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1469
17789
f75d542850e3 Turns out the example in XEP-0084 is wrong. Fixed my implementation to not try to work around an issue that isn't one.
Andreas Monitzer <am@adiumx.com>
parents: 17788
diff changeset
1470 static void do_buddy_avatar_update_data(JabberStream *js, const char *from, xmlnode *items) {
f75d542850e3 Turns out the example in XEP-0084 is wrong. Fixed my implementation to not try to work around an issue that isn't one.
Andreas Monitzer <am@adiumx.com>
parents: 17788
diff changeset
1471 xmlnode *item, *data;
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1472 const char *checksum;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1473 char *b64data;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1474 void *img;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1475 size_t size;
17789
f75d542850e3 Turns out the example in XEP-0084 is wrong. Fixed my implementation to not try to work around an issue that isn't one.
Andreas Monitzer <am@adiumx.com>
parents: 17788
diff changeset
1476 if(!items)
f75d542850e3 Turns out the example in XEP-0084 is wrong. Fixed my implementation to not try to work around an issue that isn't one.
Andreas Monitzer <am@adiumx.com>
parents: 17788
diff changeset
1477 return;
f75d542850e3 Turns out the example in XEP-0084 is wrong. Fixed my implementation to not try to work around an issue that isn't one.
Andreas Monitzer <am@adiumx.com>
parents: 17788
diff changeset
1478
f75d542850e3 Turns out the example in XEP-0084 is wrong. Fixed my implementation to not try to work around an issue that isn't one.
Andreas Monitzer <am@adiumx.com>
parents: 17788
diff changeset
1479 item = xmlnode_get_child(items, "item");
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1480 if(!item)
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1481 return;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1482
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1483 data = xmlnode_get_child_with_namespace(item,"data",AVATARNAMESPACEDATA);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1484 if(!data)
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1485 return;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1486
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1487 checksum = xmlnode_get_attrib(item,"id");
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1488 if(!checksum)
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1489 return;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1490
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1491 b64data = xmlnode_get_data(data);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1492 if(!b64data)
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1493 return;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1494
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1495 img = purple_base64_decode(b64data, &size);
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19963
diff changeset
1496 if(!img) {
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19963
diff changeset
1497 g_free(b64data);
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1498 return;
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19963
diff changeset
1499 }
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1500
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1501 purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, img, size, checksum);
20320
6337e101f6ab Plug some memory leaks.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 19963
diff changeset
1502 g_free(b64data);
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1503 }
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1504
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
1505 void jabber_buddy_avatar_update_metadata(JabberStream *js, const char *from, xmlnode *items) {
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1506 PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(js->gc), from);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1507 const char *checksum;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1508 xmlnode *item, *metadata;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1509 if(!buddy)
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1510 return;
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
1511
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1512 checksum = purple_buddy_icons_get_checksum_for_user(buddy);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1513 item = xmlnode_get_child(items,"item");
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1514 metadata = xmlnode_get_child_with_namespace(item, "metadata", AVATARNAMESPACEMETA);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1515 if(!metadata)
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1516 return;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1517 /* check if we have received a stop */
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1518 if(xmlnode_get_child(metadata, "stop")) {
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1519 purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1520 } else {
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1521 xmlnode *info, *goodinfo = NULL;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1522
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1523 /* iterate over all info nodes to get one we can use */
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1524 for(info = metadata->child; info; info = info->next) {
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1525 if(info->type == XMLNODE_TYPE_TAG && !strcmp(info->name,"info")) {
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1526 const char *type = xmlnode_get_attrib(info,"type");
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1527 const char *id = xmlnode_get_attrib(info,"id");
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1528
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1529 if(checksum && id && !strcmp(id, checksum)) {
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1530 /* we already have that avatar, so we don't have to do anything */
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1531 goodinfo = NULL;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1532 break;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1533 }
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1534 /* We'll only pick the png one for now. It's a very nice image format anyways. */
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1535 if(type && id && !goodinfo && !strcmp(type, "image/png"))
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1536 goodinfo = info;
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1537 }
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1538 }
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1539 if(goodinfo) {
24012
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1540 const char *url = xmlnode_get_attrib(goodinfo, "url");
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1541 const char *id = xmlnode_get_attrib(goodinfo,"id");
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1542
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1543 /* the avatar might either be stored in a pep node, or on a HTTP/HTTPS URL */
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1544 if(!url)
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1545 jabber_pep_request_item(js, from, AVATARNAMESPACEDATA, id, do_buddy_avatar_update_data);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1546 else {
24012
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1547 PurpleUtilFetchUrlData *url_data;
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1548 JabberBuddyAvatarUpdateURLInfo *info = g_new0(JabberBuddyAvatarUpdateURLInfo, 1);
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1549 info->js = js;
24012
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1550
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1551 url_data = purple_util_fetch_url_len(url, TRUE, NULL, TRUE,
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1552 MAX_HTTP_BUDDYICON_BYTES,
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1553 do_buddy_avatar_update_fromurl, info);
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1554 if (url_data) {
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1555 info->from = g_strdup(from);
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1556 info->id = g_strdup(id);
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1557 js->url_datas = g_slist_prepend(js->url_datas, url_data);
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1558 } else
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1559 g_free(info);
913d6f18cb95 Restrict buddy icon downloads from arbitrary urls to 200kB.
Daniel Atallah <datallah@pidgin.im>
parents: 23501
diff changeset
1560
17788
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1561 }
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1562 }
e6e381b0c7d6 Implemented receiving other people's avatars via XEP-0084. Note that this code now includes a workaround for a non-spec incompatibility for the current ejabberd PEP implementation, and doesn't use the correct namespace due to Psi using the wrong one (outdated?). Works fine though, and the vcard-based approach is retained.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
1563 }
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
1564 }
8213
bd1b05f6c02e [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
1565
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1566 static void jabber_buddy_info_resource_free(gpointer data)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1567 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1568 JabberBuddyInfoResource *jbri = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1569 g_free(jbri);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1570 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1571
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1572 static void jabber_version_parse(JabberStream *js, xmlnode *packet, gpointer data)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1573 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1574 JabberBuddyInfo *jbi = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1575 const char *type, *id, *from;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1576 xmlnode *query;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1577 char *resource_name;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1578
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1579 g_return_if_fail(jbi != NULL);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1580
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1581 type = xmlnode_get_attrib(packet, "type");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1582 id = xmlnode_get_attrib(packet, "id");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1583 from = xmlnode_get_attrib(packet, "from");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1584
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1585 jabber_buddy_info_remove_id(jbi, id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1586
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1587 if(!from)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1588 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1589
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1590 resource_name = jabber_get_resource(from);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1591
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1592 if(resource_name) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1593 if(type && !strcmp(type, "result")) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1594 if((query = xmlnode_get_child(packet, "query"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1595 JabberBuddyResource *jbr = jabber_buddy_find_resource(jbi->jb, resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1596 if(jbr) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1597 xmlnode *node;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1598 if((node = xmlnode_get_child(query, "name"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1599 jbr->client.name = xmlnode_get_data(node);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1600 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1601 if((node = xmlnode_get_child(query, "version"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1602 jbr->client.version = xmlnode_get_data(node);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1603 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1604 if((node = xmlnode_get_child(query, "os"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1605 jbr->client.os = xmlnode_get_data(node);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1606 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1607 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1608 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1609 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1610 g_free(resource_name);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1611 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1612
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1613 jabber_buddy_info_show_if_ready(jbi);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1614 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1615
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1616 static void jabber_last_parse(JabberStream *js, xmlnode *packet, gpointer data)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1617 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1618 JabberBuddyInfo *jbi = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1619 xmlnode *query;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1620 char *resource_name;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1621 const char *type, *id, *from, *seconds;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1622
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1623 g_return_if_fail(jbi != NULL);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1624
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1625 type = xmlnode_get_attrib(packet, "type");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1626 id = xmlnode_get_attrib(packet, "id");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1627 from = xmlnode_get_attrib(packet, "from");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1628
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1629 jabber_buddy_info_remove_id(jbi, id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1630
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1631 if(!from)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1632 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1633
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1634 resource_name = jabber_get_resource(from);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1635
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1636 if(resource_name) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1637 if(type && !strcmp(type, "result")) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1638 if((query = xmlnode_get_child(packet, "query"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1639 seconds = xmlnode_get_attrib(query, "seconds");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1640 if(seconds) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1641 char *end = NULL;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1642 long sec = strtol(seconds, &end, 10);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1643 if(end != seconds) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1644 JabberBuddyInfoResource *jbir = g_hash_table_lookup(jbi->resources, resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1645 if(jbir) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1646 jbir->idle_seconds = sec;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1647 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1648 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1649 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1650 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1651 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1652 g_free(resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1653 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1654
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1655 jabber_buddy_info_show_if_ready(jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1656 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1657
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1658 void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js)
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1659 {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1660 if (js->pending_buddy_info_requests)
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1661 {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1662 JabberBuddyInfo *jbi;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1663 GSList *l = js->pending_buddy_info_requests;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1664 while (l) {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1665 jbi = l->data;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1666
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1667 g_slist_free(jbi->ids);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1668 jabber_buddy_info_destroy(jbi);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1669
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
1670 l = l->next;
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1671 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1672
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1673 g_slist_free(js->pending_buddy_info_requests);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1674 js->pending_buddy_info_requests = NULL;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1675 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1676 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1677
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1678 static gboolean jabber_buddy_get_info_timeout(gpointer data)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1679 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1680 JabberBuddyInfo *jbi = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1681
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1682 /* remove the pending callbacks */
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1683 while(jbi->ids) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1684 char *id = jbi->ids->data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1685 jabber_iq_remove_callback_by_id(jbi->js, id);
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1686 jbi->ids = g_slist_remove(jbi->ids, id);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1687 g_free(id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1688 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1689
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1690 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
1691 jbi->timeout_handle = 0;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1692
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1693 jabber_buddy_info_show_if_ready(jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1694
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1695 return FALSE;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1696 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1697
17029
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1698 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
1699 {
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1700 /* 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
1701 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
1702 return FALSE;
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1703
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1704 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
1705 if(!strcmp(jbr->client.name, "Trillian")) {
20350
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1706 /* verified by nwalp 2007/05/09 */
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1707 if(!strcmp(jbr->client.version, "3.1.0.121") ||
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1708 /* verified by nwalp 2007/09/19 */
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1709 !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
1710 return TRUE;
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1711 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1712 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1713 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1714
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1715 return FALSE;
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1716 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1717
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1718 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
1719 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1720 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1721 xmlnode *vcard;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1722 GList *resources;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1723 JabberBuddy *jb;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1724 JabberBuddyInfo *jbi;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1725
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1726 jb = jabber_buddy_find(js, jid, TRUE);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1727
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1728 /* invalid JID */
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1729 if(!jb)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1730 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1731
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1732 jbi = g_new0(JabberBuddyInfo, 1);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1733 jbi->jid = g_strdup(jid);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1734 jbi->js = js;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1735 jbi->jb = jb;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1736 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
1737 jbi->user_info = purple_notify_user_info_new();
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1738
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1739 iq = jabber_iq_new(js, JABBER_IQ_GET);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1740
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1741 xmlnode_set_attrib(iq->node, "to", jid);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1742 vcard = xmlnode_new_child(iq->node, "vCard");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13794
diff changeset
1743 xmlnode_set_namespace(vcard, "vcard-temp");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1744
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1745 jabber_iq_set_callback(iq, jabber_vcard_parse, jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1746 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1747
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1748 jabber_iq_send(iq);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1749
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1750 for(resources = jb->resources; resources; resources = resources->next)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1751 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1752 JabberBuddyResource *jbr = resources->data;
14164
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1753 JabberBuddyInfoResource *jbir;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1754 char *full_jid;
14164
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1755
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1756 if ((strchr(jid, '/') == NULL) && (jbr->name != NULL)) {
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1757 full_jid = g_strdup_printf("%s/%s", jid, jbr->name);
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1758 } else {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1759 full_jid = g_strdup(jid);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1760 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1761
14164
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1762 if (jbr->name != NULL)
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1763 {
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1764 jbir = g_new0(JabberBuddyInfoResource, 1);
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1765 g_hash_table_insert(jbi->resources, g_strdup(jbr->name), jbir);
d85f44e1fec1 [gaim-migrate @ 16732]
Mark Doliner <markdoliner@pidgin.im>
parents: 14155
diff changeset
1766 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1767
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1768 if(!jbr->client.name) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1769 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:version");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1770 xmlnode_set_attrib(iq->node, "to", full_jid);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1771 jabber_iq_set_callback(iq, jabber_version_parse, jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1772 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1773 jabber_iq_send(iq);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1774 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1775
17029
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1776 /* this is to fix the feeling of irritation I get when trying
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1777 * to get info on a friend running Trillian, which doesn't
17051
055a1f1c1d99 comment typo
Nathan Walp <nwalp@pidgin.im>
parents: 17029
diff changeset
1778 * respond (with an error or otherwise) to jabber:iq:last
17029
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1779 * requests. There are a number of Trillian users in my
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1780 * office. */
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1781 if(!_client_is_blacklisted(jbr, "jabber:iq:last")) {
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1782 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:last");
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1783 xmlnode_set_attrib(iq->node, "to", full_jid);
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1784 jabber_iq_set_callback(iq, jabber_last_parse, jbi);
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1785 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1786 jabber_iq_send(iq);
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1787 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1788
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1789 g_free(full_jid);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1790 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1791
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1792 js->pending_buddy_info_requests = g_slist_prepend(js->pending_buddy_info_requests, jbi);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1793 jbi->timeout_handle = purple_timeout_add(30000, jabber_buddy_get_info_timeout, jbi);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1794 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1795
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1796 void jabber_buddy_get_info(PurpleConnection *gc, const char *who)
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1797 {
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1798 JabberStream *js = gc->proto_data;
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1799 char *bare_jid = jabber_get_bare_jid(who);
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1800
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1801 if(bare_jid) {
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1802 jabber_buddy_get_info_for_jid(js, bare_jid);
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1803 g_free(bare_jid);
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1804 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1805 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1806
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1807 static void jabber_buddy_set_invisibility(JabberStream *js, const char *who,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1808 gboolean invisible)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1809 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1810 PurplePresence *gpresence;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1811 PurpleAccount *account;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1812 PurpleStatus *status;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1813 JabberBuddy *jb = jabber_buddy_find(js, who, TRUE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1814 xmlnode *presence;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1815 JabberBuddyState state;
14525
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1816 char *msg;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1817 int priority;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1818
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1819 account = purple_connection_get_account(js->gc);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1820 gpresence = purple_account_get_presence(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1821 status = purple_presence_get_active_status(gpresence);
9944
71ef020ec4b0 [gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents: 9797
diff changeset
1822
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1823 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
1824 presence = jabber_presence_create_js(js, state, msg, priority);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1825
14525
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1826 g_free(msg);
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1827
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1828 xmlnode_set_attrib(presence, "to", who);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1829 if(invisible) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1830 xmlnode_set_attrib(presence, "type", "invisible");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1831 jb->invisible |= JABBER_INVIS_BUDDY;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1832 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1833 jb->invisible &= ~JABBER_INVIS_BUDDY;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1834 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1835
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1836 jabber_send(js, presence);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1837 xmlnode_free(presence);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1838 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1839
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1840 static void jabber_buddy_make_invisible(PurpleBlistNode *node, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1841 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1842 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1843 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1844 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1845
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1846 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1847
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1848 buddy = (PurpleBuddy *) node;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1849 gc = purple_account_get_connection(buddy->account);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1850 js = gc->proto_data;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1851
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1852 jabber_buddy_set_invisibility(js, buddy->name, TRUE);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1853 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1854
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1855 static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1856 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1857 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1858 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1859 JabberStream *js;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1860
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1861 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1862
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1863 buddy = (PurpleBuddy *) node;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1864 gc = purple_account_get_connection(buddy->account);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1865 js = gc->proto_data;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1866
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1867 jabber_buddy_set_invisibility(js, buddy->name, FALSE);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1868 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1869
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1870 static void jabber_buddy_cancel_presence_notification(PurpleBlistNode *node,
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1871 gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1872 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1873 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1874 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1875 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1876
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1877 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1878
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1879 buddy = (PurpleBuddy *) node;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1880 gc = purple_account_get_connection(buddy->account);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1881 js = gc->proto_data;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1882
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1883 /* I wonder if we should prompt the user before doing this */
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1884 jabber_presence_subscription_set(js, buddy->name, "unsubscribed");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1885 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1886
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1887 static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data)
7250
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1888 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1889 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1890 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1891 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1892
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1893 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
7250
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1894
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1895 buddy = (PurpleBuddy *) node;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1896 gc = purple_account_get_connection(buddy->account);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1897 js = gc->proto_data;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1898
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1899 jabber_presence_subscription_set(js, buddy->name, "subscribe");
7250
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1900 }
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1901
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1902
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1903 static void jabber_buddy_unsubscribe(PurpleBlistNode *node, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1904 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1905 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1906 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1907 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1908
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1909 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1910
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1911 buddy = (PurpleBuddy *) node;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1912 gc = purple_account_get_connection(buddy->account);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1913 js = gc->proto_data;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1914
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1915 jabber_presence_subscription_set(js, buddy->name, "unsubscribe");
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1916 }
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1917
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1918 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
1919 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
1920 /* 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
1921 PurpleBuddy *buddy = (PurpleBuddy *) node;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1922 PurpleConnection *gc = purple_account_get_connection(buddy->account);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1923 JabberStream *js = gc->proto_data;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1924 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
1925 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
1926 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
1927 xmlnode *presence;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1928 JabberBuddyState state;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1929 char *msg;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1930 int priority;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1931
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1932 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
1933 presence = jabber_presence_create_js(js, state, msg, priority);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1934
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1935 g_free(msg);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1936
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1937 xmlnode_set_attrib(presence, "to", buddy->name);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1938
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1939 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
1940 xmlnode_free(presence);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1941 }
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1942 }
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1943
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1944 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
1945 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
1946 /* 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
1947 PurpleBuddy *buddy = (PurpleBuddy *) node;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1948 JabberStream *js = purple_account_get_connection(buddy->account)->proto_data;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1949 xmlnode *presence;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1950
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1951 presence = jabber_presence_create_js(js, JABBER_BUDDY_STATE_UNAVAILABLE, NULL, 0);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1952
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1953 xmlnode_set_attrib(presence, "to", buddy->name);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1954
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1955 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
1956 xmlnode_free(presence);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1957 }
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1958 }
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1959
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1960 static GList *jabber_buddy_menu(PurpleBuddy *buddy)
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1961 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1962 PurpleConnection *gc = purple_account_get_connection(buddy->account);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1963 JabberStream *js = gc->proto_data;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1964 JabberBuddy *jb = jabber_buddy_find(js, buddy->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
1965 GList *jbrs;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1966
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1967 GList *m = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1968 PurpleMenuAction *act;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1969
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1970 if(!jb)
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1971 return m;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1972
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1973 /* XXX: fix the NOT ME below */
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1974
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1975 if(js->protocol_version == JABBER_PROTO_0_9 /* && NOT ME */) {
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1976 if(jb->invisible & JABBER_INVIS_BUDDY) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1977 act = purple_menu_action_new(_("Un-hide From"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1978 PURPLE_CALLBACK(jabber_buddy_make_visible),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1979 NULL, NULL);
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1980 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1981 act = purple_menu_action_new(_("Temporarily Hide From"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1982 PURPLE_CALLBACK(jabber_buddy_make_invisible),
13019
71d729443516 [gaim-migrate @ 15372]
Etan Reisner <deryni@pidgin.im>
parents: 12933
diff changeset
1983 NULL, NULL);
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1984 }
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1985 m = g_list_append(m, act);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1986 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1987
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1988 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
1989 act = purple_menu_action_new(_("Cancel Presence Notification"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1990 PURPLE_CALLBACK(jabber_buddy_cancel_presence_notification),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1991 NULL, NULL);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1992 m = g_list_append(m, act);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1993 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1994
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1995 if(!(jb->subscription & JABBER_SUB_TO)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1996 act = purple_menu_action_new(_("(Re-)Request authorization"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1997 PURPLE_CALLBACK(jabber_buddy_rerequest_auth),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1998 NULL, NULL);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1999 m = g_list_append(m, act);
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2000
8185
3a1d79a4e55a [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
2001 } else /* if(NOT ME) */{
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2002
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2003 /* shouldn't this just happen automatically when the buddy is
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2004 removed? */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2005 act = purple_menu_action_new(_("Unsubscribe"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2006 PURPLE_CALLBACK(jabber_buddy_unsubscribe),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
2007 NULL, NULL);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2008 m = g_list_append(m, act);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2009 }
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
2010
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
2011 /*
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
2012 * 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
2013 *
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
2014 * 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
2015 * 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
2016 * 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
2017 * 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
2018 */
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
2019 if (g_utf8_strchr(buddy->name, -1, '@') == NULL) {
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
2020 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
2021 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
2022 NULL, NULL);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
2023 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
2024 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
2025 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
2026 NULL, NULL);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
2027 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
2028 }
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
2029
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
2030 /* 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
2031 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
2032 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
2033 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
2034 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
2035 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
2036 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
2037 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
2038 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
2039 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
2040 }
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
2041 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2042
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2043 return m;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2044 }
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2045
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2046 GList *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2047 jabber_blist_node_menu(PurpleBlistNode *node)
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2048 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2049 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2050 return jabber_buddy_menu((PurpleBuddy *) node);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2051 } else {
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2052 return NULL;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2053 }
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2054 }
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2055
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
2056
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2057 const char *
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2058 jabber_buddy_state_get_name(JabberBuddyState state)
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2059 {
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2060 switch(state) {
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2061 case JABBER_BUDDY_STATE_UNKNOWN:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2062 return _("Unknown");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2063 case JABBER_BUDDY_STATE_ERROR:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2064 return _("Error");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2065 case JABBER_BUDDY_STATE_UNAVAILABLE:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2066 return _("Offline");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2067 case JABBER_BUDDY_STATE_ONLINE:
12467
94948d1eb8cf [gaim-migrate @ 14777]
Richard Laager <rlaager@pidgin.im>
parents: 12323
diff changeset
2068 return _("Available");
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2069 case JABBER_BUDDY_STATE_CHAT:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2070 return _("Chatty");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2071 case JABBER_BUDDY_STATE_AWAY:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2072 return _("Away");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2073 case JABBER_BUDDY_STATE_XA:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2074 return _("Extended Away");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2075 case JABBER_BUDDY_STATE_DND:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2076 return _("Do Not Disturb");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2077 }
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2078
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2079 return _("Unknown");
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2080 }
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2081
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2082 JabberBuddyState jabber_buddy_status_id_get_state(const char *id) {
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2083 if(!id)
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2084 return JABBER_BUDDY_STATE_UNKNOWN;
11540
ad0321374664 [gaim-migrate @ 13795]
Mark Doliner <markdoliner@pidgin.im>
parents: 11533
diff changeset
2085 if(!strcmp(id, "available"))
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2086 return JABBER_BUDDY_STATE_ONLINE;
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2087 if(!strcmp(id, "freeforchat"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2088 return JABBER_BUDDY_STATE_CHAT;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2089 if(!strcmp(id, "away"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2090 return JABBER_BUDDY_STATE_AWAY;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2091 if(!strcmp(id, "extended_away"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2092 return JABBER_BUDDY_STATE_XA;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2093 if(!strcmp(id, "dnd"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2094 return JABBER_BUDDY_STATE_DND;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2095 if(!strcmp(id, "offline"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2096 return JABBER_BUDDY_STATE_UNAVAILABLE;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2097 if(!strcmp(id, "error"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2098 return JABBER_BUDDY_STATE_ERROR;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2099
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2100 return JABBER_BUDDY_STATE_UNKNOWN;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2101 }
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2102
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2103 JabberBuddyState jabber_buddy_show_get_state(const char *id) {
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2104 if(!id)
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2105 return JABBER_BUDDY_STATE_UNKNOWN;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2106 if(!strcmp(id, "available"))
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2107 return JABBER_BUDDY_STATE_ONLINE;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2108 if(!strcmp(id, "chat"))
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2109 return JABBER_BUDDY_STATE_CHAT;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2110 if(!strcmp(id, "away"))
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2111 return JABBER_BUDDY_STATE_AWAY;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2112 if(!strcmp(id, "xa"))
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2113 return JABBER_BUDDY_STATE_XA;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2114 if(!strcmp(id, "dnd"))
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2115 return JABBER_BUDDY_STATE_DND;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2116 if(!strcmp(id, "offline"))
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2117 return JABBER_BUDDY_STATE_UNAVAILABLE;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2118 if(!strcmp(id, "error"))
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2119 return JABBER_BUDDY_STATE_ERROR;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2120
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2121 return JABBER_BUDDY_STATE_UNKNOWN;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2122 }
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2123
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2124 const char *jabber_buddy_state_get_show(JabberBuddyState state) {
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2125 switch(state) {
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2126 case JABBER_BUDDY_STATE_CHAT:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2127 return "chat";
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2128 case JABBER_BUDDY_STATE_AWAY:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2129 return "away";
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2130 case JABBER_BUDDY_STATE_XA:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2131 return "xa";
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2132 case JABBER_BUDDY_STATE_DND:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2133 return "dnd";
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2134 case JABBER_BUDDY_STATE_ONLINE:
11540
ad0321374664 [gaim-migrate @ 13795]
Mark Doliner <markdoliner@pidgin.im>
parents: 11533
diff changeset
2135 return "available";
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2136 case JABBER_BUDDY_STATE_UNKNOWN:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2137 case JABBER_BUDDY_STATE_ERROR:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2138 return NULL;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2139 case JABBER_BUDDY_STATE_UNAVAILABLE:
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2140 return "offline";
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2141 }
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2142 return NULL;
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
2143 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2144
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2145 const char *jabber_buddy_state_get_status_id(JabberBuddyState state) {
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2146 switch(state) {
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2147 case JABBER_BUDDY_STATE_CHAT:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2148 return "freeforchat";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2149 case JABBER_BUDDY_STATE_AWAY:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2150 return "away";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2151 case JABBER_BUDDY_STATE_XA:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2152 return "extended_away";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2153 case JABBER_BUDDY_STATE_DND:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2154 return "dnd";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2155 case JABBER_BUDDY_STATE_ONLINE:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2156 return "available";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2157 case JABBER_BUDDY_STATE_UNKNOWN:
13758
431e33afd630 [gaim-migrate @ 16167]
Sean Egan <seanegan@pidgin.im>
parents: 13715
diff changeset
2158 return "available";
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2159 case JABBER_BUDDY_STATE_ERROR:
13758
431e33afd630 [gaim-migrate @ 16167]
Sean Egan <seanegan@pidgin.im>
parents: 13715
diff changeset
2160 return "error";
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2161 case JABBER_BUDDY_STATE_UNAVAILABLE:
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2162 return "offline";
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2163 }
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2164 return NULL;
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2165 }
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
2166
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2167 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
2168 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2169 /* XXX find out the jid */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2170 purple_blist_request_add_buddy(purple_connection_get_account(gc),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2171 g_list_nth_data(row, 0), NULL, NULL);
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 static void user_search_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2175 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2176 PurpleNotifySearchResults *results;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2177 PurpleNotifySearchColumn *column;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2178 xmlnode *x, *query, *item, *field;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2179
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2180 /* XXX error checking? */
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2181 if(!(query = xmlnode_get_child(packet, "query")))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2182 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2183
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2184 results = purple_notify_searchresults_new();
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2185 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
2186 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
2187 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
2188
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2189 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
2190
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2191 if((reported = xmlnode_get_child(x, "reported"))) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2192 xmlnode *field = xmlnode_get_child(reported, "field");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2193 while(field) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2194 const char *var = xmlnode_get_attrib(field, "var");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2195 const char *label = xmlnode_get_attrib(field, "label");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2196 if(var) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2197 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
2198 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
2199 column_vars = g_slist_append(column_vars, (char *)var);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2200 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2201 field = xmlnode_get_next_twin(field);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2202 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2203 }
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2204
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2205 item = xmlnode_get_child(x, "item");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2206 while(item) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2207 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
2208 GSList *l;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2209 xmlnode *valuenode;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2210 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
2211
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2212 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
2213 /*
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2214 * 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
2215 * 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
2216 */
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2217 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
2218 field != NULL;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2219 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
2220 {
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2221 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
2222 !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
2223 (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
2224 {
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2225 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
2226 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
2227 break;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2228 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2229 }
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2230 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
2231 /* 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
2232 row = g_list_append(row, NULL);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2233 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2234 purple_notify_searchresults_row_add(results, row);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2235 item = xmlnode_get_next_twin(item);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2236 }
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2237
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2238 g_slist_free(column_vars);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2239 } else {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2240 /* old skool */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2241 purple_debug_info("jabber", "old-skool\n");
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2242
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2243 column = purple_notify_searchresults_column_new(_("JID"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2244 purple_notify_searchresults_column_add(results, column);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2245 column = purple_notify_searchresults_column_new(_("First Name"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2246 purple_notify_searchresults_column_add(results, column);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2247 column = purple_notify_searchresults_column_new(_("Last Name"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2248 purple_notify_searchresults_column_add(results, column);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2249 column = purple_notify_searchresults_column_new(_("Nickname"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2250 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
2251 column = purple_notify_searchresults_column_new(_("Email"));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2252 purple_notify_searchresults_column_add(results, column);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2253
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2254 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
2255 const char *jid;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2256 xmlnode *node;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2257 GList *row = NULL;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2258
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2259 if(!(jid = xmlnode_get_attrib(item, "jid")))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2260 continue;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2261
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2262 row = g_list_append(row, g_strdup(jid));
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2263 node = xmlnode_get_child(item, "first");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2264 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2265 node = xmlnode_get_child(item, "last");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2266 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2267 node = xmlnode_get_child(item, "nick");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2268 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2269 node = xmlnode_get_child(item, "email");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2270 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
2271 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
2272 purple_notify_searchresults_row_add(results, row);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2273 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2274 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2275
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2276 purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD,
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2277 user_search_result_add_buddy_cb);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2278
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2279 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
2280 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2281
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2282 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
2283 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2284 xmlnode *query;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2285 JabberIq *iq;
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2286 char *dir_server = data;
21388
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2287 const char *type;
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2288
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2289 /* 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
2290 * 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
2291 * a cancel, so skip it */
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2292 type = xmlnode_get_attrib(result, "type");
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2293 if(type && !strcmp(type, "cancel")) {
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2294 g_free(dir_server);
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2295 return;
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2296 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2297
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2298 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
2299 query = xmlnode_get_child(iq->node, "query");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2300
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2301 xmlnode_insert_child(query, result);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2302
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2303 jabber_iq_set_callback(iq, user_search_result_cb, NULL);
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2304 xmlnode_set_attrib(iq->node, "to", dir_server);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2305 jabber_iq_send(iq);
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2306 g_free(dir_server);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2307 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2308
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2309 struct user_search_info {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2310 JabberStream *js;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2311 char *directory_server;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2312 };
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2313
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2314 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
2315 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2316 g_free(usi->directory_server);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2317 g_free(usi);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2318 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2319
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2320 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
2321 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2322 JabberStream *js = usi->js;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2323 JabberIq *iq;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2324 xmlnode *query;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2325 GList *groups, *flds;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2326
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2327 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
2328 query = xmlnode_get_child(iq->node, "query");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2329
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2330 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
2331 for(flds = purple_request_field_group_get_fields(groups->data);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2332 flds; flds = flds->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2333 PurpleRequestField *field = flds->data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2334 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
2335 const char *value = purple_request_field_string_get_value(field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2336
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2337 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
2338 xmlnode *y = xmlnode_new_child(query, id);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2339 xmlnode_insert_data(y, value, -1);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2340 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2341 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2342 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2343
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2344 jabber_iq_set_callback(iq, user_search_result_cb, NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2345 xmlnode_set_attrib(iq->node, "to", usi->directory_server);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2346 jabber_iq_send(iq);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2347
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2348 g_free(usi->directory_server);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2349 g_free(usi);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2350 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2351
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2352 #if 0
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2353 /* 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
2354
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2355 /*
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2356 * 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
2357 * comments for Jabber User Directories
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2358 *
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2359 * 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
2360 * 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
2361 */
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2362 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
2363 /* 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
2364 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
2365 "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
2366 NULL
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2367 };
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2368 #endif
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2369
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2370 static void user_search_fields_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2371 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2372 xmlnode *query, *x;
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2373 const char *from, *type;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2374
12284
2cb693d740d5 [gaim-migrate @ 14588]
Etan Reisner <deryni@pidgin.im>
parents: 11675
diff changeset
2375 if(!(from = xmlnode_get_attrib(packet, "from")))
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2376 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2377
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2378 if(!(type = xmlnode_get_attrib(packet, "type")) || !strcmp(type, "error")) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20350
diff changeset
2379 char *msg = jabber_parse_error(js, packet, NULL);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2380
13634
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2381 if(!msg)
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2382 msg = g_strdup(_("Unknown error"));
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2383
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2384 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
2385 _("Could not query the directory server."), msg);
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2386 g_free(msg);
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2387
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2388 return;
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2389 }
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2390
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2391
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2392 if(!(query = xmlnode_get_child(packet, "query")))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2393 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2394
13330
33fb51d94dfd [gaim-migrate @ 15699]
Nathan Walp <nwalp@pidgin.im>
parents: 13019
diff changeset
2395 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
2396 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
2397 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2398 } else {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2399 struct user_search_info *usi;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2400 xmlnode *instnode;
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2401 char *instructions = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2402 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2403 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2404 PurpleRequestField *field;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2405
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2406 /* old skool */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2407 fields = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2408 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2409 purple_request_fields_add_group(fields, group);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2410
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2411 if((instnode = xmlnode_get_child(query, "instructions")))
13574
433001d94e3e [gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents: 13572
diff changeset
2412 {
433001d94e3e [gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents: 13572
diff changeset
2413 char *tmp = xmlnode_get_data(instnode);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2414
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2415 if(tmp)
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2416 {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2417 /* 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
2418 list in jabber_user_dir_comments[]) */
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2419 instructions = g_strdup_printf(_("Server Instructions: %s"), _(tmp));
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2420 g_free(tmp);
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2421 }
13574
433001d94e3e [gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents: 13572
diff changeset
2422 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2423
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2424 if(!instructions)
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2425 {
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2426 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
2427 "for any matching XMPP users."));
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2428 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2429
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2430 if(xmlnode_get_child(query, "first")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2431 field = purple_request_field_string_new("first", _("First Name"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2432 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2433 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2434 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2435 if(xmlnode_get_child(query, "last")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2436 field = purple_request_field_string_new("last", _("Last Name"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2437 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2438 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2439 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2440 if(xmlnode_get_child(query, "nick")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2441 field = purple_request_field_string_new("nick", _("Nickname"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2442 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2443 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2444 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2445 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
2446 field = purple_request_field_string_new("email", _("Email Address"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2447 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2448 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2449 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2450
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2451 usi = g_new0(struct user_search_info, 1);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2452 usi->js = js;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2453 usi->directory_server = g_strdup(from);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2454
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2455 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
2456 _("Search for XMPP users"), instructions, fields,
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2457 _("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
2458 _("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
2459 purple_connection_get_account(js->gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2460 usi);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2461
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2462 g_free(instructions);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2463 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2464 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2465
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
2466 void jabber_user_search(JabberStream *js, const char *directory)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2467 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2468 JabberIq *iq;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2469
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2470 /* XXX: should probably better validate the directory we're given */
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2471 if(!directory || !*directory) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2472 purple_notify_error(js->gc, _("Invalid Directory"), _("Invalid Directory"), NULL);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2473 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2474 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2475
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2476 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
2477 xmlnode_set_attrib(iq->node, "to", directory);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2478
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2479 jabber_iq_set_callback(iq, user_search_fields_result_cb, NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2480
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2481 jabber_iq_send(iq);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2482 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2483
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2484 void jabber_user_search_begin(PurplePluginAction *action)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2485 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2486 PurpleConnection *gc = (PurpleConnection *) action->context;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2487 JabberStream *js = gc->proto_data;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2488
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2489 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
2490 _("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
2491 js->user_directories ? js->user_directories->data : NULL,
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2492 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
2493 _("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
2494 _("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
2495 NULL, NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2496 js);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2497 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2498
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2499
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2500

mercurial