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