libpurple/protocols/jabber/buddy.c

Mon, 22 Aug 2011 06:32:44 +0000

author
Mark Doliner <markdoliner@pidgin.im>
date
Mon, 22 Aug 2011 06:32:44 +0000
changeset 32204
2a09624616c3
parent 32203
e7c2d37aecd5
child 32277
97f16af01a05
child 32438
dc8991868906
permissions
-rw-r--r--

Actually commit the purple_notify_user_info_prepend_pair_plaintext
function. I think I left it off my previous commit? Sorry.
And rename purple_notify_user_info_prepend_pair to
purple_notify_user_info_prepend_pair_html_html

7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2 * purple - Jabber Protocol Plugin
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28311
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28311
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28311
diff changeset
6 * source distribution.
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * 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
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "internal.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 #include "debug.h"
7076
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
25 #include "imgstore.h"
9713
bb37562302a1 [gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents: 9466
diff changeset
26 #include "prpl.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
27 #include "notify.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "request.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
29 #include "util.h"
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
30 #include "xmlnode.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "buddy.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 #include "chat.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34 #include "jabber.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 #include "iq.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 #include "presence.h"
25475
ad7612a5d678 Migrate the XMPP User Avatar (XEP-0084) code to its own file
Paul Aurich <darkrain42@pidgin.im>
parents: 25391
diff changeset
37 #include "useravatar.h"
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
38 #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
39 #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
40 #include "adhoccommands.h"
29913
58f5122fbcd3 First shot at refactoring the Google-specific XMPP code.
Marcus Lundblad <malu@pidgin.im>
parents: 29910
diff changeset
41 #include "google/google.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
43 typedef struct {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
44 long idle_seconds;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
45 } JabberBuddyInfoResource;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
46
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
47 typedef struct {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
48 JabberStream *js;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
49 JabberBuddy *jb;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
50 char *jid;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
51 GSList *ids;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
52 GHashTable *resources;
27305
ef06405deeb0 Use guint for a timeout handle here, too.
Paul Aurich <darkrain42@pidgin.im>
parents: 27297
diff changeset
53 guint timeout_handle;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
54 GSList *vcard_imgids;
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
55 PurpleNotifyUserInfo *user_info;
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
56 long last_seconds;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
57 gchar *last_message;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
58 } JabberBuddyInfo;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
59
29388
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
60 static void
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
61 jabber_buddy_resource_free(JabberBuddyResource *jbr)
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
62 {
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
63 g_return_if_fail(jbr != NULL);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
64
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
65 jbr->jb->resources = g_list_remove(jbr->jb->resources, jbr);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
66
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
67 while(jbr->commands) {
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
68 JabberAdHocCommands *cmd = jbr->commands->data;
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
69 g_free(cmd->jid);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
70 g_free(cmd->node);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
71 g_free(cmd->name);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
72 g_free(cmd);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
73 jbr->commands = g_list_delete_link(jbr->commands, jbr->commands);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
74 }
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
75
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
76 while (jbr->caps.exts) {
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
77 g_free(jbr->caps.exts->data);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
78 jbr->caps.exts = g_list_delete_link(jbr->caps.exts, jbr->caps.exts);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
79 }
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
80
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
81 g_free(jbr->name);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
82 g_free(jbr->status);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
83 g_free(jbr->thread_id);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
84 g_free(jbr->client.name);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
85 g_free(jbr->client.version);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
86 g_free(jbr->client.os);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
87 g_free(jbr);
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
88 }
d46f089712e8 jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents: 29387
diff changeset
89
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
90 void jabber_buddy_free(JabberBuddy *jb)
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
91 {
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
92 g_return_if_fail(jb != NULL);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
93
22942
2bf494f8e2a4 Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents: 22928
diff changeset
94 g_free(jb->error_msg);
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
95 while(jb->resources)
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
96 jabber_buddy_resource_free(jb->resources->data);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
97
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
98 g_free(jb);
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
99 }
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
100
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101 JabberBuddy *jabber_buddy_find(JabberStream *js, const char *name,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102 gboolean create)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 JabberBuddy *jb;
27297
168f268f927d Plug a leak from changing this to use jabber_get_bare_jid instead of normalize.
Paul Aurich <darkrain42@pidgin.im>
parents: 27289
diff changeset
105 char *realname;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106
15143
37451143f5c4 [gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents: 15092
diff changeset
107 if (js->buddies == NULL)
37451143f5c4 [gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents: 15092
diff changeset
108 return NULL;
37451143f5c4 [gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents: 15092
diff changeset
109
27110
05ca719b901b Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents: 27075
diff changeset
110 if(!(realname = jabber_get_bare_jid(name)))
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111 return NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
113 jb = g_hash_table_lookup(js->buddies, realname);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
114
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
115 if(!jb && create) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
116 jb = g_new0(JabberBuddy, 1);
27297
168f268f927d Plug a leak from changing this to use jabber_get_bare_jid instead of normalize.
Paul Aurich <darkrain42@pidgin.im>
parents: 27289
diff changeset
117 g_hash_table_insert(js->buddies, realname, jb);
168f268f927d Plug a leak from changing this to use jabber_get_bare_jid instead of normalize.
Paul Aurich <darkrain42@pidgin.im>
parents: 27289
diff changeset
118 } else
168f268f927d Plug a leak from changing this to use jabber_get_bare_jid instead of normalize.
Paul Aurich <darkrain42@pidgin.im>
parents: 27289
diff changeset
119 g_free(realname);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
120
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
121 return jb;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
122 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
123
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
124 /* Returns -1 if a is a higher priority resource than b, or is
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
125 * "more available" than b. 0 if they're the same, and 1 if b is
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
126 * higher priority/more available than a.
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
127 */
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
128 static gint resource_compare_cb(gconstpointer a, gconstpointer b)
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
129 {
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
130 const JabberBuddyResource *jbra = a;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
131 const JabberBuddyResource *jbrb = b;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
132 JabberBuddyState state_a, state_b;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
133
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
134 if (jbra->priority != jbrb->priority)
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
135 return jbra->priority > jbrb->priority ? -1 : 1;
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
136
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
137 /* Fold the states for easier comparison */
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
138 /* TODO: Differentiate online/chat and away/dnd? */
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
139 switch (jbra->state) {
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
140 case JABBER_BUDDY_STATE_ONLINE:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
141 case JABBER_BUDDY_STATE_CHAT:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
142 state_a = JABBER_BUDDY_STATE_ONLINE;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
143 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
144 case JABBER_BUDDY_STATE_AWAY:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
145 case JABBER_BUDDY_STATE_DND:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
146 state_a = JABBER_BUDDY_STATE_AWAY;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
147 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
148 case JABBER_BUDDY_STATE_XA:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
149 state_a = JABBER_BUDDY_STATE_XA;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
150 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
151 case JABBER_BUDDY_STATE_UNAVAILABLE:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
152 state_a = JABBER_BUDDY_STATE_UNAVAILABLE;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
153 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
154 default:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
155 state_a = JABBER_BUDDY_STATE_UNKNOWN;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
156 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
157 }
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
158
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
159 switch (jbrb->state) {
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
160 case JABBER_BUDDY_STATE_ONLINE:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
161 case JABBER_BUDDY_STATE_CHAT:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
162 state_b = JABBER_BUDDY_STATE_ONLINE;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
163 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
164 case JABBER_BUDDY_STATE_AWAY:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
165 case JABBER_BUDDY_STATE_DND:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
166 state_b = JABBER_BUDDY_STATE_AWAY;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
167 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
168 case JABBER_BUDDY_STATE_XA:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
169 state_b = JABBER_BUDDY_STATE_XA;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
170 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
171 case JABBER_BUDDY_STATE_UNAVAILABLE:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
172 state_b = JABBER_BUDDY_STATE_UNAVAILABLE;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
173 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
174 default:
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
175 state_b = JABBER_BUDDY_STATE_UNKNOWN;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
176 break;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
177 }
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
178
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
179 if (state_a == state_b) {
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
180 if (jbra->idle == jbrb->idle)
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
181 return 0;
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
182 else if ((jbra->idle && !jbrb->idle) ||
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
183 (jbra->idle && jbrb->idle && jbra->idle < jbrb->idle))
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
184 return 1;
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
185 else
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
186 return -1;
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
187 }
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
188
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
189 if (state_a == JABBER_BUDDY_STATE_ONLINE)
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
190 return -1;
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
191 else if (state_a == JABBER_BUDDY_STATE_AWAY &&
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
192 (state_b == JABBER_BUDDY_STATE_XA ||
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
193 state_b == JABBER_BUDDY_STATE_UNAVAILABLE ||
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
194 state_b == JABBER_BUDDY_STATE_UNKNOWN))
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
195 return -1;
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
196 else if (state_a == JABBER_BUDDY_STATE_XA &&
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
197 (state_b == JABBER_BUDDY_STATE_UNAVAILABLE ||
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
198 state_b == JABBER_BUDDY_STATE_UNKNOWN))
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
199 return -1;
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
200 else if (state_a == JABBER_BUDDY_STATE_UNAVAILABLE &&
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
201 state_b == JABBER_BUDDY_STATE_UNKNOWN)
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
202 return -1;
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
203
29385
314d07cec6ba jabber: Fix the resource_compare_cb function after checking how they're used with GSLists
Paul Aurich <darkrain42@pidgin.im>
parents: 29384
diff changeset
204 return 1;
27965
d2f136953034 jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents: 27846
diff changeset
205 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
206
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
207 JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
208 const char *resource)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
209 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210 GList *l;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211
29387
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
212 if (!jb)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
213 return NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214
29387
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
215 if (resource == NULL)
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
216 return jb->resources ? jb->resources->data : NULL;
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
217
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
218 for (l = jb->resources; l; l = l->next)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
219 {
29387
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
220 JabberBuddyResource *jbr = l->data;
29811
71d3ea23bbc9 jabber: Avoid crashing if a buddy has a NULL resource.
Paul Aurich <darkrain42@pidgin.im>
parents: 29388
diff changeset
221 if (jbr->name && g_str_equal(resource, jbr->name))
29387
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
222 return jbr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
223 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224
29387
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
225 return NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
226 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
228 JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource,
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
229 int priority, JabberBuddyState state, const char *status)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230 {
29387
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
231 /* TODO: Optimization: Only reinsert if priority+state changed */
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
232 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
29387
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
233 if (jbr) {
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
234 jb->resources = g_list_remove(jb->resources, jbr);
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
235 } else {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
236 jbr = g_new0(JabberBuddyResource, 1);
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
237 jbr->jb = jb;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 jbr->name = g_strdup(resource);
27746
4b3f015977d9 For contacts who advertise Entity Caps, check for XHTML-IM support. Refs #4650.
Paul Aurich <darkrain42@pidgin.im>
parents: 27696
diff changeset
239 jbr->capabilities = JABBER_CAP_NONE;
25822
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
240 jbr->tz_off = PURPLE_NO_TZ_OFF;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 jbr->priority = priority;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243 jbr->state = state;
22928
6bd622930dba Simplify
Mark Doliner <markdoliner@pidgin.im>
parents: 22622
diff changeset
244 g_free(jbr->status);
27775
b8569a76e02e Don't pre-escape jbr->status. Almost every place required it in unescaped
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27696
diff changeset
245 jbr->status = g_strdup(status);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
246
29387
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
247 jb->resources = g_list_insert_sorted(jb->resources, jbr,
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
248 resource_compare_cb);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
249 return jbr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
252 void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
254 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
255
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
256 if(!jbr)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
257 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
258
7116
86c328e44c15 [gaim-migrate @ 7683]
Nathan Walp <nwalp@pidgin.im>
parents: 7108
diff changeset
259 jabber_buddy_resource_free(jbr);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
260 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
261
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
262 /*******
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
263 * This is the old vCard stuff taken from the old prpl. vCards, by definition
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264 * are a temporary thing until jabber can get its act together and come up
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
265 * with a format for user information, hence the namespace of 'vcard-temp'
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
266 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
267 * Since I don't feel like putting that much work into something that's
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
268 * _supposed_ to go away, i'm going to just copy the kludgy old code here,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269 * and make it purdy when jabber comes up with a standards-track JEP to
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270 * replace vcard-temp
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
271 * --Nathan
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
272 *******/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
273
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 /* Jabber "set info" (vCard) support */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279 * V-Card format:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
280 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
281 * <vCard prodid='' version='' xmlns=''>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282 * <FN></FN>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
283 * <N>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 * <FAMILY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
285 * <GIVEN/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286 * </N>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
287 * <NICKNAME/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
288 * <URL/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
289 * <ADR>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290 * <STREET/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
291 * <EXTADD/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
292 * <LOCALITY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
293 * <REGION/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
294 * <PCODE/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
295 * <COUNTRY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
296 * </ADR>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
297 * <TEL/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
298 * <EMAIL/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
299 * <ORG>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
300 * <ORGNAME/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
301 * <ORGUNIT/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
302 * </ORG>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
303 * <TITLE/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
304 * <ROLE/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
305 * <DESC/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
306 * <BDAY/>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
307 * </vCard>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
308 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
309 * See also:
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
310 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
311 * http://docs.jabber.org/proto/html/vcard-temp.html
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
312 * http://www.vcard-xml.org/dtd/vCard-XML-v2-20010520.dtd
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
313 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
314
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
315 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
316 * Cross-reference user-friendly V-Card entry labels to vCard XML tags
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
317 * and attributes.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
318 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
319 * Order is (or should be) unimportant. For example: we have no way of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
320 * knowing in what order real data will arrive.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
321 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
322 * Format: Label, Pre-set text, "visible" flag, "editable" flag, XML tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
323 * name, XML tag's parent tag "path" (relative to vCard node).
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
324 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
325 * List is terminated by a NULL label pointer.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
326 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
327 * Entries with no label text, but with XML tag and parent tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
328 * entries, are used by V-Card XML construction routines to
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329 * "automagically" construct the appropriate XML node tree.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
330 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
331 * Thoughts on future direction/expansion
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
332 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
333 * This is a "simple" vCard.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
334 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
335 * It is possible for nodes other than the "vCard" node to have
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336 * attributes. Should that prove necessary/desirable, add an
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
337 * "attributes" pointer to the vcard_template struct, create the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
338 * necessary tag_attr structs, and add 'em to the vcard_dflt_data
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
339 * array.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
340 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
341 * The above changes will (obviously) require changes to the vCard
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
342 * construction routines.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
343 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
344
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
345 struct vcard_template {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
346 char *label; /* label text pointer */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
347 char *tag; /* tag text */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
348 char *ptag; /* parent tag "path" text */
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
349 } const vcard_template_data[] = {
26563
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
350 {N_("Full Name"), "FN", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
351 {N_("Family Name"), "FAMILY", "N"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
352 {N_("Given Name"), "GIVEN", "N"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
353 {N_("Nickname"), "NICKNAME", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
354 {N_("URL"), "URL", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
355 {N_("Street Address"), "STREET", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
356 {N_("Extended Address"), "EXTADD", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
357 {N_("Locality"), "LOCALITY", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
358 {N_("Region"), "REGION", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
359 {N_("Postal Code"), "PCODE", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
360 {N_("Country"), "CTRY", "ADR"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
361 {N_("Telephone"), "NUMBER", "TEL"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
362 {N_("Email"), "USERID", "EMAIL"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
363 {N_("Organization Name"), "ORGNAME", "ORG"},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
364 {N_("Organization Unit"), "ORGUNIT", "ORG"},
29965
d4d794093d2d Eliminate the name collisions on "Title". I have a few qualms:
Paul Aurich <darkrain42@pidgin.im>
parents: 29910
diff changeset
365 {N_("Job Title"), "TITLE", NULL},
26563
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
366 {N_("Role"), "ROLE", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
367 {N_("Birthday"), "BDAY", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
368 {N_("Description"), "DESC", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
369 {"", "N", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
370 {"", "ADR", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
371 {"", "ORG", NULL},
29674a9754ab Remove some unused fields. Thanks to Mayank Jain Nawal's email to the
Mark Doliner <markdoliner@pidgin.im>
parents: 26042
diff changeset
372 {NULL, NULL, NULL}
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
373 };
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
374
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
375 /*
8735
01248ea222d3 [gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents: 8401
diff changeset
376 * The "vCard" tag's attribute list...
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
377 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
378 struct tag_attr {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
379 char *attr;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
380 char *value;
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
381 } const vcard_tag_attr_list[] = {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
382 {"prodid", "-//HandGen//NONSGML vGen v1.0//EN"},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
383 {"version", "2.0", },
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
384 {"xmlns", "vcard-temp", },
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
385 {NULL, NULL},
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
386 };
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
387
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
388
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
389 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
390 * Insert a tag node into an xmlnode tree, recursively inserting parent tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
391 * nodes as necessary
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
392 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
393 * Returns pointer to inserted node
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
394 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
395 * Note to hackers: this code is designed to be re-entrant (it's recursive--it
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
396 * calls itself), so don't put any "static"s in here!
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
397 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
398 static xmlnode *insert_tag_to_parent_tag(xmlnode *start, const char *parent_tag, const char *new_tag)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
399 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
400 xmlnode *x = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
401
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
402 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
403 * If the parent tag wasn't specified, see if we can get it
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
404 * from the vCard template struct.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
405 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
406 if(parent_tag == NULL) {
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
407 const struct vcard_template *vc_tp = vcard_template_data;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
408
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
409 while(vc_tp->label != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
410 if(strcmp(vc_tp->tag, new_tag) == 0) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
411 parent_tag = vc_tp->ptag;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
412 break;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
413 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
414 ++vc_tp;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
415 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
416 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
417
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
418 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
419 * If we have a parent tag...
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
420 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
421 if(parent_tag != NULL ) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
422 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
423 * Try to get the parent node for a tag
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
424 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
425 if((x = xmlnode_get_child(start, parent_tag)) == NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
426 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
427 * Descend?
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
428 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
429 char *grand_parent = g_strdup(parent_tag);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
430 char *parent;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
431
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
432 if((parent = strrchr(grand_parent, '/')) != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
433 *(parent++) = '\0';
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
434 x = insert_tag_to_parent_tag(start, grand_parent, parent);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
435 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
436 x = xmlnode_new_child(start, grand_parent);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
437 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
438 g_free(grand_parent);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
439 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
440 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
441 * We found *something* to be the parent node.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
442 * Note: may be the "root" node!
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
443 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
444 xmlnode *y;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
445 if((y = xmlnode_get_child(x, new_tag)) != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
446 return(y);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
447 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
448 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
449 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
450
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
451 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
452 * insert the new tag into its parent node
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
453 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
454 return(xmlnode_new_child((x == NULL? start : x), new_tag));
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
455 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
456
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
457 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
458 * Send vCard info to Jabber server
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
459 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
460 void jabber_set_info(PurpleConnection *gc, const char *info)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
461 {
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
462 PurpleStoredImage *img;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
463 JabberIq *iq;
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
464 JabberStream *js = purple_connection_get_protocol_data(gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
465 xmlnode *vc_node;
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
466 const struct tag_attr *tag_attr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
467
31691
4239e2f2e6b7 Typo fix
Mark Doliner <markdoliner@pidgin.im>
parents: 31318
diff changeset
468 /* if we haven't grabbed the remote vcard yet, we can't
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
469 * assume that what we have here is correct */
31692
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
470 if(!js->vcard_fetched) {
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
471 PurpleStoredImage *image;
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
472 g_free(js->initial_avatar_hash);
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
473 image = purple_buddy_icons_find_account_icon(purple_connection_get_account(gc));
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
474 if (image != NULL) {
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
475 js->initial_avatar_hash =
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
476 jabber_calculate_data_hash(purple_imgstore_get_data(image),
31693
71f19e287209 Fix this indentation. My bad.
Mark Doliner <markdoliner@pidgin.im>
parents: 31692
diff changeset
477 purple_imgstore_get_size(image), "sha1");
31692
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
478 purple_imgstore_unref(image);
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
479 } else {
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
480 js->initial_avatar_hash = NULL;
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
481 }
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
482 return;
31692
97c06411eb81 Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents: 31691
diff changeset
483 }
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
484
28046
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
485 if (js->vcard_timer) {
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
486 purple_timeout_remove(js->vcard_timer);
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
487 js->vcard_timer = 0;
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
488 }
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
489
15273
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
490 g_free(js->avatar_hash);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
491 js->avatar_hash = NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
492
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
493 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
494 * Send only if there's actually any *information* to send
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
495 */
11388
3c8b093b5cfe [gaim-migrate @ 13616]
Nathan Walp <nwalp@pidgin.im>
parents: 11361
diff changeset
496 vc_node = info ? xmlnode_from_str(info, -1) : NULL;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
497
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
498 if (vc_node && (!vc_node->name ||
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
499 g_ascii_strncasecmp(vc_node->name, "vCard", 5))) {
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
500 xmlnode_free(vc_node);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
501 vc_node = NULL;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
502 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
503
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
504 if ((img = purple_buddy_icons_find_account_icon(gc->account))) {
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
505 gconstpointer avatar_data;
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
506 gsize avatar_len;
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
507 xmlnode *photo, *binval, *type;
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
508 gchar *enc;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
509
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
510 if(!vc_node) {
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
511 vc_node = xmlnode_new("vCard");
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
512 for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr)
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
513 xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value);
15273
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
514 }
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
515
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
516 avatar_data = purple_imgstore_get_data(img);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
517 avatar_len = purple_imgstore_get_size(img);
25386
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
518 /* Get rid of an old PHOTO if one exists.
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
519 * TODO: This may want to be modified to remove all old PHOTO
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
520 * children, at the moment some people have managed to get
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
521 * multiple PHOTO entries in their vCard. */
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
522 if((photo = xmlnode_get_child(vc_node, "PHOTO"))) {
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
523 xmlnode_free(photo);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
524 }
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
525 photo = xmlnode_new_child(vc_node, "PHOTO");
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
526 type = xmlnode_new_child(photo, "TYPE");
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
527 xmlnode_insert_data(type, "image/png", -1);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
528 binval = xmlnode_new_child(photo, "BINVAL");
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
529 enc = purple_base64_encode(avatar_data, avatar_len);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
530
29910
f1c6e586e5c1 jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents: 29849
diff changeset
531 js->avatar_hash =
f1c6e586e5c1 jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents: 29849
diff changeset
532 jabber_calculate_data_hash(avatar_data, avatar_len, "sha1");
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
533
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
534 xmlnode_insert_data(binval, enc, -1);
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
535 g_free(enc);
28151
109f9f60d725 This was a memory leak, right?
Mark Doliner <markdoliner@pidgin.im>
parents: 28114
diff changeset
536 purple_imgstore_unref(img);
25386
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
537 } else if (vc_node) {
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
538 xmlnode *photo;
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
539 /* TODO: Remove all PHOTO children? (see above note) */
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
540 if ((photo = xmlnode_get_child(vc_node, "PHOTO"))) {
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
541 xmlnode_free(photo);
7ca88088e0de Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents: 25385
diff changeset
542 }
22425
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
543 }
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
544
42142a0938a2 Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 21957
diff changeset
545 if (vc_node != NULL) {
15273
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
546 iq = jabber_iq_new(js, JABBER_IQ_SET);
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
547 xmlnode_insert_child(iq->node, vc_node);
a7838f939207 [gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents: 15205
diff changeset
548 jabber_iq_send(iq);
25478
0a7f22678a35 Send presence updates from jabber_set_info, not jabber_set_buddy_icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
549
0a7f22678a35 Send presence updates from jabber_set_info, not jabber_set_buddy_icon.
Paul Aurich <darkrain42@pidgin.im>
parents: 25477
diff changeset
550 /* Send presence to update vcard-temp:x:update */
26958
a955bd42f529 propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
parents: 26764 26950
diff changeset
551 jabber_presence_send(js, FALSE);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
552 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
553 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
554
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
555 void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
556 {
25811
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
557 PurpleAccount *account = purple_connection_get_account(gc);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
558
26950
842628304397 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents: 26947
diff changeset
559 /* Publish the avatar as specified in XEP-0084 */
842628304397 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents: 26947
diff changeset
560 jabber_avatar_set(gc->proto_data, img);
842628304397 Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents: 26947
diff changeset
561 /* Set the image in our vCard */
25811
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
562 jabber_set_info(gc, purple_account_get_user_info(account));
25385
158a12123bc8 Paul noticed that the conditional blocks here were backwards. I'm surprised no
Paul Aurich <darkrain42@pidgin.im>
parents: 25110
diff changeset
563
25811
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
564 /* TODO: Fake image to ourselves, since a number of servers do not echo
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
565 * back our presence to us. To do this without uselessly copying the data
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
566 * of the image, we need purple_buddy_icons_set_for_user_image (i.e. takes
57012229a242 Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents: 25542
diff changeset
567 * an existing icon/stored image). */
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
568 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
569
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
570 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
571 * This is the callback from the "ok clicked" for "set vCard"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
572 *
25391
363cb62aa353 Correct a comment, I don't imagine anyone will actually need this but better
Etan Reisner <deryni@pidgin.im>
parents: 25386
diff changeset
573 * Sets the vCard with data from PurpleRequestFields.
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
574 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
575 static void
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
576 jabber_format_info(PurpleConnection *gc, PurpleRequestFields *fields)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
577 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
578 xmlnode *vc_node;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
579 PurpleRequestField *field;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
580 const char *text;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
581 char *p;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
582 const struct vcard_template *vc_tp;
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20169
diff changeset
583 const struct tag_attr *tag_attr;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
584
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
585 vc_node = xmlnode_new("vCard");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
586
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
587 for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
588 xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
589
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
590 for (vc_tp = vcard_template_data; vc_tp->label != NULL; vc_tp++) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
591 if (*vc_tp->label == '\0')
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
592 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
593
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
594 field = purple_request_fields_get_field(fields, vc_tp->tag);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
595 text = purple_request_field_string_get_value(field);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
596
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
597
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
598 if (text != NULL && *text != '\0') {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
599 xmlnode *xp;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
600
28828
7c1855f037e7 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents: 28667
diff changeset
601 purple_debug_info("jabber", "Setting %s to '%s'\n", vc_tp->tag, text);
9339
31f4980a09ea [gaim-migrate @ 10147]
Nathan Walp <nwalp@pidgin.im>
parents: 9285
diff changeset
602
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
603 if ((xp = insert_tag_to_parent_tag(vc_node,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
604 NULL, vc_tp->tag)) != NULL) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
605
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
606 xmlnode_insert_data(xp, text, -1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
607 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
608 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
609 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
610
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7445
diff changeset
611 p = xmlnode_to_str(vc_node, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
612 xmlnode_free(vc_node);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
613
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
614 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
615 serv_set_info(gc, p);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
616
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
617 g_free(p);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
618 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
619
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
620 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
621 * This gets executed by the proto action
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
622 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
623 * Creates a new PurpleRequestFields struct, gets the XML-formatted user_info
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
624 * string (if any) into GSLists for the (multi-entry) edit dialog and
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
625 * calls the set_vcard dialog.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
626 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
627 void jabber_setup_set_info(PurplePluginAction *action)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
628 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
629 PurpleConnection *gc = (PurpleConnection *) action->context;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
630 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
631 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
632 PurpleRequestField *field;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
633 const struct vcard_template *vc_tp;
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
634 const char *user_info;
14130
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
635 char *cdata = NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
636 xmlnode *x_vc_data = NULL;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
637
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
638 fields = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
639 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
640 purple_request_fields_add_group(fields, group);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
641
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
642 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
643 * Get existing, XML-formatted, user info
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
644 */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
645 if((user_info = purple_account_get_user_info(gc->account)) != NULL)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
646 x_vc_data = xmlnode_from_str(user_info, -1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
647
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
648 /*
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
649 * Set up GSLists for edit with labels from "template," data from user info
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
650 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
651 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
652 xmlnode *data_node;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
653 if((vc_tp->label)[0] == '\0')
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
654 continue;
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
655
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
656 if (x_vc_data != NULL) {
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
657 if(vc_tp->ptag == NULL) {
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
658 data_node = xmlnode_get_child(x_vc_data, vc_tp->tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
659 } else {
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
660 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
661 data_node = xmlnode_get_child(x_vc_data, tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
662 g_free(tag);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
663 }
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
664 if(data_node)
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
665 cdata = xmlnode_get_data(data_node);
14130
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
666 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
667
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
668 if(strcmp(vc_tp->tag, "DESC") == 0) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
669 field = purple_request_field_string_new(vc_tp->tag,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
670 _(vc_tp->label), cdata,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
671 TRUE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
672 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
673 field = purple_request_field_string_new(vc_tp->tag,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
674 _(vc_tp->label), cdata,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
675 FALSE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
676 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
677
14130
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
678 g_free(cdata);
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
679 cdata = NULL;
02a5f8dad9cf [gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents: 14129
diff changeset
680
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
681 purple_request_field_group_add_field(group, field);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
682 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
683
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
684 if(x_vc_data != NULL)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
685 xmlnode_free(x_vc_data);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
686
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
687 purple_request_fields(gc, _("Edit XMPP vCard"),
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16799
diff changeset
688 _("Edit XMPP vCard"),
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
689 _("All items below are optional. Enter only the "
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
690 "information with which you feel comfortable."),
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
691 fields,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
692 _("Save"), G_CALLBACK(jabber_format_info),
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
693 _("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
694 purple_connection_get_account(gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
695 gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
696 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
697
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
698 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
699 /* End Jabber "set info" (vCard) support */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
700 /*---------------------------------------*/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
701
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
702 /******
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
703 * end of that ancient crap that needs to die
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
704 ******/
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
705
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
706 static void jabber_buddy_info_destroy(JabberBuddyInfo *jbi)
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
707 {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
708 /* 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
709 if (jbi->timeout_handle > 0)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
710 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
711
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
712 g_free(jbi->jid);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
713 g_hash_table_destroy(jbi->resources);
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
714 g_free(jbi->last_message);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
715 purple_notify_user_info_destroy(jbi->user_info);
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
716 g_free(jbi);
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
717 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
718
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
719 static void
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
720 add_jbr_info(JabberBuddyInfo *jbi, const char *resource,
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
721 JabberBuddyResource *jbr)
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
722 {
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
723 JabberBuddyInfoResource *jbir;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
724 PurpleNotifyUserInfo *user_info;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
725
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
726 jbir = g_hash_table_lookup(jbi->resources, resource);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
727 user_info = jbi->user_info;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
728
32202
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
729 if (jbr && jbr->client.name) {
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
730 char *tmp =
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
731 g_strdup_printf("%s%s%s", jbr->client.name,
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
732 (jbr->client.version ? " " : ""),
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
733 (jbr->client.version ? jbr->client.version : ""));
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
734 /* TODO: Check whether it's correct to call prepend_pair_html,
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
735 or if we should be using prepend_pair_plaintext */
32204
2a09624616c3 Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents: 32203
diff changeset
736 purple_notify_user_info_prepend_pair_html(user_info, _("Client"), tmp);
32202
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
737 g_free(tmp);
32196
9a50231a1573 Now that there's no speed difference between
Mark Doliner <markdoliner@pidgin.im>
parents: 32193
diff changeset
738
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
739 if (jbr->client.os) {
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
740 /* TODO: Check whether it's correct to call prepend_pair_html,
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
741 or if we should be using prepend_pair_plaintext */
32204
2a09624616c3 Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents: 32203
diff changeset
742 purple_notify_user_info_prepend_pair_html(user_info, _("Operating System"), jbr->client.os);
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
743 }
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
744 }
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
745
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
746 if (jbr && jbr->tz_off != PURPLE_NO_TZ_OFF) {
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
747 time_t now_t;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
748 struct tm *now;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
749 char *timestamp;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
750 time(&now_t);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
751 now_t += jbr->tz_off;
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
752 now = gmtime(&now_t);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
753
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
754 timestamp =
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
755 g_strdup_printf("%s %c%02d%02d", purple_time_format(now),
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
756 jbr->tz_off < 0 ? '-' : '+',
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
757 abs(jbr->tz_off / (60*60)),
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
758 abs((jbr->tz_off % (60*60)) / 60));
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
759 purple_notify_user_info_prepend_pair_plaintext(user_info, _("Local Time"), timestamp);
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
760 g_free(timestamp);
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
761 }
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
762
32202
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
763 if (jbir && jbir->idle_seconds > 0) {
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
764 char *idle = purple_str_seconds_to_string(jbir->idle_seconds);
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
765 purple_notify_user_info_prepend_pair_plaintext(user_info, _("Idle"), idle);
32202
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
766 g_free(idle);
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
767 }
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
768
32202
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
769 if (jbr) {
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
770 char *purdy = NULL;
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
771 char *tmp;
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
772 char priority[12];
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
773 const char *status_name = jabber_buddy_state_get_name(jbr->state);
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
774
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
775 if (jbr->status) {
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
776 tmp = purple_markup_escape_text(jbr->status, -1);
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
777 purdy = purple_strdup_withhtml(tmp);
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
778 g_free(tmp);
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
779
32202
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
780 if (purple_strequal(status_name, purdy))
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
781 status_name = NULL;
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
782 }
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
783
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
784 tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""),
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
785 ((status_name && purdy) ? ": " : ""),
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
786 (purdy ? purdy : ""));
32204
2a09624616c3 Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents: 32203
diff changeset
787 purple_notify_user_info_prepend_pair_html(user_info, _("Status"), tmp);
32202
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
788
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
789 g_snprintf(priority, sizeof(priority), "%d", jbr->priority);
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
790 purple_notify_user_info_prepend_pair_plaintext(user_info, _("Priority"), priority);
32202
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
791
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
792 g_free(tmp);
32202
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
793 g_free(purdy);
a3de232226e7 I tried to disapprove this, but it didn't seem to work. Maybe I
Mark Doliner <markdoliner@pidgin.im>
parents: 32200
diff changeset
794 } else {
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
795 purple_notify_user_info_prepend_pair_plaintext(user_info, _("Status"), _("Unknown"));
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
796 }
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
797 }
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
798
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
799 static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
800 {
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
801 char *resource_name;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
802 JabberBuddyResource *jbr;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
803 GList *resources;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
804 PurpleNotifyUserInfo *user_info;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
805
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
806 /* not yet */
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
807 if (jbi->ids)
11361
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
808 return;
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
809
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
810 user_info = jbi->user_info;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
811 resource_name = jabber_get_resource(jbi->jid);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
812
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
813 /* If we have one or more pairs from the vcard, put a section break above it */
32193
42173d1c1317 Change PurpleNotifyUserInfo->user_info_entries from a GList to a GQueue.
Mark Doliner <markdoliner@pidgin.im>
parents: 32191
diff changeset
814 if (g_queue_get_length(purple_notify_user_info_get_entries(user_info)))
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
815 purple_notify_user_info_prepend_section_break(user_info);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
816
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
817 /* Add the information about the user's resource(s) */
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
818 if (resource_name) {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
819 jbr = jabber_buddy_find_resource(jbi->jb, resource_name);
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
820 add_jbr_info(jbi, resource_name, jbr);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
821 } else {
29387
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
822 /* TODO: This is in priority-ascending order (lowest prio first), because
21ecdd98e791 jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents: 29385
diff changeset
823 * everything is prepended. Is that ok? */
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
824 for (resources = jbi->jb->resources; resources; resources = resources->next) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
825 jbr = resources->data;
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
826
27053
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
827 /* put a section break between resources, this is not needed if
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
828 we are at the first, because one was already added for the vcard
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
829 section */
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
830 if (resources != jbi->jb->resources)
27053
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
831 purple_notify_user_info_prepend_section_break(user_info);
fb088f01758d Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents: 26958
diff changeset
832
27550
775140c24a35 Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents: 27549
diff changeset
833 add_jbr_info(jbi, jbr->name, jbr);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
834
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
835 if (jbr->name) {
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
836 /* TODO: Check whether it's correct to call prepend_pair_html,
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
837 or if we should be using prepend_pair_plaintext */
32204
2a09624616c3 Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents: 32203
diff changeset
838 purple_notify_user_info_prepend_pair_html(user_info, _("Resource"), jbr->name);
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
839 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
840 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
841 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
842
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
843 if (!jbi->jb->resources) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
844 /* the buddy is offline */
29063
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
845 gboolean is_domain = jabber_jid_is_domain(jbi->jid);
29097
0834410aa178 Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents: 29064
diff changeset
846
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
847 if (jbi->last_seconds > 0) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
848 char *last = purple_str_seconds_to_string(jbi->last_seconds);
29063
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
849 gchar *message = NULL;
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
850 const gchar *title = NULL;
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
851 if (is_domain) {
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
852 title = _("Uptime");
29184
6218763ad5b4 This string is already translated; so it need not be translated again.
Paul Aurich <darkrain42@pidgin.im>
parents: 29097
diff changeset
853 message = last;
6218763ad5b4 This string is already translated; so it need not be translated again.
Paul Aurich <darkrain42@pidgin.im>
parents: 29097
diff changeset
854 last = NULL;
29063
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
855 } else {
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
856 title = _("Logged Off");
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
857 message = g_strdup_printf(_("%s ago"), last);
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
858 }
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
859 purple_notify_user_info_prepend_pair_plaintext(user_info, title, message);
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
860 g_free(last);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
861 g_free(message);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
862 }
29063
f245c5e9e9f3 jabber: When getting info on a "bare" domain JID, interpret the value of "last"
Marcus Lundblad <malu@pidgin.im>
parents: 28984
diff changeset
863
29097
0834410aa178 Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents: 29064
diff changeset
864 if (!is_domain) {
0834410aa178 Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents: 29064
diff changeset
865 gchar *status =
0834410aa178 Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents: 29064
diff changeset
866 g_strdup_printf("%s%s%s", _("Offline"),
0834410aa178 Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents: 29064
diff changeset
867 jbi->last_message ? ": " : "",
0834410aa178 Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents: 29064
diff changeset
868 jbi->last_message ? jbi->last_message : "");
32203
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
869 /* TODO: Check whether it's correct to call prepend_pair_html,
e7c2d37aecd5 Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents: 32202
diff changeset
870 or if we should be using prepend_pair_plaintext */
32204
2a09624616c3 Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents: 32203
diff changeset
871 purple_notify_user_info_prepend_pair_html(user_info, _("Status"), status);
29097
0834410aa178 Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents: 29064
diff changeset
872 g_free(status);
0834410aa178 Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents: 29064
diff changeset
873 }
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
874 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
875
7306
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
876 g_free(resource_name);
61d7324411f8 [gaim-migrate @ 7890]
Nathan Walp <nwalp@pidgin.im>
parents: 7250
diff changeset
877
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
878 purple_notify_userinfo(jbi->js->gc, jbi->jid, user_info, NULL, NULL);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
879
27551
4119bf954943 Style and comments
Paul Aurich <darkrain42@pidgin.im>
parents: 27550
diff changeset
880 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
881 purple_imgstore_unref_by_id(GPOINTER_TO_INT(jbi->vcard_imgids->data));
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
882 jbi->vcard_imgids = g_slist_delete_link(jbi->vcard_imgids, jbi->vcard_imgids);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
883 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
884
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
885 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
886
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
887 jabber_buddy_info_destroy(jbi);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
888 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
889
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
890 static void jabber_buddy_info_remove_id(JabberBuddyInfo *jbi, const char *id)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
891 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
892 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
893 char *comp_id;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
894
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
895 if(!id)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
896 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
897
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
898 while(l) {
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
899 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
900 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
901 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
902 g_free(comp_id);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
903 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
904 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
905 l = l->next;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
906 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
907 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
908
28046
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
909 static gboolean
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
910 set_own_vcard_cb(gpointer data)
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
911 {
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
912 JabberStream *js = data;
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
913 PurpleAccount *account = purple_connection_get_account(js->gc);
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
914
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
915 js->vcard_timer = 0;
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
916
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
917 jabber_set_info(js->gc, purple_account_get_user_info(account));
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
918
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
919 return FALSE;
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
920 }
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
921
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
922 static void jabber_vcard_save_mine(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
923 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
924 xmlnode *packet, gpointer data)
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
925 {
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
926 xmlnode *vcard, *photo, *binval;
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
927 char *txt, *vcard_hash = NULL;
28046
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
928 PurpleAccount *account;
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
929
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
930 if (type == JABBER_IQ_ERROR) {
27418
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
931 xmlnode *error;
27417
2693e524de1f Missing newline
Paul Aurich <darkrain42@pidgin.im>
parents: 27361
diff changeset
932 purple_debug_warning("jabber", "Server returned error while retrieving vCard\n");
27418
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
933
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
934 error = xmlnode_get_child(packet, "error");
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
935 if (!error || !xmlnode_get_child(error, "item-not-found"))
518044412902 If there's no vCard on the server, we have to be able to set ours. Allows bootstrapping a new account with (at least) Prosody.
Paul Aurich <darkrain42@pidgin.im>
parents: 27417
diff changeset
936 return;
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
937 }
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
938
28046
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
939 account = purple_connection_get_account(js->gc);
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
940
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
941 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
942 (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
943 {
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
944 txt = xmlnode_to_str(vcard, NULL);
28046
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
945 purple_account_set_user_info(account, txt);
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
946 g_free(txt);
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
947 } else {
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
948 /* 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
949 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
950
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
951 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
952
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
953 if (vcard && (photo = xmlnode_get_child(vcard, "PHOTO")) &&
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
954 (binval = xmlnode_get_child(photo, "BINVAL"))) {
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
955 gsize size;
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
956 char *bintext = xmlnode_get_data(binval);
28311
9c92aae99f62 jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents: 28290
diff changeset
957 if (bintext) {
9c92aae99f62 jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents: 28290
diff changeset
958 guchar *data = purple_base64_decode(bintext, &size);
9c92aae99f62 jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents: 28290
diff changeset
959 g_free(bintext);
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
960
28311
9c92aae99f62 jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents: 28290
diff changeset
961 if (data) {
29910
f1c6e586e5c1 jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents: 29849
diff changeset
962 vcard_hash = jabber_calculate_data_hash(data, size, "sha1");
28311
9c92aae99f62 jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents: 28290
diff changeset
963 g_free(data);
9c92aae99f62 jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents: 28290
diff changeset
964 }
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
965 }
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
966 }
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
967
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
968 /* Republish our vcard if the photo is different than the server's */
28881
244fb329e5df jabber: Go back to not overwriting avatars if there is not one locally set.
Paul Aurich <darkrain42@pidgin.im>
parents: 28879
diff changeset
969 if (js->initial_avatar_hash && !purple_strequal(vcard_hash, js->initial_avatar_hash)) {
28046
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
970 /*
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
971 * Google Talk has developed the behavior that it will not accept
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
972 * a vcard set in the first 10 seconds (or so) of the connection;
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
973 * it returns an error (namespaces trimmed):
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
974 * <error code="500" type="wait"><internal-server-error/></error>.
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
975 */
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
976 if (js->googletalk)
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
977 js->vcard_timer = purple_timeout_add_seconds(10, set_own_vcard_cb,
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
978 js);
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
979 else
8b6fcc2c95b3 jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents: 27998
diff changeset
980 jabber_set_info(js->gc, purple_account_get_user_info(account));
28883
b005808ee1a5 jabber: This is more correct.
Paul Aurich <darkrain42@pidgin.im>
parents: 28882
diff changeset
981 } else if (vcard_hash) {
28882
4d43dd2afadb jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents: 28881
diff changeset
982 /* A photo is in the vCard. Advertise its hash */
4d43dd2afadb jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents: 28881
diff changeset
983 js->avatar_hash = vcard_hash;
4d43dd2afadb jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents: 28881
diff changeset
984 vcard_hash = NULL;
4d43dd2afadb jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents: 28881
diff changeset
985
4d43dd2afadb jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents: 28881
diff changeset
986 /* Send presence to update vcard-temp:x:update */
4d43dd2afadb jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents: 28881
diff changeset
987 jabber_presence_send(js, FALSE);
25477
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
988 }
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
989
ada9e5c4a10a Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents: 25475
diff changeset
990 g_free(vcard_hash);
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
991 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
992
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
993 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
994 {
21957
0ce77f86c7f3 Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents: 21681
diff changeset
995 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
996
21957
0ce77f86c7f3 Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents: 21681
diff changeset
997 xmlnode *vcard = xmlnode_new_child(iq->node, "vCard");
0ce77f86c7f3 Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents: 21681
diff changeset
998 xmlnode_set_namespace(vcard, "vcard-temp");
18235
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
999 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
1000
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1001 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
1002 }
60a9bd99f035 server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents: 18196
diff changeset
1003
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1004 static void jabber_vcard_parse(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1005 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1006 xmlnode *packet, gpointer data)
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1007 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1008 char *bare_jid;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1009 char *text;
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1010 char *serverside_alias = NULL;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1011 xmlnode *vcard;
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1012 PurpleAccount *account;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1013 JabberBuddyInfo *jbi = data;
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1014 PurpleNotifyUserInfo *user_info;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1015
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1016 g_return_if_fail(jbi != NULL);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1017
14129
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
1018 jabber_buddy_info_remove_id(jbi, id);
70db31dfeeb1 [gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
1019
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1020 if (type == JABBER_IQ_ERROR) {
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1021 purple_debug_info("jabber", "Got error response for vCard\n");
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1022 jabber_buddy_info_show_if_ready(jbi);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1023 return;
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1024 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1025
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1026 user_info = jbi->user_info;
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1027 account = purple_connection_get_account(js->gc);
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1028 bare_jid = jabber_get_bare_jid(from ? from : purple_account_get_username(account));
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1029
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1030 /* TODO: Is the query xmlns='vcard-temp' version of this still necessary? */
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1031 if((vcard = xmlnode_get_child(packet, "vCard")) ||
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1032 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1033 xmlnode *child;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1034 for(child = vcard->child; child; child = child->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1035 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1036 xmlnode *child2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1037
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
1038 if(child->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1039 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1040
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1041 text = xmlnode_get_data(child);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1042 if(text && !strcmp(child->name, "FN")) {
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1043 if (!serverside_alias)
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1044 serverside_alias = g_strdup(text);
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1045
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1046 purple_notify_user_info_add_pair_plaintext(user_info, _("Full Name"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1047 } else if(!strcmp(child->name, "N")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1048 for(child2 = child->child; child2; child2 = child2->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1049 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1050 char *text2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1051
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
1052 if(child2->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1053 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1054
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1055 text2 = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1056 if(text2 && !strcmp(child2->name, "FAMILY")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1057 purple_notify_user_info_add_pair_plaintext(user_info, _("Family Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1058 } else if(text2 && !strcmp(child2->name, "GIVEN")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1059 purple_notify_user_info_add_pair_plaintext(user_info, _("Given Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1060 } else if(text2 && !strcmp(child2->name, "MIDDLE")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1061 purple_notify_user_info_add_pair_plaintext(user_info, _("Middle Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1062 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1063 g_free(text2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1064 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1065 } else if(text && !strcmp(child->name, "NICKNAME")) {
24200
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
1066 /* Prefer the Nickcname to the Full Name as the serverside alias if it's not just part of the jid.
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
1067 * Ignore it if it's part of the jid. */
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
1068 if (strstr(bare_jid, text) == NULL) {
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
1069 g_free(serverside_alias);
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
1070 serverside_alias = g_strdup(text);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1071
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1072 purple_notify_user_info_add_pair_plaintext(user_info, _("Nickname"), text);
24200
6c6870d15155 Ignore nicknames which are just the user portion of the JID, as these aren't useful. Instead, prefer the fullname in that situation for serverside alias purposes.
Evan Schoenberg <evands@pidgin.im>
parents: 24012
diff changeset
1073 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1074 } else if(text && !strcmp(child->name, "BDAY")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1075 purple_notify_user_info_add_pair_plaintext(user_info, _("Birthday"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1076 } else if(!strcmp(child->name, "ADR")) {
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1077 gboolean address_line_added = FALSE;
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1078
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1079 for(child2 = child->child; child2; child2 = child2->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1080 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1081 char *text2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1082
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
1083 if(child2->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1084 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1085
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1086 text2 = xmlnode_get_data(child2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1087 if (text2 == NULL)
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1088 continue;
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1089
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1090 /* 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
1091 * elements are empty. */
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1092 if (!address_line_added)
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1093 {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1094 purple_notify_user_info_add_section_header(user_info, _("Address"));
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1095 address_line_added = TRUE;
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1096 }
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1097
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1098 if(!strcmp(child2->name, "POBOX")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1099 purple_notify_user_info_add_pair_plaintext(user_info, _("P.O. Box"), text2);
27998
889b1fbece5b jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents: 27965
diff changeset
1100 } else if (g_str_equal(child2->name, "EXTADD") || g_str_equal(child2->name, "EXTADR")) {
889b1fbece5b jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents: 27965
diff changeset
1101 /*
889b1fbece5b jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents: 27965
diff changeset
1102 * EXTADD is correct, EXTADR is generated by other
889b1fbece5b jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents: 27965
diff changeset
1103 * clients. The next time someone reads this, remove
889b1fbece5b jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents: 27965
diff changeset
1104 * EXTADR.
889b1fbece5b jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents: 27965
diff changeset
1105 */
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1106 purple_notify_user_info_add_pair_plaintext(user_info, _("Extended Address"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1107 } else if(!strcmp(child2->name, "STREET")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1108 purple_notify_user_info_add_pair_plaintext(user_info, _("Street Address"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1109 } else if(!strcmp(child2->name, "LOCALITY")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1110 purple_notify_user_info_add_pair_plaintext(user_info, _("Locality"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1111 } else if(!strcmp(child2->name, "REGION")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1112 purple_notify_user_info_add_pair_plaintext(user_info, _("Region"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1113 } else if(!strcmp(child2->name, "PCODE")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1114 purple_notify_user_info_add_pair_plaintext(user_info, _("Postal Code"), text2);
12933
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1115 } else if(!strcmp(child2->name, "CTRY")
885970470a9b [gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents: 12919
diff changeset
1116 || !strcmp(child2->name, "COUNTRY")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1117 purple_notify_user_info_add_pair_plaintext(user_info, _("Country"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1118 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1119 g_free(text2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1120 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1121
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1122 if (address_line_added)
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1123 purple_notify_user_info_add_section_break(user_info);
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1124
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1125 } else if(!strcmp(child->name, "TEL")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1126 char *number;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1127 if((child2 = xmlnode_get_child(child, "NUMBER"))) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1128 /* show what kind of number it is */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1129 number = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1130 if(number) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1131 purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1132 g_free(number);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1133 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1134 } else if((number = xmlnode_get_data(child))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1135 /* lots of clients (including purple) do this, but it's
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1136 * out of spec */
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1137 purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1138 g_free(number);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1139 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1140 } 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
1141 char *userid, *escaped;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1142 if((child2 = xmlnode_get_child(child, "USERID"))) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1143 /* show what kind of email it is */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1144 userid = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1145 if(userid) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1146 char *mailto;
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1147 escaped = g_markup_escape_text(userid, -1);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1148 mailto = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", escaped, escaped);
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 31694
diff changeset
1149 purple_notify_user_info_add_pair_html(user_info, _("Email"), mailto);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1150
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1151 g_free(mailto);
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1152 g_free(escaped);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1153 g_free(userid);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1154 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1155 } else if((userid = xmlnode_get_data(child))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1156 /* lots of clients (including purple) do this, but it's
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1157 * out of spec */
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1158 char *mailto;
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1159
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1160 escaped = g_markup_escape_text(userid, -1);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1161 mailto = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", escaped, escaped);
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 31694
diff changeset
1162 purple_notify_user_info_add_pair_html(user_info, _("Email"), mailto);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1163
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1164 g_free(mailto);
19931
229fb62285b0 Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents: 19921
diff changeset
1165 g_free(escaped);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1166 g_free(userid);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1167 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1168 } else if(!strcmp(child->name, "ORG")) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1169 for(child2 = child->child; child2; child2 = child2->next)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1170 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1171 char *text2;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1172
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 7955
diff changeset
1173 if(child2->type != XMLNODE_TYPE_TAG)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1174 continue;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1175
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1176 text2 = xmlnode_get_data(child2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1177 if(text2 && !strcmp(child2->name, "ORGNAME")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1178 purple_notify_user_info_add_pair_plaintext(user_info, _("Organization Name"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1179 } else if(text2 && !strcmp(child2->name, "ORGUNIT")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1180 purple_notify_user_info_add_pair_plaintext(user_info, _("Organization Unit"), text2);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1181 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1182 g_free(text2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1183 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1184 } else if(text && !strcmp(child->name, "TITLE")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1185 purple_notify_user_info_add_pair_plaintext(user_info, _("Job Title"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1186 } else if(text && !strcmp(child->name, "ROLE")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1187 purple_notify_user_info_add_pair_plaintext(user_info, _("Role"), text);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1188 } else if(text && !strcmp(child->name, "DESC")) {
30537
9f833935ecd7 Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents: 29965
diff changeset
1189 purple_notify_user_info_add_pair_plaintext(user_info, _("Description"), text);
7076
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
1190 } else if(!strcmp(child->name, "PHOTO") ||
5b5d8310e599 [gaim-migrate @ 7641]
Nathan Walp <nwalp@pidgin.im>
parents: 7014
diff changeset
1191 !strcmp(child->name, "LOGO")) {
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1192 char *bintext = NULL;
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1193 xmlnode *binval;
11361
b8c9532c9ffe [gaim-migrate @ 13585]
Nathan Walp <nwalp@pidgin.im>
parents: 11318
diff changeset
1194
28611
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
1195 if ((binval = xmlnode_get_child(child, "BINVAL")) &&
156e0b180d48 jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
1196 (bintext = xmlnode_get_data(binval))) {
11127
5e539d9d26a4 [gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents: 10941
diff changeset
1197 gsize size;
11137
cf40226ddff7 [gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents: 11127
diff changeset
1198 guchar *data;
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1199 gboolean photo = (strcmp(child->name, "PHOTO") == 0);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1200
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1201 data = purple_base64_decode(bintext, &size);
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1202 if (data) {
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1203 char *img_text;
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 25109
diff changeset
1204 char *hash;
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1205
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1206 jbi->vcard_imgids = g_slist_prepend(jbi->vcard_imgids, GINT_TO_POINTER(purple_imgstore_add_with_id(g_memdup(data, size), size, "logo.png")));
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1207 img_text = g_strdup_printf("<img id='%d'>", GPOINTER_TO_INT(jbi->vcard_imgids->data));
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1208
32191
a4668d9dc8d1 Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents: 31694
diff changeset
1209 purple_notify_user_info_add_pair_html(user_info, (photo ? _("Photo") : _("Logo")), img_text);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1210
29910
f1c6e586e5c1 jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents: 29849
diff changeset
1211 hash = jabber_calculate_data_hash(data, size, "sha1");
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1212 purple_buddy_icons_set_for_user(account, bare_jid, data, size, hash);
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 25109
diff changeset
1213 g_free(hash);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1214 g_free(img_text);
16587
50de12a4b81b disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents: 16585
diff changeset
1215 }
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 25109
diff changeset
1216 g_free(bintext);
10941
7a67db0a7f43 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10687
diff changeset
1217 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1218 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1219 g_free(text);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1220 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1221 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1222
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1223 if (serverside_alias) {
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1224 PurpleBuddy *b;
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1225 /* If we found a serverside alias, set it and tell the core */
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1226 serv_got_alias(js->gc, bare_jid, serverside_alias);
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1227 b = purple_find_buddy(account, bare_jid);
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1228 if (b) {
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1229 purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", serverside_alias);
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1230 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1231
22586
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1232 g_free(serverside_alias);
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1233 }
ae2d0016b91e If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents: 22550
diff changeset
1234
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1235 g_free(bare_jid);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1236
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1237 jabber_buddy_info_show_if_ready(jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1238 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1239
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1240 static void jabber_buddy_info_resource_free(gpointer data)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1241 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1242 JabberBuddyInfoResource *jbri = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1243 g_free(jbri);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1244 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1245
28114
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1246 static guint jbir_hash(gconstpointer v)
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1247 {
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1248 if (v)
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1249 return g_str_hash(v);
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1250 else
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1251 return 0;
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1252 }
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1253
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1254 static gboolean jbir_equal(gconstpointer v1, gconstpointer v2)
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1255 {
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1256 const gchar *resource_1 = v1;
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1257 const gchar *resource_2 = v2;
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1258
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1259 return purple_strequal(resource_1, resource_2);
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1260 }
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1261
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1262 static void jabber_version_parse(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1263 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1264 xmlnode *packet, gpointer data)
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1265 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1266 JabberBuddyInfo *jbi = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1267 xmlnode *query;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1268 char *resource_name;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1269
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1270 g_return_if_fail(jbi != NULL);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1271
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1272 jabber_buddy_info_remove_id(jbi, id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1273
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1274 if(!from)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1275 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1276
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1277 resource_name = jabber_get_resource(from);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1278
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1279 if(resource_name) {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1280 if (type == JABBER_IQ_RESULT) {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1281 if((query = xmlnode_get_child(packet, "query"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1282 JabberBuddyResource *jbr = jabber_buddy_find_resource(jbi->jb, resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1283 if(jbr) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1284 xmlnode *node;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1285 if((node = xmlnode_get_child(query, "name"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1286 jbr->client.name = xmlnode_get_data(node);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1287 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1288 if((node = xmlnode_get_child(query, "version"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1289 jbr->client.version = xmlnode_get_data(node);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1290 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1291 if((node = xmlnode_get_child(query, "os"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1292 jbr->client.os = xmlnode_get_data(node);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1293 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1294 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1295 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1296 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1297 g_free(resource_name);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1298 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1299
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1300 jabber_buddy_info_show_if_ready(jbi);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1301 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1302
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1303 static void jabber_last_parse(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1304 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1305 xmlnode *packet, gpointer data)
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1306 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1307 JabberBuddyInfo *jbi = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1308 xmlnode *query;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1309 char *resource_name;
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1310 const char *seconds;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1311
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1312 g_return_if_fail(jbi != NULL);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1313
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1314 jabber_buddy_info_remove_id(jbi, id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1315
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1316 if(!from)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1317 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1318
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1319 resource_name = jabber_get_resource(from);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1320
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1321 if(resource_name) {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1322 if (type == JABBER_IQ_RESULT) {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1323 if((query = xmlnode_get_child(packet, "query"))) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1324 seconds = xmlnode_get_attrib(query, "seconds");
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1325 if(seconds) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1326 char *end = NULL;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1327 long sec = strtol(seconds, &end, 10);
27135
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1328 JabberBuddy *jb = NULL;
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1329 char *resource = NULL;
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1330 char *buddy_name = NULL;
25493
8bf093c656a5 When getting info from a buddy, update the idle status to the libpurple core
Marcus Lundblad <malu@pidgin.im>
parents: 25228
diff changeset
1331 JabberBuddyResource *jbr = NULL;
26958
a955bd42f529 propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
parents: 26764 26950
diff changeset
1332
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1333 if(end != seconds) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1334 JabberBuddyInfoResource *jbir = g_hash_table_lookup(jbi->resources, resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1335 if(jbir) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1336 jbir->idle_seconds = sec;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1337 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1338 }
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
1339 /* Update the idle time of the buddy resource, if we got it.
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
1340 This will correct the value when a server doesn't mark
27135
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1341 delayed presence and we got the presence when signing on */
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1342 jb = jabber_buddy_find(js, from, FALSE);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1343 if (jb) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1344 resource = jabber_get_resource(from);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1345 buddy_name = jabber_get_bare_jid(from);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1346 /* if the resource already has an idle time set, we
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1347 must have gotten it originally from a presence. In
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1348 this case we update it. Otherwise don't update it, to
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1349 avoid setting an idle and not getting informed about
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1350 the resource getting unidle */
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1351 if (resource && buddy_name) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1352 jbr = jabber_buddy_find_resource(jb, resource);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1353 if (jbr) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1354 if (jbr->idle) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1355 if (sec) {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1356 jbr->idle = time(NULL) - sec;
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1357 } else {
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1358 jbr->idle = 0;
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1359 }
27134
c7e25dd005c4 Fix a NULL deref if the resource has gone offline by the time we're parsing this reply.
Paul Aurich <darkrain42@pidgin.im>
parents: 27110
diff changeset
1360
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
1361 if (jbr ==
27135
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1362 jabber_buddy_find_resource(jb, NULL)) {
27155
53502d71efdd Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents: 27135
diff changeset
1363 purple_prpl_got_user_idle(js->gc->account,
27135
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1364 buddy_name, jbr->idle, jbr->idle);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1365 }
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1366 }
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1367 }
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1368 }
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1369 g_free(resource);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1370 g_free(buddy_name);
32f298815b9e This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27134
diff changeset
1371 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1372 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1373 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1374 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1375 g_free(resource_name);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1376 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1377
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1378 jabber_buddy_info_show_if_ready(jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1379 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1380
27069
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1381 static void jabber_last_offline_parse(JabberStream *js, const char *from,
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1382 JabberIqType type, const char *id,
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1383 xmlnode *packet, gpointer data)
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1384 {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1385 JabberBuddyInfo *jbi = data;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1386 xmlnode *query;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1387 const char *seconds;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1388
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1389 g_return_if_fail(jbi != NULL);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1390
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1391 jabber_buddy_info_remove_id(jbi, id);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1392
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1393 if (type == JABBER_IQ_RESULT) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1394 if((query = xmlnode_get_child(packet, "query"))) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1395 seconds = xmlnode_get_attrib(query, "seconds");
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1396 if(seconds) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1397 char *end = NULL;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1398 long sec = strtol(seconds, &end, 10);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1399 if(end != seconds) {
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1400 jbi->last_seconds = sec;
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1401 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1402 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1403 jbi->last_message = xmlnode_get_data(query);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1404 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1405 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1406
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1407 jabber_buddy_info_show_if_ready(jbi);
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1408 }
8eabf79a99fe Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents: 27053
diff changeset
1409
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1410 static void jabber_time_parse(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1411 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1412 xmlnode *packet, gpointer data)
25822
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1413 {
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1414 JabberBuddyInfo *jbi = data;
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1415 JabberBuddyResource *jbr;
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1416 char *resource_name;
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1417
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1418 g_return_if_fail(jbi != NULL);
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1419
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1420 jabber_buddy_info_remove_id(jbi, id);
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1421
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1422 if (!from)
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1423 return;
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1424
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1425 resource_name = jabber_get_resource(from);
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1426 jbr = resource_name ? jabber_buddy_find_resource(jbi->jb, resource_name) : NULL;
25827
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1427 g_free(resource_name);
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1428 if (jbr) {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1429 if (type == JABBER_IQ_RESULT) {
25822
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1430 xmlnode *time = xmlnode_get_child(packet, "time");
25823
f17d4d5e59b4 Actually display the buddy's local time.
Paul Aurich <darkrain42@pidgin.im>
parents: 25822
diff changeset
1431 xmlnode *tzo = time ? xmlnode_get_child(time, "tzo") : NULL;
25827
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1432 char *tzo_data = tzo ? xmlnode_get_data(tzo) : NULL;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1433 if (tzo_data) {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1434 char *c = tzo_data;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1435 int hours, minutes;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1436 if (tzo_data[0] == 'Z' && tzo_data[1] == '\0') {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1437 jbr->tz_off = 0;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1438 } else {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1439 gboolean offset_positive = (tzo_data[0] == '+');
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1440 /* [+-]HH:MM */
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1441 if (((*c == '+' || *c == '-') && (c = c + 1)) &&
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1442 sscanf(c, "%02d:%02d", &hours, &minutes) == 2) {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1443 jbr->tz_off = 60*60*hours + 60*minutes;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1444 if (!offset_positive)
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1445 jbr->tz_off *= -1;
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1446 } else {
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1447 purple_debug_info("jabber", "Ignoring malformed timezone %s",
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1448 tzo_data);
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1449 }
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1450 }
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1451
6adc5c7df7ae Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25825
diff changeset
1452 g_free(tzo_data);
25822
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1453 }
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1454 }
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1455 }
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1456
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1457 jabber_buddy_info_show_if_ready(jbi);
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1458 }
23f62dd4aed5 Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents: 25454
diff changeset
1459
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1460 void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js)
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1461 {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1462 if (js->pending_buddy_info_requests)
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1463 {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1464 JabberBuddyInfo *jbi;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1465 GSList *l = js->pending_buddy_info_requests;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1466 while (l) {
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1467 jbi = l->data;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1468
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1469 g_slist_free(jbi->ids);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1470 jabber_buddy_info_destroy(jbi);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1471
15727
0754583ceeae Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents: 15688
diff changeset
1472 l = l->next;
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1473 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1474
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1475 g_slist_free(js->pending_buddy_info_requests);
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1476 js->pending_buddy_info_requests = NULL;
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1477 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1478 }
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1479
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1480 static gboolean jabber_buddy_get_info_timeout(gpointer data)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1481 {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1482 JabberBuddyInfo *jbi = data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1483
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1484 /* remove the pending callbacks */
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1485 while(jbi->ids) {
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1486 char *id = jbi->ids->data;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1487 jabber_iq_remove_callback_by_id(jbi->js, id);
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1488 jbi->ids = g_slist_remove(jbi->ids, id);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1489 g_free(id);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1490 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1491
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1492 jbi->js->pending_buddy_info_requests = g_slist_remove(jbi->js->pending_buddy_info_requests, jbi);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1493 jbi->timeout_handle = 0;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1494
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1495 jabber_buddy_info_show_if_ready(jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1496
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1497 return FALSE;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1498 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1499
17029
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1500 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
1501 {
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1502 /* 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
1503 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
1504 return FALSE;
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1505
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28883
diff changeset
1506 if(!strcmp(ns, NS_LAST_ACTIVITY)) {
17029
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1507 if(!strcmp(jbr->client.name, "Trillian")) {
20350
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1508 /* verified by nwalp 2007/05/09 */
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1509 if(!strcmp(jbr->client.version, "3.1.0.121") ||
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1510 /* verified by nwalp 2007/09/19 */
ae3f3561e698 another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents: 20320
diff changeset
1511 !strcmp(jbr->client.version, "3.1.7.0")) {
17029
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1512 return TRUE;
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1513 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1514 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1515 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1516
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1517 return FALSE;
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1518 }
dea59a003028 gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents: 17007
diff changeset
1519
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1520 static void
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1521 dispatch_queries_for_resource(JabberStream *js, JabberBuddyInfo *jbi,
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1522 gboolean is_bare_jid, const char *jid,
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1523 JabberBuddyResource *jbr)
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1524 {
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1525 JabberIq *iq;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1526 JabberBuddyInfoResource *jbir;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1527 char *full_jid = NULL;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1528 const char *to;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1529
28114
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1530 if (is_bare_jid && jbr->name) {
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1531 full_jid = g_strdup_printf("%s/%s", jid, jbr->name);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1532 to = full_jid;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1533 } else
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1534 to = jid;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1535
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1536 jbir = g_new0(JabberBuddyInfoResource, 1);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1537 g_hash_table_insert(jbi->resources, g_strdup(jbr->name), jbir);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1538
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1539 if(!jbr->client.name) {
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1540 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:version");
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1541 xmlnode_set_attrib(iq->node, "to", to);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1542 jabber_iq_set_callback(iq, jabber_version_parse, jbi);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1543 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1544 jabber_iq_send(iq);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1545 }
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1546
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1547 /* this is to fix the feeling of irritation I get when trying
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1548 * to get info on a friend running Trillian, which doesn't
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1549 * respond (with an error or otherwise) to jabber:iq:last
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1550 * requests. There are a number of Trillian users in my
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1551 * office. */
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28883
diff changeset
1552 if(!_client_is_blacklisted(jbr, NS_LAST_ACTIVITY)) {
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28883
diff changeset
1553 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_LAST_ACTIVITY);
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1554 xmlnode_set_attrib(iq->node, "to", to);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1555 jabber_iq_set_callback(iq, jabber_last_parse, jbi);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1556 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1557 jabber_iq_send(iq);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1558 }
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1559
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1560 if (jbr->tz_off == PURPLE_NO_TZ_OFF &&
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1561 (!jbr->caps.info ||
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28883
diff changeset
1562 jabber_resource_has_capability(jbr, NS_ENTITY_TIME))) {
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1563 xmlnode *child;
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1564 iq = jabber_iq_new(js, JABBER_IQ_GET);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1565 xmlnode_set_attrib(iq->node, "to", to);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1566 child = xmlnode_new_child(iq->node, "time");
28984
1d84517d56eb jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents: 28883
diff changeset
1567 xmlnode_set_namespace(child, NS_ENTITY_TIME);
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1568 jabber_iq_set_callback(iq, jabber_time_parse, jbi);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1569 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1570 jabber_iq_send(iq);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1571 }
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1572
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1573 g_free(full_jid);
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1574 }
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1575
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1576 static void jabber_buddy_get_info_for_jid(JabberStream *js, const char *jid)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1577 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1578 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1579 xmlnode *vcard;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1580 GList *resources;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1581 JabberBuddy *jb;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1582 JabberBuddyInfo *jbi;
27485
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1583 const char *slash;
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1584 gboolean is_bare_jid;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1585
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1586 jb = jabber_buddy_find(js, jid, TRUE);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1587
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1588 /* invalid JID */
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1589 if(!jb)
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1590 return;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1591
27485
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1592 slash = strchr(jid, '/');
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1593 is_bare_jid = (slash == NULL);
27484
9bbc40783bbb Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents: 27418
diff changeset
1594
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1595 jbi = g_new0(JabberBuddyInfo, 1);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1596 jbi->jid = g_strdup(jid);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1597 jbi->js = js;
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1598 jbi->jb = jb;
28114
091771455e05 jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents: 28071
diff changeset
1599 jbi->resources = g_hash_table_new_full(jbir_hash, jbir_equal, g_free, jabber_buddy_info_resource_free);
23347
4b62b4732afd Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents: 23325
diff changeset
1600 jbi->user_info = purple_notify_user_info_new();
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1601
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1602 iq = jabber_iq_new(js, JABBER_IQ_GET);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1603
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1604 xmlnode_set_attrib(iq->node, "to", jid);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1605 vcard = xmlnode_new_child(iq->node, "vCard");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13794
diff changeset
1606 xmlnode_set_namespace(vcard, "vcard-temp");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1607
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1608 jabber_iq_set_callback(iq, jabber_vcard_parse, jbi);
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1609 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1610
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1611 jabber_iq_send(iq);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1612
27485
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1613 if (is_bare_jid) {
29368
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1614 if (jb->resources) {
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1615 for(resources = jb->resources; resources; resources = resources->next) {
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1616 JabberBuddyResource *jbr = resources->data;
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1617 dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr);
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1618 }
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1619 } else {
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1620 /* user is offline, send a jabber:iq:last to find out last time online */
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1621 iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_LAST_ACTIVITY);
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1622 xmlnode_set_attrib(iq->node, "to", jid);
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1623 jabber_iq_set_callback(iq, jabber_last_offline_parse, jbi);
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1624 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
22b6cd68c156 jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents: 29184
diff changeset
1625 jabber_iq_send(iq);
27485
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1626 }
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1627 } else {
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1628 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, slash + 1);
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1629 if (jbr)
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1630 dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr);
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1631 else
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1632 purple_debug_warning("jabber", "jabber_buddy_get_info_for_jid() "
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1633 "was passed JID %s, but there is no corresponding "
9c49a24cec27 If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Paul Aurich <darkrain42@pidgin.im>
parents: 27484
diff changeset
1634 "JabberBuddyResource!\n", jid);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1635 }
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
1636
15363
f6b9d1e3d0cb [gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents: 15273
diff changeset
1637 js->pending_buddy_info_requests = g_slist_prepend(js->pending_buddy_info_requests, jbi);
25716
1b5be208d5ba applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents: 25575
diff changeset
1638 jbi->timeout_handle = purple_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1639 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1640
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1641 void jabber_buddy_get_info(PurpleConnection *gc, const char *who)
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1642 {
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1643 JabberStream *js = purple_connection_get_protocol_data(gc);
24829
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1644 JabberID *jid = jabber_id_new(who);
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1645
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1646 if (!jid)
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1647 return;
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1648
25575
9fbf7bf38146 A JID can have no node (the part before the @), but a chat must have one,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25454
diff changeset
1649 if (jid->node && jabber_chat_find(js, jid->node, jid->domain)) {
24829
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1650 /* For a conversation, include the resource (indicates the user). */
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1651 jabber_buddy_get_info_for_jid(js, who);
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1652 } else {
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1653 char *bare_jid = jabber_get_bare_jid(who);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1654 jabber_buddy_get_info_for_jid(js, bare_jid);
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1655 g_free(bare_jid);
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1656 }
24829
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1657
7f33c1a6ab97 Don't try to get info for MUC's. Allow getting info for regular JID's and
Paul Aurich <darkrain42@pidgin.im>
parents: 24827
diff changeset
1658 jabber_id_free(jid);
10189
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1659 }
bc7691fee058 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1660
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1661 static void jabber_buddy_set_invisibility(JabberStream *js, const char *who,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1662 gboolean invisible)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1663 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1664 PurplePresence *gpresence;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1665 PurpleAccount *account;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1666 PurpleStatus *status;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1667 JabberBuddy *jb = jabber_buddy_find(js, who, TRUE);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1668 xmlnode *presence;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1669 JabberBuddyState state;
14525
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1670 char *msg;
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1671 int priority;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1672
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1673 account = purple_connection_get_account(js->gc);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1674 gpresence = purple_account_get_presence(account);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1675 status = purple_presence_get_active_status(gpresence);
9944
71ef020ec4b0 [gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents: 9797
diff changeset
1676
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1677 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
1678 presence = jabber_presence_create_js(js, state, msg, priority);
9954
52a14a58a33e [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
1679
14525
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1680 g_free(msg);
b278a2724686 [gaim-migrate @ 17177]
Nathan Walp <nwalp@pidgin.im>
parents: 14254
diff changeset
1681
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1682 xmlnode_set_attrib(presence, "to", who);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1683 if(invisible) {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1684 xmlnode_set_attrib(presence, "type", "invisible");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1685 jb->invisible |= JABBER_INVIS_BUDDY;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1686 } else {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1687 jb->invisible &= ~JABBER_INVIS_BUDDY;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1688 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1689
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1690 jabber_send(js, presence);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1691 xmlnode_free(presence);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1692 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1693
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1694 static void jabber_buddy_make_invisible(PurpleBlistNode *node, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1695 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1696 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1697 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1698 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1699
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1700 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1701
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1702 buddy = (PurpleBuddy *) node;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1703 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1704 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1705
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1706 jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), TRUE);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1707 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1708
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1709 static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1710 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1711 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1712 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1713 JabberStream *js;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1714
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1715 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1716
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1717 buddy = (PurpleBuddy *) node;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1718 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1719 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1720
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1721 jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), FALSE);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1722 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1723
28058
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1724 static void cancel_presence_notification(gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1725 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1726 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1727 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1728 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1729
28058
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1730 buddy = data;
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1731 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1732 js = purple_connection_get_protocol_data(gc);
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1733
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1734 jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribed");
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1735 }
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1736
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1737 static void
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1738 jabber_buddy_cancel_presence_notification(PurpleBlistNode *node,
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1739 gpointer data)
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1740 {
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1741 PurpleBuddy *buddy;
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1742 PurpleAccount *account;
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1743 PurpleConnection *gc;
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1744 const gchar *name;
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1745 char *msg;
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1746
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1747 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1748
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1749 buddy = (PurpleBuddy *) node;
28058
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1750 name = purple_buddy_get_name(buddy);
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1751 account = purple_buddy_get_account(buddy);
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1752 gc = purple_account_get_connection(account);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1753
28058
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1754 msg = g_strdup_printf(_("%s will no longer be able to see your status "
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1755 "updates. Do you want to continue?"), name);
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1756 purple_request_yes_no(gc, NULL, _("Cancel Presence Notification"),
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1757 msg, 0 /* Yes */, account, name, NULL, buddy,
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1758 cancel_presence_notification, NULL /* Do nothing */);
52eb7bf6e375 jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1759 g_free(msg);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1760 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1761
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1762 static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data)
7250
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1763 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1764 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1765 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1766 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1767
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1768 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
7250
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1769
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1770 buddy = (PurpleBuddy *) node;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1771 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1772 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1773
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1774 jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "subscribe");
7250
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1775 }
7e10382fbf49 [gaim-migrate @ 7827]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
1776
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1777
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1778 static void jabber_buddy_unsubscribe(PurpleBlistNode *node, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1779 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1780 PurpleBuddy *buddy;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1781 PurpleConnection *gc;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1782 JabberStream *js;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1783
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1784 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1785
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1786 buddy = (PurpleBuddy *) node;
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1787 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1788 js = purple_connection_get_protocol_data(gc);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1789
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1790 jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribe");
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1791 }
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1792
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1793 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
1794 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
1795 /* 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
1796 PurpleBuddy *buddy = (PurpleBuddy *) node;
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1797 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1798 JabberStream *js = purple_connection_get_protocol_data(gc);
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1799 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
1800 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
1801 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
1802 xmlnode *presence;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1803 JabberBuddyState state;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1804 char *msg;
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1805 int priority;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1806
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1807 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
1808 presence = jabber_presence_create_js(js, state, msg, priority);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1809
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1810 g_free(msg);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1811
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1812 xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy));
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1813
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1814 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
1815 xmlnode_free(presence);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1816 }
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1817 }
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1818
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1819 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
1820 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
1821 /* 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
1822 PurpleBuddy *buddy = (PurpleBuddy *) node;
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1823 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1824 JabberStream *js = purple_connection_get_protocol_data(gc);
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1825 xmlnode *presence;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1826
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1827 presence = jabber_presence_create_js(js, JABBER_BUDDY_STATE_UNAVAILABLE, NULL, 0);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1828
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1829 xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy));
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1830
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1831 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
1832 xmlnode_free(presence);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1833 }
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1834 }
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1835
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1836 static GList *jabber_buddy_menu(PurpleBuddy *buddy)
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1837 {
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1838 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
1839 JabberStream *js = purple_connection_get_protocol_data(gc);
24398
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1840 const char *name = purple_buddy_get_name(buddy);
4865c2ee6ea8 Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 24251
diff changeset
1841 JabberBuddy *jb = jabber_buddy_find(js, 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
1842 GList *jbrs;
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1843
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1844 GList *m = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1845 PurpleMenuAction *act;
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1846
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1847 if(!jb)
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1848 return m;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7306
diff changeset
1849
29849
d7b910200dc5 jabber: Treat the version properly.
Paul Aurich <darkrain42@pidgin.im>
parents: 29811
diff changeset
1850 if (js->protocol_version.major == 0 && js->protocol_version.minor == 9 &&
d7b910200dc5 jabber: Treat the version properly.
Paul Aurich <darkrain42@pidgin.im>
parents: 29811
diff changeset
1851 jb != js->user_jb) {
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1852 if(jb->invisible & JABBER_INVIS_BUDDY) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1853 act = purple_menu_action_new(_("Un-hide From"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1854 PURPLE_CALLBACK(jabber_buddy_make_visible),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1855 NULL, NULL);
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1856 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1857 act = purple_menu_action_new(_("Temporarily Hide From"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1858 PURPLE_CALLBACK(jabber_buddy_make_invisible),
13019
71d729443516 [gaim-migrate @ 15372]
Etan Reisner <deryni@pidgin.im>
parents: 12933
diff changeset
1859 NULL, NULL);
8166
0a109d9655c7 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1860 }
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1861 m = g_list_append(m, act);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1862 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1863
28071
a0706162fefd jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1864 if(jb->subscription & JABBER_SUB_FROM && jb != js->user_jb) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1865 act = purple_menu_action_new(_("Cancel Presence Notification"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1866 PURPLE_CALLBACK(jabber_buddy_cancel_presence_notification),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1867 NULL, NULL);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1868 m = g_list_append(m, act);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1869 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1870
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1871 if(!(jb->subscription & JABBER_SUB_TO)) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1872 act = purple_menu_action_new(_("(Re-)Request authorization"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1873 PURPLE_CALLBACK(jabber_buddy_rerequest_auth),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1874 NULL, NULL);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1875 m = g_list_append(m, act);
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1876
28071
a0706162fefd jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents: 28046
diff changeset
1877 } else if (jb != js->user_jb) {
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1878
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1879 /* shouldn't this just happen automatically when the buddy is
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1880 removed? */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1881 act = purple_menu_action_new(_("Unsubscribe"),
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1882 PURPLE_CALLBACK(jabber_buddy_unsubscribe),
12919
519199cca273 [gaim-migrate @ 15272]
Etan Reisner <deryni@pidgin.im>
parents: 12683
diff changeset
1883 NULL, NULL);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1884 m = g_list_append(m, act);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1885 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1886
28667
7bab19738f5e jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents: 28611
diff changeset
1887 if (js->googletalk) {
7bab19738f5e jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents: 28611
diff changeset
1888 act = purple_menu_action_new(_("Initiate _Chat"),
7bab19738f5e jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents: 28611
diff changeset
1889 PURPLE_CALLBACK(google_buddy_node_chat),
7bab19738f5e jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents: 28611
diff changeset
1890 NULL, NULL);
7bab19738f5e jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents: 28611
diff changeset
1891 m = g_list_append(m, act);
7bab19738f5e jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents: 28611
diff changeset
1892 }
7bab19738f5e jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents: 28611
diff changeset
1893
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1894 /*
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1895 * 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
1896 *
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1897 * 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
1898 * 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
1899 * 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
1900 * people don't tend to have a server or other service there.
29059
8225f2507058 strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
1901 *
8225f2507058 strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
1902 * TODO: Use disco#info...
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1903 */
29059
8225f2507058 strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents: 28984
diff changeset
1904 if (strchr(name, '@') == NULL) {
17808
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1905 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
1906 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
1907 NULL, NULL);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1908 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
1909 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
1910 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
1911 NULL, NULL);
9b9a78bf9a03 Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents: 17807
diff changeset
1912 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
1913 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25911
diff changeset
1914
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
1915 /* 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
1916 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
1917 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
1918 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
1919 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
1920 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
1921 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
1922 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
1923 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
1924 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
1925 }
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
1926 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1927
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1928 return m;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1929 }
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1930
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1931 GList *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1932 jabber_blist_node_menu(PurpleBlistNode *node)
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1933 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1934 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1935 return jabber_buddy_menu((PurpleBuddy *) node);
9030
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1936 } else {
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1937 return NULL;
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1938 }
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1939 }
7b574a641391 [gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents: 9015
diff changeset
1940
12683
9ff688ee3fec [gaim-migrate @ 15026]
Nathan Walp <nwalp@pidgin.im>
parents: 12633
diff changeset
1941
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1942 static void user_search_result_add_buddy_cb(PurpleConnection *gc, GList *row, void *user_data)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1943 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1944 /* XXX find out the jid */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1945 purple_blist_request_add_buddy(purple_connection_get_account(gc),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1946 g_list_nth_data(row, 0), NULL, NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1947 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1948
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1949 static void user_search_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1950 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
1951 xmlnode *packet, gpointer data)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1952 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1953 PurpleNotifySearchResults *results;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1954 PurpleNotifySearchColumn *column;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1955 xmlnode *x, *query, *item, *field;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1956
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1957 /* XXX error checking? */
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1958 if(!(query = xmlnode_get_child(packet, "query")))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1959 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1960
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1961 results = purple_notify_searchresults_new();
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1962 if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1963 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
1964 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
1965
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1966 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
1967
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1968 if((reported = xmlnode_get_child(x, "reported"))) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1969 xmlnode *field = xmlnode_get_child(reported, "field");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1970 while(field) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1971 const char *var = xmlnode_get_attrib(field, "var");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1972 const char *label = xmlnode_get_attrib(field, "label");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1973 if(var) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1974 column = purple_notify_searchresults_column_new(label ? label : var);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
1975 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
1976 column_vars = g_slist_append(column_vars, (char *)var);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1977 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1978 field = xmlnode_get_next_twin(field);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1979 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1980 }
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1981
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1982 item = xmlnode_get_child(x, "item");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1983 while(item) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
1984 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
1985 GSList *l;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1986 xmlnode *valuenode;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1987 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
1988
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1989 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
1990 /*
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1991 * 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
1992 * 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
1993 */
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1994 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
1995 field != NULL;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1996 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
1997 {
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
1998 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
1999 !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
2000 (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
2001 {
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2002 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
2003 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
2004 break;
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2005 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2006 }
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2007 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
2008 /* 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
2009 row = g_list_append(row, NULL);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2010 }
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2011 purple_notify_searchresults_row_add(results, row);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2012 item = xmlnode_get_next_twin(item);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2013 }
19963
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2014
46f23859d166 Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents: 19931
diff changeset
2015 g_slist_free(column_vars);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2016 } else {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2017 /* old skool */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2018 purple_debug_info("jabber", "old-skool\n");
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2019
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2020 column = purple_notify_searchresults_column_new(_("JID"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2021 purple_notify_searchresults_column_add(results, column);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2022 column = purple_notify_searchresults_column_new(_("First Name"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2023 purple_notify_searchresults_column_add(results, column);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2024 column = purple_notify_searchresults_column_new(_("Last Name"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2025 purple_notify_searchresults_column_add(results, column);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2026 column = purple_notify_searchresults_column_new(_("Nickname"));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2027 purple_notify_searchresults_column_add(results, column);
23325
a374a26fe217 Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents: 23026
diff changeset
2028 column = purple_notify_searchresults_column_new(_("Email"));
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2029 purple_notify_searchresults_column_add(results, column);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2030
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2031 for(item = xmlnode_get_child(query, "item"); item; item = xmlnode_get_next_twin(item)) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2032 const char *jid;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2033 xmlnode *node;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2034 GList *row = NULL;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2035
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2036 if(!(jid = xmlnode_get_attrib(item, "jid")))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2037 continue;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2038
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2039 row = g_list_append(row, g_strdup(jid));
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2040 node = xmlnode_get_child(item, "first");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2041 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2042 node = xmlnode_get_child(item, "last");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2043 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2044 node = xmlnode_get_child(item, "nick");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2045 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2046 node = xmlnode_get_child(item, "email");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2047 row = g_list_append(row, node ? xmlnode_get_data(node) : NULL);
22622
1ecb840b5101 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents: 22586
diff changeset
2048 purple_debug_info("jabber", "row=%p\n", row);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2049 purple_notify_searchresults_row_add(results, row);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2050 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2051 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2052
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2053 purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD,
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2054 user_search_result_add_buddy_cb);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2055
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2056 purple_notify_searchresults(js->gc, NULL, NULL, _("The following are the results of your search"), results, NULL, NULL);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2057 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2058
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2059 static void user_search_x_data_cb(JabberStream *js, xmlnode *result, gpointer data)
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2060 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2061 xmlnode *query;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2062 JabberIq *iq;
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2063 char *dir_server = data;
21388
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2064 const char *type;
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2065
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2066 /* if they've cancelled the search, we're
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2067 * just going to get an error if we send
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2068 * a cancel, so skip it */
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2069 type = xmlnode_get_attrib(result, "type");
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2070 if(type && !strcmp(type, "cancel")) {
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2071 g_free(dir_server);
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2072 return;
108195e86aa3 don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents: 21381
diff changeset
2073 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2074
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2075 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2076 query = xmlnode_get_child(iq->node, "query");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2077
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2078 xmlnode_insert_child(query, result);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2079
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2080 jabber_iq_set_callback(iq, user_search_result_cb, NULL);
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2081 xmlnode_set_attrib(iq->node, "to", dir_server);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2082 jabber_iq_send(iq);
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2083 g_free(dir_server);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2084 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2085
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2086 struct user_search_info {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2087 JabberStream *js;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2088 char *directory_server;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2089 };
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2090
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2091 static void user_search_cancel_cb(struct user_search_info *usi, PurpleRequestFields *fields)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2092 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2093 g_free(usi->directory_server);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2094 g_free(usi);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2095 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2096
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2097 static void user_search_cb(struct user_search_info *usi, PurpleRequestFields *fields)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2098 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2099 JabberStream *js = usi->js;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2100 JabberIq *iq;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2101 xmlnode *query;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2102 GList *groups, *flds;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2103
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2104 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2105 query = xmlnode_get_child(iq->node, "query");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2106
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2107 for(groups = purple_request_fields_get_groups(fields); groups; groups = groups->next) {
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2108 for(flds = purple_request_field_group_get_fields(groups->data);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2109 flds; flds = flds->next) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2110 PurpleRequestField *field = flds->data;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2111 const char *id = purple_request_field_get_id(field);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2112 const char *value = purple_request_field_string_get_value(field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2113
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2114 if(value && (!strcmp(id, "first") || !strcmp(id, "last") || !strcmp(id, "nick") || !strcmp(id, "email"))) {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2115 xmlnode *y = xmlnode_new_child(query, id);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2116 xmlnode_insert_data(y, value, -1);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2117 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2118 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2119 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2120
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2121 jabber_iq_set_callback(iq, user_search_result_cb, NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2122 xmlnode_set_attrib(iq->node, "to", usi->directory_server);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2123 jabber_iq_send(iq);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2124
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2125 g_free(usi->directory_server);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2126 g_free(usi);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2127 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2128
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2129 #if 0
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2130 /* 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
2131
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2132 /*
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2133 * 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
2134 * comments for Jabber User Directories
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2135 *
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2136 * See discussion thread "Search comment for Jabber is not translatable"
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2137 * 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
2138 */
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2139 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
2140 /* 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
2141 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
2142 "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
2143 NULL
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2144 };
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2145 #endif
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2146
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2147 static void user_search_fields_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2148 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2149 xmlnode *packet, gpointer data)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2150 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2151 xmlnode *query, *x;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2152
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2153 if (!from)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2154 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2155
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26088
diff changeset
2156 if (type == JABBER_IQ_ERROR) {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20350
diff changeset
2157 char *msg = jabber_parse_error(js, packet, NULL);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2158
13634
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2159 if(!msg)
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2160 msg = g_strdup(_("Unknown error"));
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2161
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2162 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
2163 _("Could not query the directory server."), msg);
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2164 g_free(msg);
e9f9cef982d7 [gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13619
diff changeset
2165
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2166 return;
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2167 }
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2168
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2169
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2170 if(!(query = xmlnode_get_child(packet, "query")))
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2171 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2172
13330
33fb51d94dfd [gaim-migrate @ 15699]
Nathan Walp <nwalp@pidgin.im>
parents: 13019
diff changeset
2173 if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) {
13345
5c3833c02134 [gaim-migrate @ 15714]
Nathan Walp <nwalp@pidgin.im>
parents: 13332
diff changeset
2174 jabber_x_data_request(js, x, user_search_x_data_cb, g_strdup(from));
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2175 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2176 } else {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2177 struct user_search_info *usi;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2178 xmlnode *instnode;
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2179 char *instructions = NULL;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2180 PurpleRequestFields *fields;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2181 PurpleRequestFieldGroup *group;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2182 PurpleRequestField *field;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2183
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2184 /* old skool */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2185 fields = purple_request_fields_new();
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2186 group = purple_request_field_group_new(NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2187 purple_request_fields_add_group(fields, group);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2188
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2189 if((instnode = xmlnode_get_child(query, "instructions")))
13574
433001d94e3e [gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents: 13572
diff changeset
2190 {
433001d94e3e [gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents: 13572
diff changeset
2191 char *tmp = xmlnode_get_data(instnode);
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2192
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2193 if(tmp)
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2194 {
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2195 /* 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
2196 list in jabber_user_dir_comments[]) */
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2197 instructions = g_strdup_printf(_("Server Instructions: %s"), _(tmp));
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2198 g_free(tmp);
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2199 }
13574
433001d94e3e [gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents: 13572
diff changeset
2200 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2201
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2202 if(!instructions)
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2203 {
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2204 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
2205 "for any matching XMPP users."));
13617
983b0c58fcae [gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13574
diff changeset
2206 }
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2207
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2208 if(xmlnode_get_child(query, "first")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2209 field = purple_request_field_string_new("first", _("First Name"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2210 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2211 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2212 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2213 if(xmlnode_get_child(query, "last")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2214 field = purple_request_field_string_new("last", _("Last Name"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2215 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2216 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2217 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2218 if(xmlnode_get_child(query, "nick")) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2219 field = purple_request_field_string_new("nick", _("Nickname"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2220 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2221 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2222 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2223 if(xmlnode_get_child(query, "email")) {
23325
a374a26fe217 Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents: 23026
diff changeset
2224 field = purple_request_field_string_new("email", _("Email Address"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2225 NULL, FALSE);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2226 purple_request_field_group_add_field(group, field);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2227 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2228
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2229 usi = g_new0(struct user_search_info, 1);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2230 usi->js = js;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2231 usi->directory_server = g_strdup(from);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2232
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2233 purple_request_fields(js->gc, _("Search for XMPP users"),
16961
b6955f946f8f s/Jabber/XMPP in user-visible places.
Richard Laager <rlaager@pidgin.im>
parents: 16799
diff changeset
2234 _("Search for XMPP users"), instructions, fields,
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2235 _("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
2236 _("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
2237 purple_connection_get_account(js->gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2238 usi);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2239
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2240 g_free(instructions);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2241 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2242 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2243
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
2244 void jabber_user_search(JabberStream *js, const char *directory)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2245 {
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2246 JabberIq *iq;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2247
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2248 /* XXX: should probably better validate the directory we're given */
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2249 if(!directory || !*directory) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2250 purple_notify_error(js->gc, _("Invalid Directory"), _("Invalid Directory"), NULL);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2251 return;
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2252 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2253
31660
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2254 /* If the value provided isn't the disco#info default, persist it. Otherwise,
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2255 make sure we aren't persisting an old value */
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2256 if(js->user_directories && js->user_directories->data &&
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2257 !strcmp(directory, js->user_directories->data)) {
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2258 purple_account_set_string(js->gc->account, "user_directory", "");
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2259 }
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2260 else {
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2261 purple_account_set_string(js->gc->account, "user_directory", directory);
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2262 }
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2263
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2264 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:search");
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2265 xmlnode_set_attrib(iq->node, "to", directory);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2266
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2267 jabber_iq_set_callback(iq, user_search_fields_result_cb, NULL);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2268
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2269 jabber_iq_send(iq);
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2270 }
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2271
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2272 void jabber_user_search_begin(PurplePluginAction *action)
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2273 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15727
diff changeset
2274 PurpleConnection *gc = (PurpleConnection *) action->context;
24942
ec72b773a9da More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents: 24251
diff changeset
2275 JabberStream *js = purple_connection_get_protocol_data(gc);
31660
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2276 const char *def_val = purple_account_get_string(js->gc->account, "user_directory", "");
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2277 if(!*def_val && js->user_directories)
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2278 def_val = js->user_directories->data;
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2279
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2280 purple_request_input(gc, _("Enter a User Directory"), _("Enter a User Directory"),
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2281 _("Select a user directory to search"),
31660
fd970a73f5ff jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents: 31318
diff changeset
2282 def_val,
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2283 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
2284 _("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
2285 _("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
2286 NULL, NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
2287 js);
11675
0eae965a9098 [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11540
diff changeset
2288 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2289
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2290 gboolean
28879
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28828
diff changeset
2291 jabber_resource_know_capabilities(const JabberBuddyResource *jbr)
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28828
diff changeset
2292 {
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28828
diff changeset
2293 return jbr->caps.info != NULL;
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28828
diff changeset
2294 }
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28828
diff changeset
2295
27cc8217e86e jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents: 28828
diff changeset
2296 gboolean
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2297 jabber_resource_has_capability(const JabberBuddyResource *jbr, const gchar *cap)
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2298 {
24802
eb481e98ac6a Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
2299 const GList *node = NULL;
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2300 const JabberCapsNodeExts *exts;
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2301
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2302 if (!jbr->caps.info) {
27696
2cd9b9331f06 Lower the severity of this message.
Paul Aurich <darkrain42@pidgin.im>
parents: 27619
diff changeset
2303 purple_debug_info("jabber",
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2304 "Unable to find caps: nothing known about buddy\n");
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2305 return FALSE;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2306 }
13794
7264393a2349 [gaim-migrate @ 16204]
Nathan Walp <nwalp@pidgin.im>
parents: 13787
diff changeset
2307
24880
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2308 node = g_list_find_custom(jbr->caps.info->features, cap, (GCompareFunc)strcmp);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2309 if (!node && jbr->caps.exts && jbr->caps.info->exts) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2310 const GList *ext;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2311 exts = jbr->caps.info->exts;
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2312 /* Walk through all the enabled caps, checking each list for the cap.
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2313 * Don't check it twice, though. */
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2314 for (ext = jbr->caps.exts; ext && !node; ext = ext->next) {
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2315 GList *features = g_hash_table_lookup(exts->exts, ext->data);
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2316 if (features)
ae4e8598d0bf Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents: 24878
diff changeset
2317 node = g_list_find_custom(features, cap, (GCompareFunc)strcmp);
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2318 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2319 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2320
24802
eb481e98ac6a Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents: 24732
diff changeset
2321 return (node != NULL);
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2322 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2323
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2324 gboolean
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2325 jabber_buddy_has_capability(const JabberBuddy *jb, const gchar *cap)
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2326 {
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2327 JabberBuddyResource *jbr = jabber_buddy_find_resource((JabberBuddy*)jb, NULL);
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2328
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2329 if (!jbr) {
25454
9a1500ef24bd This happens anytime you IM an offline user, and is totally not an error
Mark Doliner <markdoliner@pidgin.im>
parents: 25391
diff changeset
2330 purple_debug_info("jabber",
23626
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2331 "Unable to find caps: buddy might be offline\n");
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2332 return FALSE;
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2333 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2334
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2335 return jabber_resource_has_capability(jbr, cap);
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2336 }
e21afec2f485 Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents: 23393
diff changeset
2337
25577
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2338 const gchar *
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2339 jabber_resource_get_identity_category_type(const JabberBuddyResource *jbr,
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2340 const gchar *category)
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2341 {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2342 const GList *iter = NULL;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30014
diff changeset
2343
27286
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
2344 if (jbr->caps.info) {
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
2345 for (iter = jbr->caps.info->identities ; iter ; iter = g_list_next(iter)) {
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30014
diff changeset
2346 const JabberIdentity *identity =
27286
f637c4c27815 Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents: 27285
diff changeset
2347 (JabberIdentity *) iter->data;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30014
diff changeset
2348
25577
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2349 if (strcmp(identity->category, category) == 0) {
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2350 return identity->type;
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2351 }
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2352 }
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2353 }
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 30014
diff changeset
2354
25577
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2355 return NULL;
ca0b40451bbc Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents: 25575
diff changeset
2356 }

mercurial