annotate src/protocols/jabber/buddy.c @ 13051:7d8da9d4da49

[gaim-migrate @ 15412] Authentication Failure should wants_to_die, yes? committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Fri, 27 Jan 2006 15:21:49 +0000
parents 8504ce176d38
children 1d569233f257
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
2 * gaim - Jabber Protocol Plugin
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
67c4e9d39242 [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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
10684
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10662
diff changeset
22 #include "cipher.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "debug.h"
7076
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
24 #include "imgstore.h"
9713
db62420a53a2 [gaim-migrate @ 10574]
Mark Doliner <mark@kingant.net>
parents: 9466
diff changeset
25 #include "prpl.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26 #include "notify.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "request.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "util.h"
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
29 #include "xmlnode.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 #include "buddy.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "chat.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 #include "jabber.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 #include "iq.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 #include "presence.h"
11675
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
36 #include "xdata.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37
7116
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
38 void jabber_buddy_free(JabberBuddy *jb)
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
39 {
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
40 g_return_if_fail(jb != NULL);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
41
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
42 if(jb->error_msg)
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
43 g_free(jb->error_msg);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
44 while(jb->resources)
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
45 jabber_buddy_resource_free(jb->resources->data);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
46
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
47 g_free(jb);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
48 }
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
49
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50 JabberBuddy *jabber_buddy_find(JabberStream *js, const char *name,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
51 gboolean create)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
53 JabberBuddy *jb;
7445
6ea4a49b4b51 [gaim-migrate @ 8052]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
54 const char *realname;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55
7445
6ea4a49b4b51 [gaim-migrate @ 8052]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
56 if(!(realname = jabber_normalize(js->gc->account, name)))
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 return NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
58
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
59 jb = g_hash_table_lookup(js->buddies, realname);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
60
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
61 if(!jb && create) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 jb = g_new0(JabberBuddy, 1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63 g_hash_table_insert(js->buddies, g_strdup(realname), jb);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
64 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 return jb;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70 JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71 const char *resource)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73 JabberBuddyResource *jbr = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74 GList *l;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76 if(!jb)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77 return NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
78
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
79 for(l = jb->resources; l; l = l->next)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
80 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
81 if(!jbr && !resource) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
82 jbr = l->data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
83 } else if(!resource) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
84 if(((JabberBuddyResource *)l->data)->priority >= jbr->priority)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
85 jbr = l->data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
86 } else if(((JabberBuddyResource *)l->data)->name) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
87 if(!strcmp(((JabberBuddyResource *)l->data)->name, resource)) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
88 jbr = l->data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
89 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
91 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94 return jbr;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
97 JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource,
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
98 int priority, JabberBuddyState state, const char *status)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102 if(!jbr) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 jbr = g_new0(JabberBuddyResource, 1);
7116
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
104 jbr->jb = jb;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 jbr->name = g_strdup(resource);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 jbr->capabilities = JABBER_CAP_XHTML;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107 jb->resources = g_list_append(jb->resources, jbr);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 jbr->priority = priority;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 jbr->state = state;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111 if(jbr->status)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112 g_free(jbr->status);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
113 jbr->status = g_strdup(status);
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
114
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
115 return jbr;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
117
7116
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
118 void jabber_buddy_resource_free(JabberBuddyResource *jbr)
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
119 {
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
120 g_return_if_fail(jbr != NULL);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
121
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
122 jbr->jb->resources = g_list_remove(jbr->jb->resources, jbr);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
123
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
124 g_free(jbr->name);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
125 if(jbr->status)
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
126 g_free(jbr->status);
8400
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
127 if(jbr->thread_id)
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
128 g_free(jbr->thread_id);
7116
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
129 g_free(jbr);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
130 }
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
131
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132 void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
133 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
134 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
135
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
136 if(!jbr)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
137 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
138
7116
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
139 jabber_buddy_resource_free(jbr);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
141
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
142 const char *jabber_buddy_get_status_msg(JabberBuddy *jb)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144 JabberBuddyResource *jbr;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
145
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
146 if(!jb)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
147 return NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149 jbr = jabber_buddy_find_resource(jb, NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
151 if(!jbr)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
152 return NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
153
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154 return jbr->status;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
156
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157 /*******
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
158 * This is the old vCard stuff taken from the old prpl. vCards, by definition
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
159 * are a temporary thing until jabber can get its act together and come up
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160 * with a format for user information, hence the namespace of 'vcard-temp'
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
161 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162 * Since I don't feel like putting that much work into something that's
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 * _supposed_ to go away, i'm going to just copy the kludgy old code here,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164 * and make it purdy when jabber comes up with a standards-track JEP to
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165 * replace vcard-temp
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166 * --Nathan
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
167 *******/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169 /*---------------------------------------*/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
170 /* Jabber "set info" (vCard) support */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
171 /*---------------------------------------*/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
172
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 * V-Card format:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176 * <vCard prodid='' version='' xmlns=''>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177 * <FN></FN>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178 * <N>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179 * <FAMILY/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180 * <GIVEN/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
181 * </N>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
182 * <NICKNAME/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
183 * <URL/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
184 * <ADR>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
185 * <STREET/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
186 * <EXTADD/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
187 * <LOCALITY/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
188 * <REGION/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
189 * <PCODE/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
190 * <COUNTRY/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
191 * </ADR>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
192 * <TEL/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
193 * <EMAIL/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
194 * <ORG>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195 * <ORGNAME/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
196 * <ORGUNIT/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
197 * </ORG>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198 * <TITLE/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
199 * <ROLE/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
200 * <DESC/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
201 * <BDAY/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202 * </vCard>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
203 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204 * See also:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
205 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206 * http://docs.jabber.org/proto/html/vcard-temp.html
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207 * http://www.vcard-xml.org/dtd/vCard-XML-v2-20010520.dtd
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211 * Cross-reference user-friendly V-Card entry labels to vCard XML tags
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212 * and attributes.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
213 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214 * Order is (or should be) unimportant. For example: we have no way of
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
215 * knowing in what order real data will arrive.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
216 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
217 * Format: Label, Pre-set text, "visible" flag, "editable" flag, XML tag
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
218 * name, XML tag's parent tag "path" (relative to vCard node).
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
219 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
220 * List is terminated by a NULL label pointer.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
221 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
222 * Entries with no label text, but with XML tag and parent tag
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
223 * entries, are used by V-Card XML construction routines to
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224 * "automagically" construct the appropriate XML node tree.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
225 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
226 * Thoughts on future direction/expansion
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
228 * This is a "simple" vCard.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
229 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230 * It is possible for nodes other than the "vCard" node to have
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231 * attributes. Should that prove necessary/desirable, add an
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
232 * "attributes" pointer to the vcard_template struct, create the
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
233 * necessary tag_attr structs, and add 'em to the vcard_dflt_data
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
234 * array.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
235 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
236 * The above changes will (obviously) require changes to the vCard
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237 * construction routines.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240 struct vcard_template {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241 char *label; /* label text pointer */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 char *text; /* entry text pointer */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243 int visible; /* should entry field be "visible?" */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244 int editable; /* should entry field be editable? */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
245 char *tag; /* tag text */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 char *ptag; /* parent tag "path" text */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247 char *url; /* vCard display format if URL */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248 } vcard_template_data[] = {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249 {N_("Full Name"), NULL, TRUE, TRUE, "FN", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250 {N_("Family Name"), NULL, TRUE, TRUE, "FAMILY", "N", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251 {N_("Given Name"), NULL, TRUE, TRUE, "GIVEN", "N", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
252 {N_("Nickname"), NULL, TRUE, TRUE, "NICKNAME", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253 {N_("URL"), NULL, TRUE, TRUE, "URL", NULL, "<A HREF=\"%s\">%s</A>"},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
254 {N_("Street Address"), NULL, TRUE, TRUE, "STREET", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
255 {N_("Extended Address"), NULL, TRUE, TRUE, "EXTADD", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
256 {N_("Locality"), NULL, TRUE, TRUE, "LOCALITY", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
257 {N_("Region"), NULL, TRUE, TRUE, "REGION", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
258 {N_("Postal Code"), NULL, TRUE, TRUE, "PCODE", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
259 {N_("Country"), NULL, TRUE, TRUE, "COUNTRY", "ADR", NULL},
11361
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
260 {N_("Telephone"), NULL, TRUE, TRUE, "NUMBER", "TEL", NULL},
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
261 {N_("Email"), NULL, TRUE, TRUE, "USERID", "EMAIL", "<A HREF=\"mailto:%s\">%s</A>"},
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
262 {N_("Organization Name"), NULL, TRUE, TRUE, "ORGNAME", "ORG", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
263 {N_("Organization Unit"), NULL, TRUE, TRUE, "ORGUNIT", "ORG", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264 {N_("Title"), NULL, TRUE, TRUE, "TITLE", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
265 {N_("Role"), NULL, TRUE, TRUE, "ROLE", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
266 {N_("Birthday"), NULL, TRUE, TRUE, "BDAY", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
267 {N_("Description"), NULL, TRUE, TRUE, "DESC", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
268 {"", NULL, TRUE, TRUE, "N", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269 {"", NULL, TRUE, TRUE, "ADR", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270 {"", NULL, TRUE, TRUE, "ORG", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
271 {NULL, NULL, 0, 0, NULL, NULL, NULL}
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
272 };
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
273
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274 /*
8735
92cbf9713795 [gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents: 8401
diff changeset
275 * The "vCard" tag's attribute list...
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 struct tag_attr {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 char *attr;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279 char *value;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280 } vcard_tag_attr_list[] = {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 {"prodid", "-//HandGen//NONSGML vGen v1.0//EN"},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282 {"version", "2.0", },
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283 {"xmlns", "vcard-temp", },
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 {NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 };
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
287
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
288 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289 * Insert a tag node into an xmlnode tree, recursively inserting parent tag
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290 * nodes as necessary
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
291 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
292 * Returns pointer to inserted node
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
293 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
294 * Note to hackers: this code is designed to be re-entrant (it's recursive--it
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
295 * calls itself), so don't put any "static"s in here!
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
296 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
297 static xmlnode *insert_tag_to_parent_tag(xmlnode *start, const char *parent_tag, const char *new_tag)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
298 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
299 xmlnode *x = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
300
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
301 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
302 * If the parent tag wasn't specified, see if we can get it
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
303 * from the vCard template struct.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
304 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
305 if(parent_tag == NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
306 struct vcard_template *vc_tp = vcard_template_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
307
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
308 while(vc_tp->label != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
309 if(strcmp(vc_tp->tag, new_tag) == 0) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
310 parent_tag = vc_tp->ptag;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
311 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
312 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
313 ++vc_tp;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
314 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
315 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
316
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
317 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
318 * If we have a parent tag...
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
319 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
320 if(parent_tag != NULL ) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
321 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
322 * Try to get the parent node for a tag
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
323 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
324 if((x = xmlnode_get_child(start, parent_tag)) == NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
325 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
326 * Descend?
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
327 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
328 char *grand_parent = g_strdup(parent_tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329 char *parent;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
330
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
331 if((parent = strrchr(grand_parent, '/')) != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
332 *(parent++) = '\0';
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
333 x = insert_tag_to_parent_tag(start, grand_parent, parent);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
334 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
335 x = xmlnode_new_child(start, grand_parent);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
337 g_free(grand_parent);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
338 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
339 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
340 * We found *something* to be the parent node.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
341 * Note: may be the "root" node!
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
342 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
343 xmlnode *y;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
344 if((y = xmlnode_get_child(x, new_tag)) != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
345 return(y);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
346 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
347 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
348 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
349
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
350 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
351 * insert the new tag into its parent node
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
352 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
353 return(xmlnode_new_child((x == NULL? start : x), new_tag));
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
354 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
355
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
356 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
357 * Send vCard info to Jabber server
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
358 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
359 void jabber_set_info(GaimConnection *gc, const char *info)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
360 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
361 JabberIq *iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
362 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
363 xmlnode *vc_node;
11303
10066662176a [gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents: 11183
diff changeset
364 char *avatar_file = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
365
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
366 if(js->avatar_hash)
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
367 g_free(js->avatar_hash);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
368 js->avatar_hash = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
369
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
370 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
371 * Send only if there's actually any *information* to send
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
372 */
11388
ce2a2e793835 [gaim-migrate @ 13616]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
373 vc_node = info ? xmlnode_from_str(info, -1) : NULL;
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11303
diff changeset
374 avatar_file = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(gc->account));
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
375
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
376 if(!vc_node && avatar_file) {
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
377 vc_node = xmlnode_new("vCard");
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
378 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
379
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
380 if(vc_node) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
381 if (vc_node->name &&
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
382 !g_ascii_strncasecmp(vc_node->name, "vCard", 5)) {
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
383 GError *error = NULL;
11509
fca94aa83486 [gaim-migrate @ 13754]
Tim Ringenbach <marv@pidgin.im>
parents: 11388
diff changeset
384 gchar *avatar_data_tmp;
fca94aa83486 [gaim-migrate @ 13754]
Tim Ringenbach <marv@pidgin.im>
parents: 11388
diff changeset
385 guchar *avatar_data;
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
386 gsize avatar_len;
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
387
11509
fca94aa83486 [gaim-migrate @ 13754]
Tim Ringenbach <marv@pidgin.im>
parents: 11388
diff changeset
388 if(avatar_file && g_file_get_contents(avatar_file, &avatar_data_tmp, &avatar_len, &error)) {
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
389 xmlnode *photo, *binval;
11127
719779387f96 [gaim-migrate @ 13183]
Mark Doliner <mark@kingant.net>
parents: 10941
diff changeset
390 gchar *enc;
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
391 int i;
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
392 unsigned char hashval[20];
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
393 char *p, hash[41];
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
394
11521
d41aabad3b7a [gaim-migrate @ 13769]
Mark Doliner <mark@kingant.net>
parents: 11509
diff changeset
395 avatar_data = (guchar *) avatar_data_tmp;
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
396 photo = xmlnode_new_child(vc_node, "PHOTO");
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
397 binval = xmlnode_new_child(photo, "BINVAL");
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
398 enc = gaim_base64_encode(avatar_data, avatar_len);
10684
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10662
diff changeset
399
11183
8dca96cbcd64 [gaim-migrate @ 13295]
Mark Doliner <mark@kingant.net>
parents: 11137
diff changeset
400 gaim_cipher_digest_region("sha1", (guchar *)avatar_data,
10687
b256ce6b85b8 [gaim-migrate @ 12235]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10684
diff changeset
401 avatar_len, sizeof(hashval),
b256ce6b85b8 [gaim-migrate @ 12235]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10684
diff changeset
402 hashval, NULL);
10684
72a5babfa8b4 [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10662
diff changeset
403
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
404 p = hash;
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
405 for(i=0; i<20; i++, p+=2)
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
406 snprintf(p, 3, "%02x", hashval[i]);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
407 js->avatar_hash = g_strdup(hash);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
408
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
409 xmlnode_insert_data(binval, enc, -1);
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
410 g_free(enc);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
411 g_free(avatar_data);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10490
diff changeset
412 } else if (error != NULL) {
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
413 g_error_free(error);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
414 }
11303
10066662176a [gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents: 11183
diff changeset
415 g_free(avatar_file);
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
416
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
417 iq = jabber_iq_new(js, JABBER_IQ_SET);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
418 xmlnode_insert_child(iq->node, vc_node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
419 jabber_iq_send(iq);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
420 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
421 xmlnode_free(vc_node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
422 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
423 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
424 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
425
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
426 void jabber_set_buddy_icon(GaimConnection *gc, const char *iconfile)
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
427 {
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
428 GaimPresence *gpresence;
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
429 GaimStatus *status;
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
430
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
431 jabber_set_info(gc, gaim_account_get_user_info(gc->account));
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
432
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
433 gpresence = gaim_account_get_presence(gc->account);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
434 status = gaim_presence_get_active_status(gpresence);
10216
09876d57c520 [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10215
diff changeset
435 jabber_presence_send(gc->account, status);
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
436 }
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
437
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
438 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
439 * This is the callback from the "ok clicked" for "set vCard"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
440 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
441 * Formats GSList data into XML-encoded string and returns a pointer
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
442 * to said string.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
443 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
444 * g_free()'ing the returned string space is the responsibility of
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
445 * the caller.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
446 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
447 static void
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
448 jabber_format_info(GaimConnection *gc, GaimRequestFields *fields)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
449 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
450 GaimAccount *account;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
451 xmlnode *vc_node;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
452 GaimRequestField *field;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
453 const char *text;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
454 char *p;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
455 const struct vcard_template *vc_tp;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
456 struct tag_attr *tag_attr;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
457
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
458 vc_node = xmlnode_new("vCard");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
459
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
460 for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
461 xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
462
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
463 for (vc_tp = vcard_template_data; vc_tp->label != NULL; vc_tp++) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
464 if (*vc_tp->label == '\0')
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
465 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
466
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
467 field = gaim_request_fields_get_field(fields, vc_tp->tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
468 text = gaim_request_field_string_get_value(field);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
469
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
470
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
471 if (text != NULL && *text != '\0') {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
472 xmlnode *xp;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
473
9339
4d1ba3243f7a [gaim-migrate @ 10147]
Nathan Walp <nwalp@pidgin.im>
parents: 9285
diff changeset
474 gaim_debug(GAIM_DEBUG_INFO, "jabber",
4d1ba3243f7a [gaim-migrate @ 10147]
Nathan Walp <nwalp@pidgin.im>
parents: 9285
diff changeset
475 "Setting %s to '%s'\n", vc_tp->tag, text);
4d1ba3243f7a [gaim-migrate @ 10147]
Nathan Walp <nwalp@pidgin.im>
parents: 9285
diff changeset
476
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
477 if ((xp = insert_tag_to_parent_tag(vc_node,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
478 NULL, vc_tp->tag)) != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
479
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
480 xmlnode_insert_data(xp, text, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
481 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
482 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
483 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
484
7642
9008b5be4275 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7445
diff changeset
485 p = xmlnode_to_str(vc_node, NULL);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
486 xmlnode_free(vc_node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
487
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
488 account = gaim_connection_get_account(gc);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
489
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
490 if (account != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
491 gaim_account_set_user_info(account, p);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
492
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
493 if (gc != NULL)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
494 serv_set_info(gc, p);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
495 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
496
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
497 g_free(p);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
498 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
499
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
500 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
501 * This gets executed by the proto action
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
502 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
503 * Creates a new GaimRequestFields struct, gets the XML-formatted user_info
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
504 * string (if any) into GSLists for the (multi-entry) edit dialog and
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
505 * calls the set_vcard dialog.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
506 */
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
507 void jabber_setup_set_info(GaimPluginAction *action)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
508 {
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
509 GaimConnection *gc = (GaimConnection *) action->context;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
510 GaimRequestFields *fields;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
511 GaimRequestFieldGroup *group;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
512 GaimRequestField *field;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
513 const struct vcard_template *vc_tp;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
514 char *user_info;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
515 char *cdata;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
516 xmlnode *x_vc_data = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
517
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
518 fields = gaim_request_fields_new();
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
519 group = gaim_request_field_group_new(NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
520 gaim_request_fields_add_group(fields, group);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
521
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
522 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
523 * Get existing, XML-formatted, user info
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
524 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
525 if((user_info = g_strdup(gaim_account_get_user_info(gc->account))) != NULL)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
526 x_vc_data = xmlnode_from_str(user_info, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
527 else
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
528 user_info = g_strdup("");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
529
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
530 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
531 * Set up GSLists for edit with labels from "template," data from user info
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
532 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
533 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
534 xmlnode *data_node;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
535 if((vc_tp->label)[0] == '\0')
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
536 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
537 if(vc_tp->ptag == NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
538 data_node = xmlnode_get_child(x_vc_data, vc_tp->tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
539 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
540 gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
541 data_node = xmlnode_get_child(x_vc_data, tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
542 g_free(tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
543 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
544 if(data_node)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
545 cdata = xmlnode_get_data(data_node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
546 else
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
547 cdata = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
548
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
549 if(strcmp(vc_tp->tag, "DESC") == 0) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
550 field = gaim_request_field_string_new(vc_tp->tag,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
551 _(vc_tp->label), cdata,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
552 TRUE);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
553 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
554 field = gaim_request_field_string_new(vc_tp->tag,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
555 _(vc_tp->label), cdata,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
556 FALSE);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
557 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
558
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
559 gaim_request_field_group_add_field(group, field);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
560 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
561
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
562 if(x_vc_data != NULL)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
563 xmlnode_free(x_vc_data);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
564
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
565 g_free(user_info);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
566
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
567 gaim_request_fields(gc, _("Edit Jabber vCard"),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
568 _("Edit Jabber vCard"),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
569 _("All items below are optional. Enter only the "
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
570 "information with which you feel comfortable."),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
571 fields,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
572 _("Save"), G_CALLBACK(jabber_format_info),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
573 _("Cancel"), NULL,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
574 gc);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
575 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
576
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
577 /*---------------------------------------*/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
578 /* End Jabber "set info" (vCard) support */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
579 /*---------------------------------------*/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
580
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
581 /******
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
582 * end of that ancient crap that needs to die
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
583 ******/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
584
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
585
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
586 static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
587 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
588 GList *resources;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
589 const char *from = xmlnode_get_attrib(packet, "from");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
590 JabberBuddy *jb;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
591 JabberBuddyResource *jbr;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
592 GString *info_text;
7306
7c12dab8e513 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
593 char *resource_name;
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7757
diff changeset
594 char *bare_jid;
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
595 char *text;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
596 xmlnode *vcard;
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7757
diff changeset
597 GaimBuddy *b;
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
598 GSList *imgids = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
599
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
600 if(!from)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
601 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
602
11361
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
603 if(!(jb = jabber_buddy_find(js, from, TRUE)))
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
604 return;
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
605
10490
a3a540ed2518 [gaim-migrate @ 11780]
Nathan Walp <nwalp@pidgin.im>
parents: 10442
diff changeset
606 /* XXX: handle the error case */
a3a540ed2518 [gaim-migrate @ 11780]
Nathan Walp <nwalp@pidgin.im>
parents: 10442
diff changeset
607
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
608 resource_name = jabber_get_resource(from);
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7757
diff changeset
609 bare_jid = jabber_get_bare_jid(from);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7757
diff changeset
610
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7757
diff changeset
611 b = gaim_find_buddy(js->gc->account, bare_jid);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
612
11361
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
613
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
614 info_text = g_string_new("");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
615
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
616 if(resource_name) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
617 jbr = jabber_buddy_find_resource(jb, resource_name);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
618 if(jbr) {
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
619 char *purdy = NULL;
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
620 if(jbr->status)
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
621 purdy = gaim_strdup_withhtml(jbr->status);
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
622 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/>",
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
623 _("Status"), jabber_buddy_state_get_name(jbr->state),
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
624 purdy ? ": " : "",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
625 purdy ? purdy : "");
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
626 if(purdy)
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
627 g_free(purdy);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
628 } else {
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
629 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
630 _("Status"), _("Unknown"));
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
631 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
632 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
633 for(resources = jb->resources; resources; resources = resources->next) {
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
634 char *purdy = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
635 jbr = resources->data;
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
636 if(jbr->status)
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
637 purdy = gaim_strdup_withhtml(jbr->status);
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
638 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
639 _("Resource"), jbr->name);
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
640 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/><br/>",
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
641 _("Status"), jabber_buddy_state_get_name(jbr->state),
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
642 purdy ? ": " : "",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
643 purdy ? purdy : "");
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
644 if(purdy)
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
645 g_free(purdy);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
646 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
647 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
648
7306
7c12dab8e513 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
649 g_free(resource_name);
7c12dab8e513 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
650
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
651 if((vcard = xmlnode_get_child(packet, "vCard")) ||
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
652 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
653 xmlnode *child;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
654 for(child = vcard->child; child; child = child->next)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
655 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
656 xmlnode *child2;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
657
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
658 if(child->type != XMLNODE_TYPE_TAG)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
659 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
660
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
661 text = xmlnode_get_data(child);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
662 if(text && !strcmp(child->name, "FN")) {
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
663 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
664 _("Full Name"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
665 } else if(!strcmp(child->name, "N")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
666 for(child2 = child->child; child2; child2 = child2->next)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
667 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
668 char *text2;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
669
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
670 if(child2->type != XMLNODE_TYPE_TAG)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
671 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
672
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
673 text2 = xmlnode_get_data(child2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
674 if(text2 && !strcmp(child2->name, "FAMILY")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
675 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
676 "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
677 _("Family Name"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
678 } else if(text2 && !strcmp(child2->name, "GIVEN")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
679 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
680 "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
681 _("Given Name"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
682 } else if(text2 && !strcmp(child2->name, "MIDDLE")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
683 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
684 "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
685 _("Middle Name"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
686 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
687 g_free(text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
688 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
689 } else if(text && !strcmp(child->name, "NICKNAME")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
690 serv_got_alias(js->gc, from, text);
7955
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7757
diff changeset
691 if(b) {
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7757
diff changeset
692 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", text);
119a22025818 [gaim-migrate @ 8630]
Nathan Walp <nwalp@pidgin.im>
parents: 7757
diff changeset
693 }
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
694 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
695 _("Nickname"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
696 } else if(text && !strcmp(child->name, "BDAY")) {
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
697 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
698 _("Birthday"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
699 } else if(!strcmp(child->name, "ADR")) {
12933
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
700 gboolean address_line_added = FALSE;
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
701
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
702 for(child2 = child->child; child2; child2 = child2->next)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
703 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
704 char *text2;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
705
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
706 if(child2->type != XMLNODE_TYPE_TAG)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
707 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
708
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
709 text2 = xmlnode_get_data(child2);
12933
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
710 if (text2 == NULL)
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
711 continue;
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
712
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
713 /* We do this here so that it's not added if all the child
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
714 * elements are empty. */
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
715 if (!address_line_added)
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
716 {
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
717 g_string_append_printf(info_text, "<b>%s:</b><br/>",
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
718 _("Address"));
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
719 address_line_added = TRUE;
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
720 }
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
721
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
722 if(!strcmp(child2->name, "POBOX")) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
723 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
724 "&nbsp;<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
725 _("P.O. Box"), text2);
12933
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
726 } else if(!strcmp(child2->name, "EXTADR")) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
727 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
728 "&nbsp;<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
729 _("Extended Address"), text2);
12933
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
730 } else if(!strcmp(child2->name, "STREET")) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
731 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
732 "&nbsp;<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
733 _("Street Address"), text2);
12933
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
734 } else if(!strcmp(child2->name, "LOCALITY")) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
735 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
736 "&nbsp;<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
737 _("Locality"), text2);
12933
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
738 } else if(!strcmp(child2->name, "REGION")) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
739 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
740 "&nbsp;<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
741 _("Region"), text2);
12933
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
742 } else if(!strcmp(child2->name, "PCODE")) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
743 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
744 "&nbsp;<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
745 _("Postal Code"), text2);
12933
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
746 } else if(!strcmp(child2->name, "CTRY")
75ac13ab161f [gaim-migrate @ 15286]
Richard Laager <rlaager@wiktel.com>
parents: 12919
diff changeset
747 || !strcmp(child2->name, "COUNTRY")) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
748 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
749 "&nbsp;<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
750 _("Country"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
751 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
752 g_free(text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
753 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
754 } else if(!strcmp(child->name, "TEL")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
755 char *number;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
756 if((child2 = xmlnode_get_child(child, "NUMBER"))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
757 /* show what kind of number it is */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
758 number = xmlnode_get_data(child2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
759 if(number) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
760 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
761 "<b>%s:</b> %s<br/>", _("Telephone"), number);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
762 g_free(number);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
763 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
764 } else if((number = xmlnode_get_data(child))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
765 /* lots of clients (including gaim) do this, but it's
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
766 * out of spec */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
767 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
768 "<b>%s:</b> %s<br/>", _("Telephone"), number);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
769 g_free(number);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
770 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
771 } else if(!strcmp(child->name, "EMAIL")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
772 char *userid;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
773 if((child2 = xmlnode_get_child(child, "USERID"))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
774 /* show what kind of email it is */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
775 userid = xmlnode_get_data(child2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
776 if(userid) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
777 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
778 "<b>%s:</b> <a href='mailto:%s'>%s</a><br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
779 _("Email"), userid, userid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
780 g_free(userid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
781 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
782 } else if((userid = xmlnode_get_data(child))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
783 /* lots of clients (including gaim) do this, but it's
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
784 * out of spec */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
785 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
786 "<b>%s:</b> <a href='mailto:%s'>%s</a><br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
787 _("Email"), userid, userid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
788 g_free(userid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
789 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
790 } else if(!strcmp(child->name, "ORG")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
791 for(child2 = child->child; child2; child2 = child2->next)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
792 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
793 char *text2;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
794
8135
8f4ce853e685 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
795 if(child2->type != XMLNODE_TYPE_TAG)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
796 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
797
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
798 text2 = xmlnode_get_data(child2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
799 if(text2 && !strcmp(child2->name, "ORGNAME")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
800 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
801 "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
802 _("Organization Name"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
803 } else if(text2 && !strcmp(child2->name, "ORGUNIT")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
804 g_string_append_printf(info_text,
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
805 "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
806 _("Organization Unit"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
807 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
808 g_free(text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
809 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
810 } else if(text && !strcmp(child->name, "TITLE")) {
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
811 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
812 _("Title"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
813 } else if(text && !strcmp(child->name, "ROLE")) {
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
814 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
815 _("Role"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
816 } else if(text && !strcmp(child->name, "DESC")) {
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
817 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
818 _("Description"), text);
7076
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
819 } else if(!strcmp(child->name, "PHOTO") ||
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
820 !strcmp(child->name, "LOGO")) {
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
821 char *bintext = NULL;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
822 xmlnode *binval;
11361
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
823
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
824 if( ((binval = xmlnode_get_child(child, "BINVAL")) &&
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
825 (bintext = xmlnode_get_data(binval))) ||
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
826 (bintext = xmlnode_get_data(child))) {
11127
719779387f96 [gaim-migrate @ 13183]
Mark Doliner <mark@kingant.net>
parents: 10941
diff changeset
827 gsize size;
11137
096020ae09a9 [gaim-migrate @ 13201]
Mark Doliner <mark@kingant.net>
parents: 11127
diff changeset
828 guchar *data;
11127
719779387f96 [gaim-migrate @ 13183]
Mark Doliner <mark@kingant.net>
parents: 10941
diff changeset
829 int i;
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
830 unsigned char hashval[20];
11127
719779387f96 [gaim-migrate @ 13183]
Mark Doliner <mark@kingant.net>
parents: 10941
diff changeset
831 char *p, hash[41];
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
832 gboolean photo = (strcmp(child->name, "PHOTO") == 0);
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
833
11361
e4868370c433 [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
834 data = gaim_base64_decode(bintext, &size);
7076
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
835
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
836 imgids = g_slist_prepend(imgids, GINT_TO_POINTER(gaim_imgstore_add(data, size, "logo.png")));
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
837 g_string_append_printf(info_text,
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
838 "<b>%s:</b> <img id='%d'><br/>",
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
839 photo ? _("Photo") : _("Logo"),
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
840 GPOINTER_TO_INT(imgids->data));
7076
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
841
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
842 gaim_buddy_icons_set_for_user(js->gc->account, bare_jid,
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
843 data, size);
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
844
11183
8dca96cbcd64 [gaim-migrate @ 13295]
Mark Doliner <mark@kingant.net>
parents: 11137
diff changeset
845 gaim_cipher_digest_region("sha1", (guchar *)data, size,
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
846 sizeof(hashval), hashval, NULL);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
847 p = hash;
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
848 for(i=0; i<20; i++, p+=2)
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
849 snprintf(p, 3, "%02x", hashval[i]);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
850 gaim_blist_node_set_string((GaimBlistNode*)b, "avatar_hash", hash);
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
851
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
852 g_free(data);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
853 g_free(bintext);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
854 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
855 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
856 g_free(text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
857 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
858 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
859
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
860 text = gaim_strdup_withhtml(info_text->str);
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
861
11533
c9b815aeddc1 [gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents: 11532
diff changeset
862 gaim_notify_userinfo(js->gc, from, text, NULL, NULL);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
863
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
864 while(imgids) {
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
865 gaim_imgstore_unref(GPOINTER_TO_INT(imgids->data));
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
866 imgids = g_slist_delete_link(imgids, imgids);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
867 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
868 g_string_free(info_text, TRUE);
8213
8d41a4250bb7 [gaim-migrate @ 8936]
Nathan Walp <nwalp@pidgin.im>
parents: 8185
diff changeset
869 g_free(text);
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
870 g_free(bare_jid);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
871 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
872
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
873 static void jabber_buddy_get_info_for_jid(JabberStream *js, const char *full_jid)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
874 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
875 JabberIq *iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
876 xmlnode *vcard;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
877
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
878 iq = jabber_iq_new(js, JABBER_IQ_GET);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
879
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
880 xmlnode_set_attrib(iq->node, "to", full_jid);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
881 vcard = xmlnode_new_child(iq->node, "vCard");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
882 xmlnode_set_attrib(vcard, "xmlns", "vcard-temp");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
883
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
884 jabber_iq_set_callback(iq, jabber_vcard_parse, NULL);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
885
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
886 jabber_iq_send(iq);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
887 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
888
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
889 void jabber_buddy_get_info(GaimConnection *gc, const char *who)
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
890 {
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
891 JabberStream *js = gc->proto_data;
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
892 char *bare_jid = jabber_get_bare_jid(who);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
893
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
894 if(bare_jid) {
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
895 jabber_buddy_get_info_for_jid(js, bare_jid);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
896 g_free(bare_jid);
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
897 }
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
898 }
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
899
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
900 void jabber_buddy_get_info_chat(GaimConnection *gc, int id,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
901 const char *resource)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
902 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
903 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
904 JabberChat *chat = jabber_chat_find_by_id(js, id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
905 char *full_jid;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
906
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
907 if(!chat)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
908 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
909
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
910 full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, resource);
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
911 jabber_buddy_get_info_for_jid(js, full_jid);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
912 g_free(full_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
913 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
914
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
915
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
916 static void jabber_buddy_set_invisibility(JabberStream *js, const char *who,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
917 gboolean invisible)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
918 {
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9797
diff changeset
919 GaimPresence *gpresence;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9797
diff changeset
920 GaimAccount *account;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9797
diff changeset
921 GaimStatus *status;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
922 JabberBuddy *jb = jabber_buddy_find(js, who, TRUE);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
923 xmlnode *presence;
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
924 JabberBuddyState state;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
925 const char *msg;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
926 int priority;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
927
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9797
diff changeset
928 account = gaim_connection_get_account(js->gc);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9797
diff changeset
929 gpresence = gaim_account_get_presence(account);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9797
diff changeset
930 status = gaim_presence_get_active_status(gpresence);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9797
diff changeset
931
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
932 gaim_status_to_jabber(status, &state, &msg, &priority);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
933 presence = jabber_presence_create(state, msg, priority);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
934
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
935 xmlnode_set_attrib(presence, "to", who);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
936 if(invisible) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
937 xmlnode_set_attrib(presence, "type", "invisible");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
938 jb->invisible |= JABBER_INVIS_BUDDY;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
939 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
940 jb->invisible &= ~JABBER_INVIS_BUDDY;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
941 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
942
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
943 jabber_send(js, presence);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
944 xmlnode_free(presence);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
945 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
946
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
947 static void jabber_buddy_make_invisible(GaimBlistNode *node, gpointer data)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
948 {
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
949 GaimBuddy *buddy;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
950 GaimConnection *gc;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
951 JabberStream *js;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
952
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
953 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
954
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
955 buddy = (GaimBuddy *) node;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
956 gc = gaim_account_get_connection(buddy->account);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
957 js = gc->proto_data;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
958
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
959 jabber_buddy_set_invisibility(js, buddy->name, TRUE);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
960 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
961
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
962 static void jabber_buddy_make_visible(GaimBlistNode *node, gpointer data)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
963 {
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
964 GaimBuddy *buddy;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
965 GaimConnection *gc;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
966 JabberStream *js;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
967
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
968 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
969
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
970 buddy = (GaimBuddy *) node;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
971 gc = gaim_account_get_connection(buddy->account);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
972 js = gc->proto_data;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
973
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
974 jabber_buddy_set_invisibility(js, buddy->name, FALSE);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
975 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
976
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
977 static void jabber_buddy_cancel_presence_notification(GaimBlistNode *node,
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
978 gpointer data)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
979 {
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
980 GaimBuddy *buddy;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
981 GaimConnection *gc;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
982 JabberStream *js;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
983
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
984 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
985
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
986 buddy = (GaimBuddy *) node;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
987 gc = gaim_account_get_connection(buddy->account);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
988 js = gc->proto_data;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
989
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
990 /* I wonder if we should prompt the user before doing this */
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
991 jabber_presence_subscription_set(js, buddy->name, "unsubscribed");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
992 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
993
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
994 static void jabber_buddy_rerequest_auth(GaimBlistNode *node, gpointer data)
7250
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
995 {
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
996 GaimBuddy *buddy;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
997 GaimConnection *gc;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
998 JabberStream *js;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
999
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1000 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
7250
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1001
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1002 buddy = (GaimBuddy *) node;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1003 gc = gaim_account_get_connection(buddy->account);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1004 js = gc->proto_data;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1005
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1006 jabber_presence_subscription_set(js, buddy->name, "subscribe");
7250
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1007 }
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1008
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1009
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1010 static void jabber_buddy_unsubscribe(GaimBlistNode *node, gpointer data)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1011 {
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1012 GaimBuddy *buddy;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1013 GaimConnection *gc;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1014 JabberStream *js;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1015
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1016 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1017
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1018 buddy = (GaimBuddy *) node;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1019 gc = gaim_account_get_connection(buddy->account);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1020 js = gc->proto_data;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1021
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1022 jabber_presence_subscription_set(js, buddy->name, "unsubscribe");
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1023 }
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1024
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1025
12323
fc464a0abccc [gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents: 12284
diff changeset
1026 static GList *jabber_buddy_menu(GaimBuddy *buddy)
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1027 {
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1028 GaimConnection *gc = gaim_account_get_connection(buddy->account);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1029 JabberStream *js = gc->proto_data;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1030 JabberBuddy *jb = jabber_buddy_find(js, buddy->name, TRUE);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1031
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1032 GList *m = NULL;
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1033 GaimMenuAction *act;
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1034
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1035 if(!jb)
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1036 return m;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1037
8185
3a229ad2fab0 [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1038 /* XXX: fix the NOT ME below */
3a229ad2fab0 [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1039
3a229ad2fab0 [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1040 if(js->protocol_version == JABBER_PROTO_0_9 /* && NOT ME */) {
8166
ac7bf273bd66 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1041 if(jb->invisible & JABBER_INVIS_BUDDY) {
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1042 act = gaim_menu_action_new(_("Un-hide From"),
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1043 GAIM_CALLBACK(jabber_buddy_make_visible),
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1044 NULL, NULL);
8166
ac7bf273bd66 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1045 } else {
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1046 act = gaim_menu_action_new(_("Temporarily Hide From"),
13019
8504ce176d38 [gaim-migrate @ 15372]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12933
diff changeset
1047 GAIM_CALLBACK(jabber_buddy_make_invisible),
8504ce176d38 [gaim-migrate @ 15372]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12933
diff changeset
1048 NULL, NULL);
8166
ac7bf273bd66 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1049 }
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1050 m = g_list_append(m, act);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1051 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1052
8185
3a229ad2fab0 [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1053 if(jb->subscription & JABBER_SUB_FROM /* && NOT ME */) {
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1054 act = gaim_menu_action_new(_("Cancel Presence Notification"),
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1055 GAIM_CALLBACK(jabber_buddy_cancel_presence_notification),
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1056 NULL, NULL);
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1057 m = g_list_append(m, act);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1058 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1059
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1060 if(!(jb->subscription & JABBER_SUB_TO)) {
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1061 act = gaim_menu_action_new(_("(Re-)Request authorization"),
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1062 GAIM_CALLBACK(jabber_buddy_rerequest_auth),
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1063 NULL, NULL);
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1064 m = g_list_append(m, act);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1065
8185
3a229ad2fab0 [gaim-migrate @ 8906]
Nathan Walp <nwalp@pidgin.im>
parents: 8166
diff changeset
1066 } else /* if(NOT ME) */{
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1067
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1068 /* shouldn't this just happen automatically when the buddy is
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1069 removed? */
12919
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1070 act = gaim_menu_action_new(_("Unsubscribe"),
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1071 GAIM_CALLBACK(jabber_buddy_unsubscribe),
248b8b39c671 [gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12683
diff changeset
1072 NULL, NULL);
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1073 m = g_list_append(m, act);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1074 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1075
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1076 return m;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1077 }
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1078
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1079 GList *
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1080 jabber_blist_node_menu(GaimBlistNode *node)
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1081 {
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1082 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1083 return jabber_buddy_menu((GaimBuddy *) node);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1084 } else {
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1085 return NULL;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1086 }
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1087 }
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1088
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1089
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1090 const char *
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1091 jabber_buddy_state_get_name(JabberBuddyState state)
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1092 {
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1093 switch(state) {
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1094 case JABBER_BUDDY_STATE_UNKNOWN:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1095 return _("Unknown");
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1096 case JABBER_BUDDY_STATE_ERROR:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1097 return _("Error");
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1098 case JABBER_BUDDY_STATE_UNAVAILABLE:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1099 return _("Offline");
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1100 case JABBER_BUDDY_STATE_ONLINE:
12467
1b57012eec7b [gaim-migrate @ 14777]
Richard Laager <rlaager@wiktel.com>
parents: 12323
diff changeset
1101 return _("Available");
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1102 case JABBER_BUDDY_STATE_CHAT:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1103 return _("Chatty");
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1104 case JABBER_BUDDY_STATE_AWAY:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1105 return _("Away");
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1106 case JABBER_BUDDY_STATE_XA:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1107 return _("Extended Away");
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1108 case JABBER_BUDDY_STATE_DND:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1109 return _("Do Not Disturb");
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1110 }
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1111
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1112 return _("Unknown");
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1113 }
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1114
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1115 JabberBuddyState jabber_buddy_status_id_get_state(const char *id) {
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1116 if(!id)
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1117 return JABBER_BUDDY_STATE_UNKNOWN;
11540
9ddda2a86f50 [gaim-migrate @ 13795]
Mark Doliner <mark@kingant.net>
parents: 11533
diff changeset
1118 if(!strcmp(id, "available"))
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1119 return JABBER_BUDDY_STATE_ONLINE;
12683
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1120 if(!strcmp(id, "freeforchat"))
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1121 return JABBER_BUDDY_STATE_CHAT;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1122 if(!strcmp(id, "away"))
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1123 return JABBER_BUDDY_STATE_AWAY;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1124 if(!strcmp(id, "extended_away"))
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1125 return JABBER_BUDDY_STATE_XA;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1126 if(!strcmp(id, "dnd"))
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1127 return JABBER_BUDDY_STATE_DND;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1128 if(!strcmp(id, "offline"))
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1129 return JABBER_BUDDY_STATE_UNAVAILABLE;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1130 if(!strcmp(id, "error"))
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1131 return JABBER_BUDDY_STATE_ERROR;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1132
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1133 return JABBER_BUDDY_STATE_UNKNOWN;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1134 }
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1135
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1136 JabberBuddyState jabber_buddy_show_get_state(const char *id) {
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1137 if(!id)
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1138 return JABBER_BUDDY_STATE_UNKNOWN;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1139 if(!strcmp(id, "available"))
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1140 return JABBER_BUDDY_STATE_ONLINE;
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1141 if(!strcmp(id, "chat"))
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1142 return JABBER_BUDDY_STATE_CHAT;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1143 if(!strcmp(id, "away"))
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1144 return JABBER_BUDDY_STATE_AWAY;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1145 if(!strcmp(id, "xa"))
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1146 return JABBER_BUDDY_STATE_XA;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1147 if(!strcmp(id, "dnd"))
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1148 return JABBER_BUDDY_STATE_DND;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1149 if(!strcmp(id, "offline"))
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1150 return JABBER_BUDDY_STATE_UNAVAILABLE;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1151 if(!strcmp(id, "error"))
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1152 return JABBER_BUDDY_STATE_ERROR;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1153
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1154 return JABBER_BUDDY_STATE_UNKNOWN;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1155 }
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1156
12683
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1157 const char *jabber_buddy_state_get_show(JabberBuddyState state) {
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1158 switch(state) {
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1159 case JABBER_BUDDY_STATE_CHAT:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1160 return "chat";
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1161 case JABBER_BUDDY_STATE_AWAY:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1162 return "away";
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1163 case JABBER_BUDDY_STATE_XA:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1164 return "xa";
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1165 case JABBER_BUDDY_STATE_DND:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1166 return "dnd";
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1167 case JABBER_BUDDY_STATE_ONLINE:
11540
9ddda2a86f50 [gaim-migrate @ 13795]
Mark Doliner <mark@kingant.net>
parents: 11533
diff changeset
1168 return "available";
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1169 case JABBER_BUDDY_STATE_UNKNOWN:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1170 case JABBER_BUDDY_STATE_ERROR:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1171 return NULL;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1172 case JABBER_BUDDY_STATE_UNAVAILABLE:
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1173 return "offline";
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1174 }
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1175 return NULL;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1176 }
11675
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1177
12683
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1178 const char *jabber_buddy_state_get_status_id(JabberBuddyState state) {
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1179 switch(state) {
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1180 case JABBER_BUDDY_STATE_CHAT:
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1181 return "freeforchat";
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1182 case JABBER_BUDDY_STATE_AWAY:
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1183 return "away";
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1184 case JABBER_BUDDY_STATE_XA:
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1185 return "extended_away";
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1186 case JABBER_BUDDY_STATE_DND:
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1187 return "dnd";
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1188 case JABBER_BUDDY_STATE_ONLINE:
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1189 return "available";
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1190 case JABBER_BUDDY_STATE_UNKNOWN:
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1191 case JABBER_BUDDY_STATE_ERROR:
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1192 return NULL;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1193 case JABBER_BUDDY_STATE_UNAVAILABLE:
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1194 return "offline";
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1195 }
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1196 return NULL;
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1197 }
41cf9be29754 [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1198
11675
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1199 static void user_search_result_add_buddy_cb(GaimConnection *gc, GList *row)
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1200 {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1201 /* XXX find out the jid */
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1202 gaim_blist_request_add_buddy(gaim_connection_get_account(gc),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1203 g_list_nth_data(row, 0), NULL, NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1204 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1205
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1206 static void user_search_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1207 {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1208 GaimNotifySearchResults *results;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1209 GaimNotifySearchColumn *column;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1210 xmlnode *x, *query, *item, *field;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1211
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1212 /* XXX error checking? */
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1213 if(!(query = xmlnode_get_child(packet, "query")))
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1214 return;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1215
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1216 results = gaim_notify_searchresults_new();
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1217 if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1218 xmlnode *reported;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1219 gaim_debug_info("jabber", "new-skool\n");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1220 if((reported = xmlnode_get_child(x, "reported"))) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1221 xmlnode *field = xmlnode_get_child(reported, "field");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1222 while(field) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1223 /* XXX keep track of this order, use it below */
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1224 const char *var = xmlnode_get_attrib(field, "var");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1225 const char *label = xmlnode_get_attrib(field, "label");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1226 if(var) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1227 column = gaim_notify_searchresults_column_new(label ? label : var);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1228 gaim_notify_searchresults_column_add(results, column);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1229 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1230 field = xmlnode_get_next_twin(field);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1231 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1232 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1233 item = xmlnode_get_child(x, "item");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1234 while(item) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1235 GList *row = NULL;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1236 field = xmlnode_get_child(item, "field");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1237 while(field) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1238 xmlnode *valuenode = xmlnode_get_child(item, "value");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1239 if(valuenode) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1240 char *value = xmlnode_get_data(valuenode);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1241 row = g_list_append(row, value);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1242 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1243 field = xmlnode_get_next_twin(field);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1244 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1245 gaim_notify_searchresults_row_add(results, row);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1246
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1247 item = xmlnode_get_next_twin(item);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1248 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1249 } else {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1250 /* old skool */
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1251 gaim_debug_info("jabber", "old-skool\n");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1252
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1253 column = gaim_notify_searchresults_column_new("JID");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1254 gaim_notify_searchresults_column_add(results, column);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1255 column = gaim_notify_searchresults_column_new("First");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1256 gaim_notify_searchresults_column_add(results, column);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1257 column = gaim_notify_searchresults_column_new("Last");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1258 gaim_notify_searchresults_column_add(results, column);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1259 column = gaim_notify_searchresults_column_new("Nickname");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1260 gaim_notify_searchresults_column_add(results, column);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1261 column = gaim_notify_searchresults_column_new("E-Mail");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1262 gaim_notify_searchresults_column_add(results, column);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1263
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1264 for(item = xmlnode_get_child(query, "item"); item; item = xmlnode_get_next_twin(item)) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1265 const char *jid;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1266 xmlnode *node;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1267 GList *row = NULL;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1268
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1269 if(!(jid = xmlnode_get_attrib(item, "jid")))
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1270 continue;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1271
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1272 row = g_list_append(row, g_strdup(jid));
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1273 node = xmlnode_get_child(item, "first");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1274 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1275 node = xmlnode_get_child(item, "last");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1276 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1277 node = xmlnode_get_child(item, "nick");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1278 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1279 node = xmlnode_get_child(item, "email");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1280 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1281 gaim_debug_info("jabber", "row=%d\n", row);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1282 gaim_notify_searchresults_row_add(results, row);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1283 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1284 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1285
12624
851b0bd7eb52 [gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents: 12467
diff changeset
1286 gaim_notify_searchresults_button_add(results, GAIM_NOTIFY_BUTTON_ADD,
11675
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1287 user_search_result_add_buddy_cb);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1288
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1289 gaim_notify_searchresults(js->gc, NULL, NULL, _("The following are the results of your search"), results, NULL, NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1290 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1291
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1292 static void user_search_x_data_cb(JabberStream *js, xmlnode *result, gpointer data)
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1293 {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1294 xmlnode *query;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1295 JabberIq *iq;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1296
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1297 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1298 query = xmlnode_get_child(iq->node, "query");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1299
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1300 xmlnode_insert_child(query, result);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1301
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1302 jabber_iq_set_callback(iq, user_search_result_cb, NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1303 jabber_iq_send(iq);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1304 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1305
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1306 struct user_search_info {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1307 JabberStream *js;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1308 char *directory_server;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1309 };
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1310
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1311 static void user_search_cancel_cb(struct user_search_info *usi, GaimRequestFields *fields)
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1312 {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1313 g_free(usi->directory_server);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1314 g_free(usi);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1315 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1316
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1317 static void user_search_cb(struct user_search_info *usi, GaimRequestFields *fields)
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1318 {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1319 JabberStream *js = usi->js;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1320 JabberIq *iq;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1321 xmlnode *query;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1322 GList *groups, *flds;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1323
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1324 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1325 query = xmlnode_get_child(iq->node, "query");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1326
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1327 for(groups = gaim_request_fields_get_groups(fields); groups; groups = groups->next) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1328 for(flds = gaim_request_field_group_get_fields(groups->data);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1329 flds; flds = flds->next) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1330 GaimRequestField *field = flds->data;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1331 const char *id = gaim_request_field_get_id(field);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1332 const char *value = gaim_request_field_string_get_value(field);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1333
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1334 if(value && (!strcmp(id, "first") || !strcmp(id, "last") || !strcmp(id, "nick") || !strcmp(id, "email"))) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1335 xmlnode *y = xmlnode_new_child(query, id);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1336 xmlnode_insert_data(y, value, -1);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1337 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1338 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1339 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1340
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1341 jabber_iq_set_callback(iq, user_search_result_cb, NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1342 xmlnode_set_attrib(iq->node, "to", usi->directory_server);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1343 jabber_iq_send(iq);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1344
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1345 g_free(usi->directory_server);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1346 g_free(usi);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1347 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1348
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1349 static void user_search_fields_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1350 {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1351 xmlnode *query, *x;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1352 const char *from;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1353
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1354 /* i forget, do i have to check for error? XXX */
12284
ecd471d1eeec [gaim-migrate @ 14588]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11675
diff changeset
1355 if(!(from = xmlnode_get_attrib(packet, "from")))
11675
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1356 return;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1357
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1358
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1359 if(!(query = xmlnode_get_child(packet, "query")))
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1360 return;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1361
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1362 if((x = xmlnode_get_child_with_namespace(packet, "x", "jabber:x:data"))) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1363 jabber_x_data_request(js, x, user_search_x_data_cb, NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1364 return;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1365 } else {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1366 struct user_search_info *usi;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1367 xmlnode *instnode;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1368 char *instructions;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1369 GaimRequestFields *fields;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1370 GaimRequestFieldGroup *group;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1371 GaimRequestField *field;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1372
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1373 /* old skool */
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1374 fields = gaim_request_fields_new();
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1375 group = gaim_request_field_group_new(NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1376 gaim_request_fields_add_group(fields, group);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1377
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1378 if((instnode = xmlnode_get_child(query, "instructions")))
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1379 instructions = xmlnode_get_data(instnode);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1380 else
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1381 instructions = g_strdup(_("Fill in one or more fields to search "
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1382 "for any matching Jabber users."));
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1383
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1384 if(xmlnode_get_child(query, "first")) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1385 field = gaim_request_field_string_new("first", _("First Name"),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1386 NULL, FALSE);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1387 gaim_request_field_group_add_field(group, field);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1388 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1389 if(xmlnode_get_child(query, "last")) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1390 field = gaim_request_field_string_new("last", _("Last Name"),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1391 NULL, FALSE);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1392 gaim_request_field_group_add_field(group, field);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1393 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1394 if(xmlnode_get_child(query, "nick")) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1395 field = gaim_request_field_string_new("nick", _("Nickname"),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1396 NULL, FALSE);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1397 gaim_request_field_group_add_field(group, field);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1398 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1399 if(xmlnode_get_child(query, "email")) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1400 field = gaim_request_field_string_new("email", _("E-Mail Address"),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1401 NULL, FALSE);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1402 gaim_request_field_group_add_field(group, field);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1403 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1404
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1405 usi = g_new0(struct user_search_info, 1);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1406 usi->js = js;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1407 usi->directory_server = g_strdup(from);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1408
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1409 gaim_request_fields(js->gc, _("Search for Jabber users"),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1410 _("Search for Jabber users"), instructions, fields,
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1411 _("Search"), G_CALLBACK(user_search_cb),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1412 _("Cancel"), G_CALLBACK(user_search_cancel_cb), usi);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1413
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1414 g_free(instructions);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1415 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1416 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1417
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1418 static void jabber_user_search_ok(JabberStream *js, const char *directory)
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1419 {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1420 JabberIq *iq;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1421
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1422 /* XXX: should probably better validate the directory we're given */
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1423 if(!directory || !*directory) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1424 gaim_notify_error(js->gc, _("Invalid Directory"), _("Invalid Directory"), NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1425 return;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1426 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1427
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1428 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:search");
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1429 xmlnode_set_attrib(iq->node, "to", directory);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1430
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1431 jabber_iq_set_callback(iq, user_search_fields_result_cb, NULL);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1432
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1433 jabber_iq_send(iq);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1434 }
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1435
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1436 void jabber_user_search_begin(GaimPluginAction *action)
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1437 {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1438 GaimConnection *gc = (GaimConnection *) action->context;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1439 JabberStream *js = gc->proto_data;
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1440
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1441 gaim_request_input(gc, _("Enter a User Directory"), _("Enter a User Directory"),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1442 _("Select a user directory to search"),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1443 js->user_directories ? js->user_directories->data : "users.jabber.org",
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1444 FALSE, FALSE, NULL,
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1445 _("Search Directory"), GAIM_CALLBACK(jabber_user_search_ok),
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1446 _("Cancel"), NULL, js);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1447 }