annotate src/protocols/jabber/buddy.c @ 7514:43a214a385d1

[gaim-migrate @ 8127] this is what I accomplished on the ride to atlanta. pathetic, eh? committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sat, 15 Nov 2003 07:09:20 +0000
parents 6ea4a49b4b51
children 9008b5be4275
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"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 #include "debug.h"
7076
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
23 #include "imgstore.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 #include "multi.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25 #include "notify.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
26 #include "request.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "util.h"
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
28 #include "xmlnode.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "buddy.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 #include "chat.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "jabber.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 #include "iq.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 #include "presence.h"
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
35 #include "si.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97 void jabber_buddy_track_resource(JabberBuddy *jb, const char *resource,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 int priority, int state, const char *status)
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);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
114 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115
7116
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
116 void jabber_buddy_resource_free(JabberBuddyResource *jbr)
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
117 {
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
118 g_return_if_fail(jbr != NULL);
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 jbr->jb->resources = g_list_remove(jbr->jb->resources, jbr);
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 g_free(jbr->name);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
123 if(jbr->status)
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
124 g_free(jbr->status);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
125 g_free(jbr);
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
126 }
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
127
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
128 void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
129 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
130 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
131
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132 if(!jbr)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
133 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
134
7116
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
135 jabber_buddy_resource_free(jbr);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
136 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
137
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
138 const char *jabber_buddy_get_status_msg(JabberBuddy *jb)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
139 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
140 JabberBuddyResource *jbr;
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 if(!jb)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
143 return NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
144
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
145 jbr = jabber_buddy_find_resource(jb, NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
146
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
147 if(!jbr)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148 return NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150 return jbr->status;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
151 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
152
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 * 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
155 * 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
156 * with a format for user information, hence the namespace of 'vcard-temp'
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 * 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
159 * _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
160 * 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
161 * replace vcard-temp
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
162 * --Nathan
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
163 *******/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
164
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
165 /*---------------------------------------*/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
166 /* Jabber "set info" (vCard) support */
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 * V-Card format:
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 * <vCard prodid='' version='' xmlns=''>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
173 * <FN></FN>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
174 * <N>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
175 * <FAMILY/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
176 * <GIVEN/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
177 * </N>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
178 * <NICKNAME/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
179 * <URL/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
180 * <ADR>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
181 * <STREET/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
182 * <EXTADD/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
183 * <LOCALITY/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
184 * <REGION/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
185 * <PCODE/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
186 * <COUNTRY/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
187 * </ADR>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
188 * <TEL/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
189 * <EMAIL/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
190 * <ORG>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
191 * <ORGNAME/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
192 * <ORGUNIT/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
193 * </ORG>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
194 * <TITLE/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195 * <ROLE/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
196 * <DESC/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
197 * <BDAY/>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198 * </vCard>
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
199 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
200 * See also:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
201 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202 * http://docs.jabber.org/proto/html/vcard-temp.html
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
203 * http://www.vcard-xml.org/dtd/vCard-XML-v2-20010520.dtd
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
204 */
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 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207 * Cross-reference user-friendly V-Card entry labels to vCard XML tags
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 * and attributes.
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 * 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
211 * knowing in what order real data will arrive.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
212 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
213 * Format: Label, Pre-set text, "visible" flag, "editable" flag, XML tag
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214 * name, XML tag's parent tag "path" (relative to vCard node).
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
215 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
216 * List is terminated by a NULL label pointer.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
217 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
218 * Entries with no label text, but with XML tag and parent tag
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
219 * entries, are used by V-Card XML construction routines to
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
220 * "automagically" construct the appropriate XML node tree.
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 * Thoughts on future direction/expansion
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
223 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224 * This is a "simple" vCard.
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 * It is possible for nodes other than the "vCard" node to have
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227 * attributes. Should that prove necessary/desirable, add an
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
228 * "attributes" pointer to the vcard_template struct, create the
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
229 * necessary tag_attr structs, and add 'em to the vcard_dflt_data
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230 * array.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
232 * The above changes will (obviously) require changes to the vCard
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
233 * construction routines.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
234 */
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 struct vcard_template {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237 char *label; /* label text pointer */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 char *text; /* entry text pointer */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239 int visible; /* should entry field be "visible?" */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240 int editable; /* should entry field be editable? */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241 char *tag; /* tag text */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 char *ptag; /* parent tag "path" text */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243 char *url; /* vCard display format if URL */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244 } vcard_template_data[] = {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
245 {N_("Full Name"), NULL, TRUE, TRUE, "FN", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 {N_("Family Name"), NULL, TRUE, TRUE, "FAMILY", "N", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247 {N_("Given Name"), NULL, TRUE, TRUE, "GIVEN", "N", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248 {N_("Nickname"), NULL, TRUE, TRUE, "NICKNAME", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249 {N_("URL"), NULL, TRUE, TRUE, "URL", NULL, "<A HREF=\"%s\">%s</A>"},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250 {N_("Street Address"), NULL, TRUE, TRUE, "STREET", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251 {N_("Extended Address"), NULL, TRUE, TRUE, "EXTADD", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
252 {N_("Locality"), NULL, TRUE, TRUE, "LOCALITY", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253 {N_("Region"), NULL, TRUE, TRUE, "REGION", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
254 {N_("Postal Code"), NULL, TRUE, TRUE, "PCODE", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
255 {N_("Country"), NULL, TRUE, TRUE, "COUNTRY", "ADR", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
256 {N_("Telephone"), NULL, TRUE, TRUE, "TELEPHONE", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
257 {N_("Email"), NULL, TRUE, TRUE, "EMAIL", NULL, "<A HREF=\"mailto:%s\">%s</A>"},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
258 {N_("Organization Name"), NULL, TRUE, TRUE, "ORGNAME", "ORG", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
259 {N_("Organization Unit"), NULL, TRUE, TRUE, "ORGUNIT", "ORG", NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
260 {N_("Title"), NULL, TRUE, TRUE, "TITLE", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
261 {N_("Role"), NULL, TRUE, TRUE, "ROLE", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
262 {N_("Birthday"), NULL, TRUE, TRUE, "BDAY", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
263 {N_("Description"), NULL, TRUE, TRUE, "DESC", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264 {"", NULL, TRUE, TRUE, "N", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
265 {"", NULL, TRUE, TRUE, "ADR", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
266 {"", NULL, TRUE, TRUE, "ORG", NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
267 {NULL, NULL, 0, 0, NULL, NULL, NULL}
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
268 };
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
271 * The "vCard" tag's attibute list...
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 struct tag_attr {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274 char *attr;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 char *value;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276 } vcard_tag_attr_list[] = {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 {"prodid", "-//HandGen//NONSGML vGen v1.0//EN"},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 {"version", "2.0", },
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279 {"xmlns", "vcard-temp", },
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280 {NULL, NULL},
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 };
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 * Insert a tag node into an xmlnode tree, recursively inserting parent tag
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286 * nodes as necessary
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 * Returns pointer to inserted node
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290 * 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
291 * calls itself), so don't put any "static"s in here!
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
292 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
293 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
294 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
295 xmlnode *x = NULL;
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 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
298 * 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
299 * from the vCard template struct.
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 if(parent_tag == NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
302 struct vcard_template *vc_tp = vcard_template_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
303
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
304 while(vc_tp->label != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
305 if(strcmp(vc_tp->tag, new_tag) == 0) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
306 parent_tag = vc_tp->ptag;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
307 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
308 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
309 ++vc_tp;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
310 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
311 }
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 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
314 * If we have a parent tag...
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 if(parent_tag != NULL ) {
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 * Try to get the parent node for a 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((x = xmlnode_get_child(start, 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 * Descend?
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 char *grand_parent = g_strdup(parent_tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
325 char *parent;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
326
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
327 if((parent = strrchr(grand_parent, '/')) != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
328 *(parent++) = '\0';
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329 x = insert_tag_to_parent_tag(start, grand_parent, parent);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
330 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
331 x = xmlnode_new_child(start, grand_parent);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
332 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
333 g_free(grand_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 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336 * We found *something* to be the parent node.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
337 * Note: may be the "root" node!
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
338 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
339 xmlnode *y;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
340 if((y = xmlnode_get_child(x, new_tag)) != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
341 return(y);
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 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
344 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
345
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 * insert the new tag into its parent node
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 return(xmlnode_new_child((x == NULL? start : x), new_tag));
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
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 * Send vCard info to Jabber server
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 void jabber_set_info(GaimConnection *gc, const char *info)
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 JabberIq *iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
358 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
359 xmlnode *vc_node;
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
362 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
363 * Send only if there's actually any *information* to send
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
364 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
365 vc_node = xmlnode_from_str(info, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
366
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
367 if(vc_node) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
368 if (vc_node->name &&
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
369 !g_ascii_strncasecmp(vc_node->name, "vcard", 5)) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
370 iq = jabber_iq_new(js, JABBER_IQ_SET);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
371 xmlnode_insert_child(iq->node, vc_node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
372 jabber_iq_send(iq);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
373 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
374 xmlnode_free(vc_node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
375 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
376 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
377 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
378
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 * This is the callback from the "ok clicked" for "set vCard"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
381 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
382 * Formats GSList data into XML-encoded string and returns a pointer
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
383 * to said string.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
384 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
385 * g_free()'ing the returned string space is the responsibility of
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
386 * the caller.
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
387 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
388 static void
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
389 jabber_format_info(GaimConnection *gc, GaimRequestFields *fields)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
390 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
391 GaimAccount *account;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
392 xmlnode *vc_node;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
393 GaimRequestField *field;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
394 const char *text;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
395 char *p;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
396 const struct vcard_template *vc_tp;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
397 struct tag_attr *tag_attr;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
398
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
399 vc_node = xmlnode_new("vCard");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
400
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
401 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
402 xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
403
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
404 for (vc_tp = vcard_template_data; vc_tp->label != NULL; vc_tp++) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
405 if (*vc_tp->label == '\0')
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
406 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
407
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
408 field = gaim_request_fields_get_field(fields, vc_tp->tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
409 text = gaim_request_field_string_get_value(field);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
410
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
411 gaim_debug(GAIM_DEBUG_INFO, "jabber",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
412 "Setting %s to '%s'\n", vc_tp->tag, text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
413
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
414 if (text != NULL && *text != '\0') {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
415 xmlnode *xp;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
416
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
417 if ((xp = insert_tag_to_parent_tag(vc_node,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
418 NULL, vc_tp->tag)) != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
419
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
420 xmlnode_insert_data(xp, text, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
421 }
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 p = xmlnode_to_str(vc_node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
426 xmlnode_free(vc_node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
427
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
428 account = gaim_connection_get_account(gc);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
429
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
430 if (account != NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
431 gaim_account_set_user_info(account, p);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
432
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
433 if (gc != NULL)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
434 serv_set_info(gc, p);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
435 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
436
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
437 g_free(p);
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
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 * This gets executed by the proto action
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
442 *
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
443 * Creates a new GaimRequestFields struct, gets the XML-formatted user_info
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
444 * string (if any) into GSLists for the (multi-entry) edit dialog and
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
445 * calls the set_vcard dialog.
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 void jabber_setup_set_info(GaimConnection *gc)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
448 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
449 GaimRequestFields *fields;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
450 GaimRequestFieldGroup *group;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
451 GaimRequestField *field;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
452 const struct vcard_template *vc_tp;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
453 char *user_info;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
454 char *cdata;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
455 xmlnode *x_vc_data = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
456
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
457 fields = gaim_request_fields_new();
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
458 group = gaim_request_field_group_new(NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
459 gaim_request_fields_add_group(fields, group);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
460
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
461 /*
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
462 * Get existing, XML-formatted, user info
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
463 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
464 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
465 x_vc_data = xmlnode_from_str(user_info, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
466 else
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
467 user_info = g_strdup("");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
468
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 * 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
471 */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
472 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
473 xmlnode *data_node;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
474 if((vc_tp->label)[0] == '\0')
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
475 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
476 if(vc_tp->ptag == NULL) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
477 data_node = xmlnode_get_child(x_vc_data, vc_tp->tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
478 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
479 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
480 data_node = xmlnode_get_child(x_vc_data, tag);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
481 g_free(tag);
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 if(data_node)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
484 cdata = xmlnode_get_data(data_node);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
485 else
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
486 cdata = NULL;
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 if(strcmp(vc_tp->tag, "DESC") == 0) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
489 field = gaim_request_field_string_new(vc_tp->tag,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
490 _(vc_tp->label), cdata,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
491 TRUE);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
492 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
493 field = gaim_request_field_string_new(vc_tp->tag,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
494 _(vc_tp->label), cdata,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
495 FALSE);
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
498 gaim_request_field_group_add_field(group, field);
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 if(x_vc_data != NULL)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
502 xmlnode_free(x_vc_data);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
503
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
504 g_free(user_info);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
505
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
506 gaim_request_fields(gc, _("Edit Jabber vCard"),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
507 _("Edit Jabber vCard"),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
508 _("All items below are optional. Enter only the "
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
509 "information with which you feel comfortable."),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
510 fields,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
511 _("Save"), G_CALLBACK(jabber_format_info),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
512 _("Cancel"), NULL,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
513 gc);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
514 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
515
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
516 /*---------------------------------------*/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
517 /* End Jabber "set info" (vCard) support */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
518 /*---------------------------------------*/
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
519
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
520 /******
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
521 * end of that ancient crap that needs to die
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
524
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
525 static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
526 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
527 GList *resources;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
528 const char *from = xmlnode_get_attrib(packet, "from");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
529 JabberBuddy *jb;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
530 JabberBuddyResource *jbr;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
531 GString *info_text;
7306
7c12dab8e513 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
532 char *resource_name;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
533 char *title;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
534 xmlnode *vcard;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
535
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
536 if(!from)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
537 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
538
7116
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
539 /* XXX: make this handle handle errors */
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
540
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
541 resource_name = jabber_get_resource(from);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
542
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
543 jb = jabber_buddy_find(js, from, TRUE);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
544 info_text = g_string_new("");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
545
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
546 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", _("Jabber ID"),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
547 from);
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(resource_name) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
550 jbr = jabber_buddy_find_resource(jb, resource_name);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
551 if(jbr) {
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
552 char *purdy = NULL;
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
553 if(jbr->status)
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
554 purdy = gaim_strdup_withhtml(jbr->status);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
555 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
556 _("Status"), jabber_get_state_string(jbr->state),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
557 purdy ? ": " : "",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
558 purdy ? purdy : "");
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
559 if(purdy)
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
560 g_free(purdy);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
561 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
562 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
563 _("Status"), _("Unknown"));
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 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
566 for(resources = jb->resources; resources; resources = resources->next) {
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
567 char *purdy = NULL;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
568 jbr = resources->data;
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
569 if(jbr->status)
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
570 purdy = gaim_strdup_withhtml(jbr->status);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
571 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
572 _("Resource"), jbr->name);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
573 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/><br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
574 _("Status"), jabber_get_state_string(jbr->state),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
575 purdy ? ": " : "",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
576 purdy ? purdy : "");
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
577 if(purdy)
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
578 g_free(purdy);
7014
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
7306
7c12dab8e513 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
582 g_free(resource_name);
7c12dab8e513 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
583
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
584 if((vcard = xmlnode_get_child(packet, "vCard"))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
585 xmlnode *child;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
586 for(child = vcard->child; child; child = child->next)
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 xmlnode *child2;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
589 char *text;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
590
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
591 if(child->type != NODE_TYPE_TAG)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
592 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
593
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
594 text = xmlnode_get_data(child);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
595 if(text && !strcmp(child->name, "FN")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
596 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
597 _("Full Name"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
598 } else if(!strcmp(child->name, "N")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
599 for(child2 = child->child; child2; child2 = child2->next)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
600 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
601 char *text2;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
602
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
603 if(child2->type != NODE_TYPE_TAG)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
604 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
605
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
606 text2 = xmlnode_get_data(child2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
607 if(text2 && !strcmp(child2->name, "FAMILY")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
608 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
609 "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
610 _("Family Name"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
611 } else if(text2 && !strcmp(child2->name, "GIVEN")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
612 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
613 "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
614 _("Given Name"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
615 } else if(text2 && !strcmp(child2->name, "MIDDLE")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
616 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
617 "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
618 _("Middle Name"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
619 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
620 g_free(text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
621 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
622 } else if(text && !strcmp(child->name, "NICKNAME")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
623 serv_got_alias(js->gc, from, text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
624 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
625 _("Nickname"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
626 } else if(text && !strcmp(child->name, "BDAY")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
627 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
628 _("Birthday"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
629 } else if(!strcmp(child->name, "ADR")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
630 /* show which address it is */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
631 if(child->child)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
632 g_string_append_printf(info_text, "<b>%s:</b><br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
633 _("Address"));
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
634 for(child2 = child->child; child2; child2 = child2->next)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
635 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
636 char *text2;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
637
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
638 if(child2->type != NODE_TYPE_TAG)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
639 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
640
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
641 text2 = xmlnode_get_data(child2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
642 if(text2 && !strcmp(child2->name, "POBOX")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
643 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
644 "&nbsp;<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
645 _("P.O. Box"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
646 } else if(text2 && !strcmp(child2->name, "EXTADR")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
647 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
648 "&nbsp;<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
649 _("Extended Address"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
650 } else if(text2 && !strcmp(child2->name, "STREET")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
651 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
652 "&nbsp;<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
653 _("Street Address"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
654 } else if(text2 && !strcmp(child2->name, "LOCALITY")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
655 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
656 "&nbsp;<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
657 _("Locality"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
658 } else if(text2 && !strcmp(child2->name, "REGION")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
659 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
660 "&nbsp;<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
661 _("Region"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
662 } else if(text2 && !strcmp(child2->name, "PCODE")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
663 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
664 "&nbsp;<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
665 _("Postal Code"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
666 } else if(text2 && (!strcmp(child2->name, "CTRY")
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
667 || !strcmp(child2->name, "COUNTRY"))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
668 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
669 "&nbsp;<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
670 _("Country"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
671 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
672 g_free(text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
673 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
674 } else if(!strcmp(child->name, "TEL")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
675 char *number;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
676 if((child2 = xmlnode_get_child(child, "NUMBER"))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
677 /* show what kind of number it is */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
678 number = xmlnode_get_data(child2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
679 if(number) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
680 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
681 "<b>%s:</b> %s<br/>\n", _("Telephone"), number);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
682 g_free(number);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
683 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
684 } else if((number = xmlnode_get_data(child))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
685 /* lots of clients (including gaim) do this, but it's
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
686 * out of spec */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
687 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
688 "<b>%s:</b> %s<br/>\n", _("Telephone"), number);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
689 g_free(number);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
690 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
691 } else if(!strcmp(child->name, "EMAIL")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
692 char *userid;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
693 if((child2 = xmlnode_get_child(child, "USERID"))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
694 /* show what kind of email it is */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
695 userid = xmlnode_get_data(child2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
696 if(userid) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
697 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
698 "<b>%s:</b> <a href='mailto:%s'>%s</a><br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
699 _("Email"), userid, userid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
700 g_free(userid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
701 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
702 } else if((userid = xmlnode_get_data(child))) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
703 /* lots of clients (including gaim) do this, but it's
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
704 * out of spec */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
705 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
706 "<b>%s:</b> <a href='mailto:%s'>%s</a><br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
707 _("Email"), userid, userid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
708 g_free(userid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
709 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
710 } else if(!strcmp(child->name, "ORG")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
711 for(child2 = child->child; child2; child2 = child2->next)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
712 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
713 char *text2;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
714
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
715 if(child2->type != NODE_TYPE_TAG)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
716 continue;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
717
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
718 text2 = xmlnode_get_data(child2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
719 if(text2 && !strcmp(child2->name, "ORGNAME")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
720 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
721 "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
722 _("Organization Name"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
723 } else if(text2 && !strcmp(child2->name, "ORGUNIT")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
724 g_string_append_printf(info_text,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
725 "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
726 _("Organization Unit"), text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
727 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
728 g_free(text2);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
729 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
730 } else if(text && !strcmp(child->name, "TITLE")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
731 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
732 _("Title"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
733 } else if(text && !strcmp(child->name, "ROLE")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
734 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
735 _("Role"), text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
736 } else if(text && !strcmp(child->name, "DESC")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
737 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
738 _("Description"), text);
7076
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
739 } else if(!strcmp(child->name, "PHOTO") ||
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
740 !strcmp(child->name, "LOGO")) {
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
741 if((child2 = xmlnode_get_child(child, "BINVAL"))) {
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
742 char *data, *text2;
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
743 int size, imgid;
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
744 if((text2 = xmlnode_get_data(child2))) {
7106
db6bd3e794d8 [gaim-migrate @ 7671]
Christian Hammond <chipx86@chipx86.com>
parents: 7076
diff changeset
745 gaim_base64_decode(text2, &data, &size);
7076
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
746
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
747 imgid = gaim_imgstore_add(data, size, "logo.png");
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
748 g_string_append_printf(info_text,
7116
6c8706109f92 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
749 "<b>%s:</b> <img id='%d'><br/>",
7076
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
750 strcmp(child->name, "PHOTO") == 0 ?
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
751 _("Photo") : _("Logo"),
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
752 imgid);
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
753
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
754 g_free(data);
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
755 g_free(text2);
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
756 }
9f1a6c97108d [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
757 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
758 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
759 g_free(text);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
760 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
761 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
762
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
763 title = g_strdup_printf("User info for %s", from);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
764
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
765 gaim_notify_formatted(NULL, title, _("Jabber Profile"),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
766 NULL, info_text->str, NULL, NULL);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
767
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
768 g_free(title);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
769 g_string_free(info_text, TRUE);
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
772 void jabber_buddy_get_info(GaimConnection *gc, const char *who)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
773 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
774 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
775 JabberIq *iq;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
776 xmlnode *vcard;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
777
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
778 iq = jabber_iq_new(js, JABBER_IQ_GET);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
779
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
780 xmlnode_set_attrib(iq->node, "to", who);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
781 vcard = xmlnode_new_child(iq->node, "vCard");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
782 xmlnode_set_attrib(vcard, "xmlns", "vcard-temp");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
783
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
784 jabber_iq_set_callback(iq, jabber_vcard_parse, NULL);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
785
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
786 jabber_iq_send(iq);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
787 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
788
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
789 void jabber_buddy_get_info_chat(GaimConnection *gc, int id,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
790 const char *resource)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
791 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
792 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
793 JabberChat *chat = jabber_chat_find_by_id(js, id);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
794 char *full_jid;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
795
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
796 if(!chat)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
797 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
798
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
799 full_jid = g_strdup_printf("%s@%s/%s", chat->room, chat->server, resource);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
800 jabber_buddy_get_info(gc, full_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
801 g_free(full_jid);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
802 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
803
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
804
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
805
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
806 static void jabber_buddy_ask_send_file(GaimConnection *gc, const char *name)
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
807 {
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
808 JabberStream *js = gc->proto_data;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
809 GaimXfer *xfer;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
810 JabberSIXfer *jsx;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
811
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
812 xfer = gaim_xfer_new(gaim_connection_get_account(gc), GAIM_XFER_SEND, name);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
813
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
814 xfer->data = jsx = g_new0(JabberSIXfer, 1);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
815 jsx->js = js;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
816
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
817 gaim_xfer_set_init_fnc(xfer, jabber_si_xfer_init);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
818 gaim_xfer_set_start_fnc(xfer, jabber_si_xfer_start);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
819 gaim_xfer_set_end_fnc(xfer, jabber_si_xfer_end);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
820 gaim_xfer_set_cancel_send_fnc(xfer, jabber_si_xfer_cancel_send);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
821 gaim_xfer_set_cancel_recv_fnc(xfer, jabber_si_xfer_cancel_recv);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
822 gaim_xfer_set_ack_fnc(xfer, jabber_si_xfer_ack);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
823
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
824 js->file_transfers = g_list_append(js->file_transfers, xfer);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
825
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
826 gaim_xfer_request(xfer);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
827 }
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
828
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
829 static void jabber_buddy_set_invisibility(JabberStream *js, const char *who,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
830 gboolean invisible)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
831 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
832 JabberBuddy *jb = jabber_buddy_find(js, who, TRUE);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
833 xmlnode *presence;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
834
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
835 presence = jabber_presence_create(js->gc->away_state, js->gc->away);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
836 xmlnode_set_attrib(presence, "to", who);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
837 if(invisible) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
838 xmlnode_set_attrib(presence, "type", "invisible");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
839 jb->invisible |= JABBER_INVIS_BUDDY;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
840 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
841 jb->invisible &= ~JABBER_INVIS_BUDDY;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
842 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
843
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
844 jabber_send(js, presence);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
845 xmlnode_free(presence);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
846 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
847
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
848 static void jabber_buddy_make_invisible(GaimConnection *gc, const char *name)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
849 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
850 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
851 jabber_buddy_set_invisibility(js, name, TRUE);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
852 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
853
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
854 static void jabber_buddy_make_visible(GaimConnection *gc, const char *name)
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 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
857 jabber_buddy_set_invisibility(js, name, FALSE);
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
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
860 static void jabber_buddy_cancel_presence_notification(GaimConnection *gc,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
861 const char *name)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
862 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
863 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
864
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
865 /* I wonder if we should prompt the user before doing this */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
866 jabber_presence_subscription_set(js, name, "unsubscribed");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
867 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
868
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
869 static void jabber_buddy_rerequest_auth(GaimConnection *gc, const char *name)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
870 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
871 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
872
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
873 jabber_presence_subscription_set(js, name, "subscribe");
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
7250
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
876 static void jabber_buddy_unsubscribe(GaimConnection *gc, const char *name)
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
877 {
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
878 JabberStream *js = gc->proto_data;
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
879
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
880 jabber_presence_subscription_set(js, name, "unsubscribe");
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
881 }
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
882
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
883 GList *jabber_buddy_menu(GaimConnection *gc, const char *name)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
884 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
885 GList *m = NULL;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
886 struct proto_buddy_menu *pbm;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
887 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
888 JabberBuddy *jb = jabber_buddy_find(js, name, TRUE);
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
889
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
890 if(!jb)
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
891 return m;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
892
7425
85cd2e71bff7 [gaim-migrate @ 8028]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
893 /* XXX: should check capability once we know we want to send
85cd2e71bff7 [gaim-migrate @ 8028]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
894 pbm = g_new0(struct proto_buddy_menu, 1);
85cd2e71bff7 [gaim-migrate @ 8028]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
895 pbm->label = _("Send File");
85cd2e71bff7 [gaim-migrate @ 8028]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
896 pbm->callback = jabber_buddy_ask_send_file;
85cd2e71bff7 [gaim-migrate @ 8028]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
897 pbm->gc = gc;
85cd2e71bff7 [gaim-migrate @ 8028]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
898 m = g_list_append(m, pbm);
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
899
7425
85cd2e71bff7 [gaim-migrate @ 8028]
Nathan Walp <nwalp@pidgin.im>
parents: 7395
diff changeset
900 */
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
901
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
902 pbm = g_new0(struct proto_buddy_menu, 1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
903 if(jb->invisible & JABBER_INVIS_BUDDY) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
904 pbm->label = _("Un-hide From");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
905 pbm->callback = jabber_buddy_make_visible;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
906 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
907 pbm->label = _("Temporarily Hide From");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
908 pbm->callback = jabber_buddy_make_invisible;
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 pbm->gc = gc;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
911 m = g_list_append(m, pbm);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
912
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
913 if(jb->subscription & JABBER_SUB_FROM) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
914 pbm = g_new0(struct proto_buddy_menu, 1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
915 pbm->label = _("Cancel Presence Notification");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
916 pbm->callback = jabber_buddy_cancel_presence_notification;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
917 pbm->gc = gc;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
918 m = g_list_append(m, pbm);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
919 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
920
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
921 if(!(jb->subscription & JABBER_SUB_TO)) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
922 pbm = g_new0(struct proto_buddy_menu, 1);
7250
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
923 pbm->label = _("(Re-)Request authorization");
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
924 pbm->callback = jabber_buddy_rerequest_auth;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
925 pbm->gc = gc;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
926 m = g_list_append(m, pbm);
7250
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
927 } else {
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
928 pbm = g_new0(struct proto_buddy_menu, 1);
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
929 pbm->label = _("Unsubscribe");
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
930 pbm->callback = jabber_buddy_unsubscribe;
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
931 pbm->gc = gc;
dee9f6aebbf3 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
932 m = g_list_append(m, pbm);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
933 }
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
934
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
935 return m;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
936 }