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