Wed, 13 Apr 2011 00:22:29 +0000
Update js->initial_avatar_hash if the user tries to set the icon before
we've received our self vcard. This is the other half of a fix to get
rid of a race condition where the user's icon wouldn't get set correctly
if they set it while connecting.
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 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 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 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 | 21 | * |
| 22 | */ | |
| 23 | #include "internal.h" | |
| 24 | #include "debug.h" | |
| 7076 | 25 | #include "imgstore.h" |
|
9713
bb37562302a1
[gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents:
9466
diff
changeset
|
26 | #include "prpl.h" |
| 7014 | 27 | #include "notify.h" |
| 28 | #include "request.h" | |
| 29 | #include "util.h" | |
| 7395 | 30 | #include "xmlnode.h" |
| 7014 | 31 | |
| 32 | #include "buddy.h" | |
| 33 | #include "chat.h" | |
| 34 | #include "jabber.h" | |
| 35 | #include "iq.h" | |
| 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 | 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 | 42 | |
| 13794 | 43 | typedef struct { |
| 44 | long idle_seconds; | |
| 45 | } JabberBuddyInfoResource; | |
| 46 | ||
| 47 | typedef struct { | |
| 48 | JabberStream *js; | |
| 49 | JabberBuddy *jb; | |
| 50 | char *jid; | |
| 51 | GSList *ids; | |
| 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 | 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 | 58 | } JabberBuddyInfo; |
| 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 | 90 | void jabber_buddy_free(JabberBuddy *jb) |
| 91 | { | |
| 92 | g_return_if_fail(jb != NULL); | |
| 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 | 95 | while(jb->resources) |
| 96 | jabber_buddy_resource_free(jb->resources->data); | |
| 97 | ||
| 98 | g_free(jb); | |
| 99 | } | |
| 100 | ||
| 7014 | 101 | JabberBuddy *jabber_buddy_find(JabberStream *js, const char *name, |
| 102 | gboolean create) | |
| 103 | { | |
| 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 | 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 | 111 | return NULL; |
| 112 | ||
| 113 | jb = g_hash_table_lookup(js->buddies, realname); | |
| 114 | ||
| 115 | if(!jb && create) { | |
| 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 | 120 | |
| 121 | return jb; | |
| 122 | } | |
| 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 | 206 | |
| 207 | JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb, | |
| 208 | const char *resource) | |
| 209 | { | |
| 210 | GList *l; | |
| 211 | ||
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
212 | if (!jb) |
| 7014 | 213 | return NULL; |
| 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 | 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 | 223 | } |
| 224 | ||
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
225 | return NULL; |
| 7014 | 226 | } |
| 227 | ||
| 9954 | 228 | JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource, |
| 229 | int priority, JabberBuddyState state, const char *status) | |
| 7014 | 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 | 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 | 236 | jbr = g_new0(JabberBuddyResource, 1); |
| 7116 | 237 | jbr->jb = jb; |
| 7014 | 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 | 241 | } |
| 242 | jbr->priority = priority; | |
| 243 | jbr->state = state; | |
| 22928 | 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 | 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 | 249 | return jbr; |
| 7014 | 250 | } |
| 251 | ||
| 252 | void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource) | |
| 253 | { | |
| 254 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource); | |
| 255 | ||
| 256 | if(!jbr) | |
| 257 | return; | |
| 258 | ||
| 7116 | 259 | jabber_buddy_resource_free(jbr); |
| 7014 | 260 | } |
| 261 | ||
| 262 | /******* | |
| 263 | * This is the old vCard stuff taken from the old prpl. vCards, by definition | |
| 264 | * are a temporary thing until jabber can get its act together and come up | |
| 265 | * with a format for user information, hence the namespace of 'vcard-temp' | |
| 266 | * | |
| 267 | * Since I don't feel like putting that much work into something that's | |
| 268 | * _supposed_ to go away, i'm going to just copy the kludgy old code here, | |
| 269 | * and make it purdy when jabber comes up with a standards-track JEP to | |
| 270 | * replace vcard-temp | |
| 271 | * --Nathan | |
| 272 | *******/ | |
| 273 | ||
| 274 | /*---------------------------------------*/ | |
| 275 | /* Jabber "set info" (vCard) support */ | |
| 276 | /*---------------------------------------*/ | |
| 277 | ||
| 278 | /* | |
| 279 | * V-Card format: | |
| 280 | * | |
| 281 | * <vCard prodid='' version='' xmlns=''> | |
| 282 | * <FN></FN> | |
| 283 | * <N> | |
| 284 | * <FAMILY/> | |
| 285 | * <GIVEN/> | |
| 286 | * </N> | |
| 287 | * <NICKNAME/> | |
| 288 | * <URL/> | |
| 289 | * <ADR> | |
| 290 | * <STREET/> | |
| 291 | * <EXTADD/> | |
| 292 | * <LOCALITY/> | |
| 293 | * <REGION/> | |
| 294 | * <PCODE/> | |
| 295 | * <COUNTRY/> | |
| 296 | * </ADR> | |
| 297 | * <TEL/> | |
| 298 | * <EMAIL/> | |
| 299 | * <ORG> | |
| 300 | * <ORGNAME/> | |
| 301 | * <ORGUNIT/> | |
| 302 | * </ORG> | |
| 303 | * <TITLE/> | |
| 304 | * <ROLE/> | |
| 305 | * <DESC/> | |
| 306 | * <BDAY/> | |
| 307 | * </vCard> | |
| 308 | * | |
| 309 | * See also: | |
| 310 | * | |
| 311 | * http://docs.jabber.org/proto/html/vcard-temp.html | |
| 312 | * http://www.vcard-xml.org/dtd/vCard-XML-v2-20010520.dtd | |
| 313 | */ | |
| 314 | ||
| 315 | /* | |
| 316 | * Cross-reference user-friendly V-Card entry labels to vCard XML tags | |
| 317 | * and attributes. | |
| 318 | * | |
| 319 | * Order is (or should be) unimportant. For example: we have no way of | |
| 320 | * knowing in what order real data will arrive. | |
| 321 | * | |
| 322 | * Format: Label, Pre-set text, "visible" flag, "editable" flag, XML tag | |
| 323 | * name, XML tag's parent tag "path" (relative to vCard node). | |
| 324 | * | |
| 325 | * List is terminated by a NULL label pointer. | |
| 326 | * | |
| 327 | * Entries with no label text, but with XML tag and parent tag | |
| 328 | * entries, are used by V-Card XML construction routines to | |
| 329 | * "automagically" construct the appropriate XML node tree. | |
| 330 | * | |
| 331 | * Thoughts on future direction/expansion | |
| 332 | * | |
| 333 | * This is a "simple" vCard. | |
| 334 | * | |
| 335 | * It is possible for nodes other than the "vCard" node to have | |
| 336 | * attributes. Should that prove necessary/desirable, add an | |
| 337 | * "attributes" pointer to the vcard_template struct, create the | |
| 338 | * necessary tag_attr structs, and add 'em to the vcard_dflt_data | |
| 339 | * array. | |
| 340 | * | |
| 341 | * The above changes will (obviously) require changes to the vCard | |
| 342 | * construction routines. | |
| 343 | */ | |
| 344 | ||
| 345 | struct vcard_template { | |
| 346 | char *label; /* label text pointer */ | |
| 347 | char *tag; /* tag text */ | |
| 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 | 373 | }; |
| 374 | ||
| 375 | /* | |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8401
diff
changeset
|
376 | * The "vCard" tag's attribute list... |
| 7014 | 377 | */ |
| 378 | struct tag_attr { | |
| 379 | char *attr; | |
| 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 | 382 | {"prodid", "-//HandGen//NONSGML vGen v1.0//EN"}, |
| 383 | {"version", "2.0", }, | |
| 384 | {"xmlns", "vcard-temp", }, | |
| 385 | {NULL, NULL}, | |
| 386 | }; | |
| 387 | ||
| 388 | ||
| 389 | /* | |
| 390 | * Insert a tag node into an xmlnode tree, recursively inserting parent tag | |
| 391 | * nodes as necessary | |
| 392 | * | |
| 393 | * Returns pointer to inserted node | |
| 394 | * | |
| 395 | * Note to hackers: this code is designed to be re-entrant (it's recursive--it | |
| 396 | * calls itself), so don't put any "static"s in here! | |
| 397 | */ | |
| 398 | static xmlnode *insert_tag_to_parent_tag(xmlnode *start, const char *parent_tag, const char *new_tag) | |
| 399 | { | |
| 400 | xmlnode *x = NULL; | |
| 401 | ||
| 402 | /* | |
| 403 | * If the parent tag wasn't specified, see if we can get it | |
| 404 | * from the vCard template struct. | |
| 405 | */ | |
| 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 | 408 | |
| 409 | while(vc_tp->label != NULL) { | |
| 410 | if(strcmp(vc_tp->tag, new_tag) == 0) { | |
| 411 | parent_tag = vc_tp->ptag; | |
| 412 | break; | |
| 413 | } | |
| 414 | ++vc_tp; | |
| 415 | } | |
| 416 | } | |
| 417 | ||
| 418 | /* | |
| 419 | * If we have a parent tag... | |
| 420 | */ | |
| 421 | if(parent_tag != NULL ) { | |
| 422 | /* | |
| 423 | * Try to get the parent node for a tag | |
| 424 | */ | |
| 425 | if((x = xmlnode_get_child(start, parent_tag)) == NULL) { | |
| 426 | /* | |
| 427 | * Descend? | |
| 428 | */ | |
| 429 | char *grand_parent = g_strdup(parent_tag); | |
| 430 | char *parent; | |
| 431 | ||
| 432 | if((parent = strrchr(grand_parent, '/')) != NULL) { | |
| 433 | *(parent++) = '\0'; | |
| 434 | x = insert_tag_to_parent_tag(start, grand_parent, parent); | |
| 435 | } else { | |
| 436 | x = xmlnode_new_child(start, grand_parent); | |
| 437 | } | |
| 438 | g_free(grand_parent); | |
| 439 | } else { | |
| 440 | /* | |
| 441 | * We found *something* to be the parent node. | |
| 442 | * Note: may be the "root" node! | |
| 443 | */ | |
| 444 | xmlnode *y; | |
| 445 | if((y = xmlnode_get_child(x, new_tag)) != NULL) { | |
| 446 | return(y); | |
| 447 | } | |
| 448 | } | |
| 449 | } | |
| 450 | ||
| 451 | /* | |
| 452 | * insert the new tag into its parent node | |
| 453 | */ | |
| 454 | return(xmlnode_new_child((x == NULL? start : x), new_tag)); | |
| 455 | } | |
| 456 | ||
| 457 | /* | |
| 458 | * Send vCard info to Jabber server | |
| 459 | */ | |
| 15884 | 460 | void jabber_set_info(PurpleConnection *gc, const char *info) |
| 7014 | 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 | 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 | 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 | 467 | |
| 31691 | 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), |
|
97c06411eb81
Update js->initial_avatar_hash if the user tries to set the icon before
Mark Doliner <markdoliner@pidgin.im>
parents:
31691
diff
changeset
|
477 | purple_imgstore_get_size(image), "sha1"); |
|
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 | 491 | js->avatar_hash = NULL; |
| 7014 | 492 | |
| 493 | /* | |
| 494 | * Send only if there's actually any *information* to send | |
| 495 | */ | |
| 11388 | 496 | vc_node = info ? xmlnode_from_str(info, -1) : NULL; |
| 10189 | 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 | 502 | } |
| 7014 | 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 | 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 | 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>
diff
changeset
|
551 | jabber_presence_send(js, FALSE); |
| 7014 | 552 | } |
| 553 | } | |
| 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 | 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 | 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 | 568 | } |
| 569 | ||
| 7014 | 570 | /* |
| 571 | * This is the callback from the "ok clicked" for "set vCard" | |
| 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 | 574 | */ |
| 575 | static void | |
| 15884 | 576 | jabber_format_info(PurpleConnection *gc, PurpleRequestFields *fields) |
| 7014 | 577 | { |
| 578 | xmlnode *vc_node; | |
| 15884 | 579 | PurpleRequestField *field; |
| 7014 | 580 | const char *text; |
| 581 | char *p; | |
| 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 | 584 | |
| 585 | vc_node = xmlnode_new("vCard"); | |
| 586 | ||
| 587 | for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr) | |
| 588 | xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value); | |
| 589 | ||
| 590 | for (vc_tp = vcard_template_data; vc_tp->label != NULL; vc_tp++) { | |
| 591 | if (*vc_tp->label == '\0') | |
| 592 | continue; | |
| 593 | ||
| 15884 | 594 | field = purple_request_fields_get_field(fields, vc_tp->tag); |
| 595 | text = purple_request_field_string_get_value(field); | |
| 7014 | 596 | |
| 597 | ||
| 598 | if (text != NULL && *text != '\0') { | |
| 599 | xmlnode *xp; | |
| 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 | 602 | |
| 7014 | 603 | if ((xp = insert_tag_to_parent_tag(vc_node, |
| 604 | NULL, vc_tp->tag)) != NULL) { | |
| 605 | ||
| 606 | xmlnode_insert_data(xp, text, -1); | |
| 607 | } | |
| 608 | } | |
| 609 | } | |
| 610 | ||
| 7642 | 611 | p = xmlnode_to_str(vc_node, NULL); |
| 7014 | 612 | xmlnode_free(vc_node); |
| 613 | ||
| 15884 | 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 | 616 | |
| 617 | g_free(p); | |
| 618 | } | |
| 619 | ||
| 620 | /* | |
| 621 | * This gets executed by the proto action | |
| 622 | * | |
| 15884 | 623 | * Creates a new PurpleRequestFields struct, gets the XML-formatted user_info |
| 7014 | 624 | * string (if any) into GSLists for the (multi-entry) edit dialog and |
| 625 | * calls the set_vcard dialog. | |
| 626 | */ | |
| 15884 | 627 | void jabber_setup_set_info(PurplePluginAction *action) |
| 7014 | 628 | { |
| 15884 | 629 | PurpleConnection *gc = (PurpleConnection *) action->context; |
| 630 | PurpleRequestFields *fields; | |
| 631 | PurpleRequestFieldGroup *group; | |
| 632 | PurpleRequestField *field; | |
| 7014 | 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 | 636 | xmlnode *x_vc_data = NULL; |
| 637 | ||
| 15884 | 638 | fields = purple_request_fields_new(); |
| 639 | group = purple_request_field_group_new(NULL); | |
| 640 | purple_request_fields_add_group(fields, group); | |
| 7014 | 641 | |
| 642 | /* | |
| 643 | * Get existing, XML-formatted, user info | |
| 644 | */ | |
| 15884 | 645 | if((user_info = purple_account_get_user_info(gc->account)) != NULL) |
| 7014 | 646 | x_vc_data = xmlnode_from_str(user_info, -1); |
| 647 | ||
| 648 | /* | |
| 649 | * Set up GSLists for edit with labels from "template," data from user info | |
| 650 | */ | |
| 651 | for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) { | |
| 652 | xmlnode *data_node; | |
| 653 | if((vc_tp->label)[0] == '\0') | |
| 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 | 667 | |
| 668 | if(strcmp(vc_tp->tag, "DESC") == 0) { | |
| 15884 | 669 | field = purple_request_field_string_new(vc_tp->tag, |
| 7014 | 670 | _(vc_tp->label), cdata, |
| 671 | TRUE); | |
| 672 | } else { | |
| 15884 | 673 | field = purple_request_field_string_new(vc_tp->tag, |
| 7014 | 674 | _(vc_tp->label), cdata, |
| 675 | FALSE); | |
| 676 | } | |
| 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 | 681 | purple_request_field_group_add_field(group, field); |
| 7014 | 682 | } |
| 683 | ||
| 684 | if(x_vc_data != NULL) | |
| 685 | xmlnode_free(x_vc_data); | |
| 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 | 689 | _("All items below are optional. Enter only the " |
| 690 | "information with which you feel comfortable."), | |
| 691 | fields, | |
| 692 | _("Save"), G_CALLBACK(jabber_format_info), | |
| 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 | 696 | } |
| 697 | ||
| 698 | /*---------------------------------------*/ | |
| 699 | /* End Jabber "set info" (vCard) support */ | |
| 700 | /*---------------------------------------*/ | |
| 701 | ||
| 702 | /****** | |
| 703 | * end of that ancient crap that needs to die | |
| 704 | ******/ | |
| 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 | 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 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
729 | if (jbr && jbr->client.name) { |
| 27551 | 730 | char *tmp = |
| 731 | g_strdup_printf("%s%s%s", jbr->client.name, | |
| 732 | (jbr->client.version ? " " : ""), | |
| 733 | (jbr->client.version ? jbr->client.version : "")); | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
734 | purple_notify_user_info_prepend_pair(user_info, _("Client"), tmp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
735 | g_free(tmp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
736 | |
| 27551 | 737 | if (jbr->client.os) |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
738 | purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
739 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
740 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
741 | 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
|
742 | time_t now_t; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
743 | struct tm *now; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
744 | char *timestamp; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
745 | time(&now_t); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
746 | 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
|
747 | now = gmtime(&now_t); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
748 | |
| 27551 | 749 | timestamp = |
| 750 | g_strdup_printf("%s %c%02d%02d", purple_time_format(now), | |
| 751 | jbr->tz_off < 0 ? '-' : '+', | |
| 752 | abs(jbr->tz_off / (60*60)), | |
| 753 | abs((jbr->tz_off % (60*60)) / 60)); | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
754 | purple_notify_user_info_prepend_pair(user_info, _("Local Time"), timestamp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
755 | g_free(timestamp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
756 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
757 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
758 | if (jbir && jbir->idle_seconds > 0) { |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
759 | char *idle = purple_str_seconds_to_string(jbir->idle_seconds); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
760 | purple_notify_user_info_prepend_pair(user_info, _("Idle"), idle); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
761 | g_free(idle); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
762 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
763 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
764 | if (jbr) { |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
765 | char *purdy = NULL; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
766 | char *tmp; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
767 | char priority[12]; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
768 | const char *status_name = jabber_buddy_state_get_name(jbr->state); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
769 | |
| 27551 | 770 | if (jbr->status) { |
|
28290
55c4b5a11af7
jabber: Escape status messages with a '<' or '>' in the Get Info dialog.
Paul Aurich <darkrain42@pidgin.im>
parents:
28278
diff
changeset
|
771 | tmp = purple_markup_escape_text(jbr->status, -1); |
|
55c4b5a11af7
jabber: Escape status messages with a '<' or '>' in the Get Info dialog.
Paul Aurich <darkrain42@pidgin.im>
parents:
28278
diff
changeset
|
772 | purdy = purple_strdup_withhtml(tmp); |
|
55c4b5a11af7
jabber: Escape status messages with a '<' or '>' in the Get Info dialog.
Paul Aurich <darkrain42@pidgin.im>
parents:
28278
diff
changeset
|
773 | g_free(tmp); |
| 27551 | 774 | |
| 775 | if (purple_strequal(status_name, purdy)) | |
| 776 | status_name = NULL; | |
| 777 | } | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
778 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
779 | tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""), |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
780 | ((status_name && purdy) ? ": " : ""), |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
781 | (purdy ? purdy : "")); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
782 | purple_notify_user_info_prepend_pair(user_info, _("Status"), tmp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
783 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
784 | g_snprintf(priority, sizeof(priority), "%d", jbr->priority); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
785 | purple_notify_user_info_prepend_pair(user_info, _("Priority"), priority); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
786 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
787 | g_free(tmp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
788 | g_free(purdy); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
789 | } else { |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
790 | purple_notify_user_info_prepend_pair(user_info, _("Status"), _("Unknown")); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
791 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
792 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
793 | |
| 13794 | 794 | static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi) |
| 7014 | 795 | { |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
796 | char *resource_name; |
| 13794 | 797 | JabberBuddyResource *jbr; |
| 798 | GList *resources; | |
| 15884 | 799 | PurpleNotifyUserInfo *user_info; |
| 7014 | 800 | |
| 13794 | 801 | /* not yet */ |
| 27551 | 802 | if (jbi->ids) |
| 11361 | 803 | return; |
| 804 | ||
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
805 | user_info = jbi->user_info; |
| 13794 | 806 | resource_name = jabber_get_resource(jbi->jid); |
| 7014 | 807 | |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
808 | /* If we have one or more pairs from the vcard, put a section break above it */ |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
809 | if (purple_notify_user_info_get_entries(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
|
810 | 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
|
811 | |
| 27551 | 812 | /* Add the information about the user's resource(s) */ |
| 813 | if (resource_name) { | |
| 13794 | 814 | 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
|
815 | add_jbr_info(jbi, resource_name, jbr); |
| 7014 | 816 | } else { |
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
817 | /* 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
|
818 | * 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
|
819 | for (resources = jbi->jb->resources; resources; resources = resources->next) { |
| 7014 | 820 | 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
|
821 | |
|
27053
fb088f01758d
Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents:
26958
diff
changeset
|
822 | /* 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
|
823 | 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
|
824 | section */ |
| 27551 | 825 | 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
|
826 | 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
|
827 | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
828 | add_jbr_info(jbi, jbr->name, jbr); |
| 13794 | 829 | |
| 27551 | 830 | if (jbr->name) |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
831 | purple_notify_user_info_prepend_pair(user_info, _("Resource"), jbr->name); |
| 7014 | 832 | } |
| 833 | } | |
| 834 | ||
|
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
|
835 | 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
|
836 | /* 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
|
837 | 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
|
838 | |
|
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
|
839 | 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
|
840 | 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
|
841 | 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
|
842 | 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
|
843 | 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
|
844 | 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
|
845 | message = last; |
|
6218763ad5b4
This string is already translated; so it need not be translated again.
Paul Aurich <darkrain42@pidgin.im>
parents:
29097
diff
changeset
|
846 | 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
|
847 | } 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
|
848 | 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
|
849 | 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
|
850 | } |
|
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 | purple_notify_user_info_prepend_pair(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
|
852 | 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
|
853 | 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
|
854 | } |
|
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 | |
|
29097
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
856 | if (!is_domain) { |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
857 | gchar *status = |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
858 | g_strdup_printf("%s%s%s", _("Offline"), |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
859 | jbi->last_message ? ": " : "", |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
860 | jbi->last_message ? jbi->last_message : ""); |
|
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
|
861 | purple_notify_user_info_prepend_pair(user_info, _("Status"), status); |
|
29097
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
862 | g_free(status); |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
863 | } |
|
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
|
864 | } |
|
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
|
865 | |
| 7306 | 866 | g_free(resource_name); |
| 867 | ||
| 15884 | 868 | purple_notify_userinfo(jbi->js->gc, jbi->jid, user_info, NULL, NULL); |
| 13794 | 869 | |
| 27551 | 870 | 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
|
871 | purple_imgstore_unref_by_id(GPOINTER_TO_INT(jbi->vcard_imgids->data)); |
| 13794 | 872 | jbi->vcard_imgids = g_slist_delete_link(jbi->vcard_imgids, jbi->vcard_imgids); |
| 873 | } | |
| 874 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
875 | 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
|
876 | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
877 | jabber_buddy_info_destroy(jbi); |
| 13794 | 878 | } |
| 879 | ||
| 880 | static void jabber_buddy_info_remove_id(JabberBuddyInfo *jbi, const char *id) | |
| 881 | { | |
| 882 | 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
|
883 | char *comp_id; |
| 13794 | 884 | |
| 885 | if(!id) | |
| 886 | return; | |
| 887 | ||
| 888 | while(l) { | |
|
15727
0754583ceeae
Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents:
15688
diff
changeset
|
889 | 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
|
890 | 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
|
891 | 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
|
892 | g_free(comp_id); |
| 13794 | 893 | return; |
| 894 | } | |
| 895 | l = l->next; | |
| 896 | } | |
| 897 | } | |
| 898 | ||
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
899 | static gboolean |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
900 | set_own_vcard_cb(gpointer data) |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
901 | { |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
902 | JabberStream *js = data; |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
903 | 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
|
904 | |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
905 | js->vcard_timer = 0; |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
906 | |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
907 | 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
|
908 | |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
909 | return FALSE; |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
910 | } |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
911 | |
|
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
|
912 | 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
|
913 | 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
|
914 | 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
|
915 | { |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
916 | 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
|
917 | char *txt, *vcard_hash = NULL; |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
918 | PurpleAccount *account; |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
919 | |
|
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
|
920 | 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
|
921 | xmlnode *error; |
| 27417 | 922 | 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
|
923 | |
|
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
|
924 | 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
|
925 | 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
|
926 | 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
|
927 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
928 | |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
929 | 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
|
930 | |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
931 | 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
|
932 | (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
|
933 | { |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
934 | 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
|
935 | 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
|
936 | g_free(txt); |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
937 | } else { |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
938 | /* 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
|
939 | } |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
940 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
941 | 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
|
942 | |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
943 | 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
|
944 | (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
|
945 | 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
|
946 | 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
|
947 | if (bintext) { |
|
9c92aae99f62
jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents:
28290
diff
changeset
|
948 | 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
|
949 | 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
|
950 | |
|
28311
9c92aae99f62
jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents:
28290
diff
changeset
|
951 | 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
|
952 | 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
|
953 | g_free(data); |
|
9c92aae99f62
jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents:
28290
diff
changeset
|
954 | } |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
955 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
956 | } |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
957 | |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
958 | /* 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
|
959 | 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
|
960 | /* |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
961 | * 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
|
962 | * 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
|
963 | * it returns an error (namespaces trimmed): |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
964 | * <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
|
965 | */ |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
966 | if (js->googletalk) |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
967 | 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
|
968 | js); |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
969 | else |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
970 | 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
|
971 | } 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
|
972 | /* 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
|
973 | 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
|
974 | vcard_hash = NULL; |
|
4d43dd2afadb
jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents:
28881
diff
changeset
|
975 | |
|
4d43dd2afadb
jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents:
28881
diff
changeset
|
976 | /* 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
|
977 | 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
|
978 | } |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
979 | |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
980 | 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
|
981 | } |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
982 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
983 | 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
|
984 | { |
|
21957
0ce77f86c7f3
Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents:
21681
diff
changeset
|
985 | 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
|
986 | |
|
21957
0ce77f86c7f3
Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents:
21681
diff
changeset
|
987 | 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
|
988 | 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
|
989 | 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
|
990 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
991 | 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
|
992 | } |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
993 | |
|
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
|
994 | 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
|
995 | 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
|
996 | xmlnode *packet, gpointer data) |
| 13794 | 997 | { |
| 998 | char *bare_jid; | |
| 999 | 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
|
1000 | char *serverside_alias = NULL; |
| 13794 | 1001 | xmlnode *vcard; |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1002 | PurpleAccount *account; |
| 13794 | 1003 | 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
|
1004 | PurpleNotifyUserInfo *user_info; |
| 13794 | 1005 | |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1006 | g_return_if_fail(jbi != NULL); |
| 13794 | 1007 | |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
1008 | jabber_buddy_info_remove_id(jbi, id); |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
1009 | |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1010 | 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
|
1011 | 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
|
1012 | jabber_buddy_info_show_if_ready(jbi); |
| 13794 | 1013 | return; |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1014 | } |
| 13794 | 1015 | |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1016 | 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
|
1017 | 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
|
1018 | bare_jid = jabber_get_bare_jid(from ? from : purple_account_get_username(account)); |
| 13794 | 1019 | |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1020 | /* TODO: Is the query xmlns='vcard-temp' version of this still necessary? */ |
| 10189 | 1021 | if((vcard = xmlnode_get_child(packet, "vCard")) || |
| 1022 | (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { | |
| 7014 | 1023 | xmlnode *child; |
| 1024 | for(child = vcard->child; child; child = child->next) | |
| 1025 | { | |
| 1026 | xmlnode *child2; | |
| 1027 | ||
| 8135 | 1028 | if(child->type != XMLNODE_TYPE_TAG) |
| 7014 | 1029 | continue; |
| 1030 | ||
| 1031 | text = xmlnode_get_data(child); | |
| 1032 | 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
|
1033 | 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
|
1034 | 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
|
1035 | |
|
30537
9f833935ecd7
Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents:
29965
diff
changeset
|
1036 | purple_notify_user_info_add_pair_plaintext(user_info, _("Full Name"), text); |
| 7014 | 1037 | } else if(!strcmp(child->name, "N")) { |
| 1038 | for(child2 = child->child; child2; child2 = child2->next) | |
| 1039 | { | |
| 1040 | char *text2; | |
| 1041 | ||
| 8135 | 1042 | if(child2->type != XMLNODE_TYPE_TAG) |
| 7014 | 1043 | continue; |
| 1044 | ||
| 1045 | text2 = xmlnode_get_data(child2); | |
| 1046 | 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
|
1047 | purple_notify_user_info_add_pair_plaintext(user_info, _("Family Name"), text2); |
| 7014 | 1048 | } 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
|
1049 | purple_notify_user_info_add_pair_plaintext(user_info, _("Given Name"), text2); |
| 7014 | 1050 | } 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
|
1051 | purple_notify_user_info_add_pair_plaintext(user_info, _("Middle Name"), text2); |
| 7014 | 1052 | } |
| 1053 | g_free(text2); | |
| 1054 | } | |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1055 | } 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
|
1056 | /* 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
|
1057 | * 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
|
1058 | 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
|
1059 | 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
|
1060 | 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
|
1061 | |
|
30537
9f833935ecd7
Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents:
29965
diff
changeset
|
1062 | 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
|
1063 | } |
| 7014 | 1064 | } 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
|
1065 | purple_notify_user_info_add_pair_plaintext(user_info, _("Birthday"), text); |
| 7014 | 1066 | } else if(!strcmp(child->name, "ADR")) { |
|
12933
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1067 | gboolean address_line_added = FALSE; |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1068 | |
| 7014 | 1069 | for(child2 = child->child; child2; child2 = child2->next) |
| 1070 | { | |
| 1071 | char *text2; | |
| 1072 | ||
| 8135 | 1073 | if(child2->type != XMLNODE_TYPE_TAG) |
| 7014 | 1074 | continue; |
| 1075 | ||
| 1076 | text2 = xmlnode_get_data(child2); | |
|
12933
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1077 | if (text2 == NULL) |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1078 | continue; |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1079 | |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1080 | /* 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
|
1081 | * elements are empty. */ |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1082 | if (!address_line_added) |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1083 | { |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1084 | purple_notify_user_info_add_section_header(user_info, _("Address")); |
|
12933
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1085 | address_line_added = TRUE; |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1086 | } |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1087 | |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1088 | 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
|
1089 | 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
|
1090 | } 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
|
1091 | /* |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1092 | * EXTADD is correct, EXTADR is generated by other |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1093 | * clients. The next time someone reads this, remove |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1094 | * EXTADR. |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1095 | */ |
|
30537
9f833935ecd7
Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents:
29965
diff
changeset
|
1096 | 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
|
1097 | } 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
|
1098 | 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
|
1099 | } 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
|
1100 | 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
|
1101 | } 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
|
1102 | 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
|
1103 | } 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
|
1104 | 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
|
1105 | } else if(!strcmp(child2->name, "CTRY") |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1106 | || !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
|
1107 | purple_notify_user_info_add_pair_plaintext(user_info, _("Country"), text2); |
| 7014 | 1108 | } |
| 1109 | g_free(text2); | |
| 1110 | } | |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1111 | |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1112 | 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
|
1113 | 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
|
1114 | |
| 7014 | 1115 | } else if(!strcmp(child->name, "TEL")) { |
| 1116 | char *number; | |
| 1117 | if((child2 = xmlnode_get_child(child, "NUMBER"))) { | |
| 1118 | /* show what kind of number it is */ | |
| 1119 | number = xmlnode_get_data(child2); | |
| 1120 | 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
|
1121 | purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number); |
| 7014 | 1122 | g_free(number); |
| 1123 | } | |
| 1124 | } else if((number = xmlnode_get_data(child))) { | |
| 15884 | 1125 | /* lots of clients (including purple) do this, but it's |
| 7014 | 1126 | * 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
|
1127 | purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number); |
| 7014 | 1128 | g_free(number); |
| 1129 | } | |
| 1130 | } 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
|
1131 | char *userid, *escaped; |
| 7014 | 1132 | if((child2 = xmlnode_get_child(child, "USERID"))) { |
| 1133 | /* show what kind of email it is */ | |
| 1134 | userid = xmlnode_get_data(child2); | |
| 1135 | 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
|
1136 | 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
|
1137 | 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
|
1138 | mailto = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", escaped, escaped); |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1139 | purple_notify_user_info_add_pair(user_info, _("Email"), mailto); |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1140 | |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1141 | 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
|
1142 | g_free(escaped); |
| 7014 | 1143 | g_free(userid); |
| 1144 | } | |
| 1145 | } else if((userid = xmlnode_get_data(child))) { | |
| 15884 | 1146 | /* lots of clients (including purple) do this, but it's |
| 7014 | 1147 | * 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
|
1148 | 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
|
1149 | |
|
19931
229fb62285b0
Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents:
19921
diff
changeset
|
1150 | 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
|
1151 | mailto = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", escaped, escaped); |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1152 | purple_notify_user_info_add_pair(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
|
1153 | |
|
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1154 | 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
|
1155 | g_free(escaped); |
| 7014 | 1156 | g_free(userid); |
| 1157 | } | |
| 1158 | } else if(!strcmp(child->name, "ORG")) { | |
| 1159 | for(child2 = child->child; child2; child2 = child2->next) | |
| 1160 | { | |
| 1161 | char *text2; | |
| 1162 | ||
| 8135 | 1163 | if(child2->type != XMLNODE_TYPE_TAG) |
| 7014 | 1164 | continue; |
| 1165 | ||
| 1166 | text2 = xmlnode_get_data(child2); | |
| 1167 | 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
|
1168 | purple_notify_user_info_add_pair_plaintext(user_info, _("Organization Name"), text2); |
| 7014 | 1169 | } 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
|
1170 | purple_notify_user_info_add_pair_plaintext(user_info, _("Organization Unit"), text2); |
| 7014 | 1171 | } |
| 1172 | g_free(text2); | |
| 1173 | } | |
| 1174 | } 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
|
1175 | purple_notify_user_info_add_pair_plaintext(user_info, _("Job Title"), text); |
| 7014 | 1176 | } 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
|
1177 | purple_notify_user_info_add_pair_plaintext(user_info, _("Role"), text); |
| 7014 | 1178 | } 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
|
1179 | purple_notify_user_info_add_pair_plaintext(user_info, _("Description"), text); |
| 7076 | 1180 | } else if(!strcmp(child->name, "PHOTO") || |
| 1181 | !strcmp(child->name, "LOGO")) { | |
| 10941 | 1182 | char *bintext = NULL; |
| 1183 | xmlnode *binval; | |
| 11361 | 1184 | |
|
28611
156e0b180d48
jabber: Don't try to pull a photo out of the <PHOTO/> cdata.
Paul Aurich <darkrain42@pidgin.im>
parents:
28322
diff
changeset
|
1185 | 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
|
1186 | (bintext = xmlnode_get_data(binval))) { |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10941
diff
changeset
|
1187 | gsize size; |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
1188 | guchar *data; |
| 10941 | 1189 | gboolean photo = (strcmp(child->name, "PHOTO") == 0); |
| 10189 | 1190 | |
| 15884 | 1191 | data = purple_base64_decode(bintext, &size); |
|
16587
50de12a4b81b
disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents:
16585
diff
changeset
|
1192 | 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
|
1193 | 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
|
1194 | 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
|
1195 | |
|
16587
50de12a4b81b
disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents:
16585
diff
changeset
|
1196 | 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
|
1197 | 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
|
1198 | |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1199 | purple_notify_user_info_add_pair(user_info, (photo ? _("Photo") : _("Logo")), img_text); |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1200 | |
|
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
|
1201 | 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
|
1202 | 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
|
1203 | 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
|
1204 | g_free(img_text); |
|
16587
50de12a4b81b
disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents:
16585
diff
changeset
|
1205 | } |
|
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
|
1206 | g_free(bintext); |
| 10941 | 1207 | } |
| 7014 | 1208 | } |
| 1209 | g_free(text); | |
| 1210 | } | |
| 1211 | } | |
| 1212 | ||
|
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
|
1213 | 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
|
1214 | 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
|
1215 | /* 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
|
1216 | 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
|
1217 | 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
|
1218 | 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
|
1219 | 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
|
1220 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1221 | |
|
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
|
1222 | 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
|
1223 | } |
|
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
|
1224 | |
| 13794 | 1225 | g_free(bare_jid); |
| 1226 | ||
| 1227 | jabber_buddy_info_show_if_ready(jbi); | |
| 1228 | } | |
| 1229 | ||
| 1230 | static void jabber_buddy_info_resource_free(gpointer data) | |
| 1231 | { | |
| 1232 | JabberBuddyInfoResource *jbri = data; | |
| 1233 | g_free(jbri); | |
| 1234 | } | |
| 1235 | ||
|
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
|
1236 | 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
|
1237 | { |
|
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
|
1238 | 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
|
1239 | 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
|
1240 | 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
|
1241 | 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
|
1242 | } |
|
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
|
1243 | |
|
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
|
1244 | 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
|
1245 | { |
|
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 | 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
|
1247 | 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
|
1248 | |
|
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 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
|
1250 | } |
|
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 | |
|
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
|
1252 | 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
|
1253 | 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
|
1254 | xmlnode *packet, gpointer data) |
| 13794 | 1255 | { |
| 1256 | JabberBuddyInfo *jbi = data; | |
| 1257 | xmlnode *query; | |
| 1258 | char *resource_name; | |
| 1259 | ||
| 1260 | g_return_if_fail(jbi != NULL); | |
| 1261 | ||
| 1262 | jabber_buddy_info_remove_id(jbi, id); | |
| 1263 | ||
| 1264 | if(!from) | |
| 1265 | return; | |
| 1266 | ||
| 1267 | resource_name = jabber_get_resource(from); | |
| 1268 | ||
| 1269 | 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
|
1270 | if (type == JABBER_IQ_RESULT) { |
| 13794 | 1271 | if((query = xmlnode_get_child(packet, "query"))) { |
| 1272 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jbi->jb, resource_name); | |
| 1273 | if(jbr) { | |
| 1274 | xmlnode *node; | |
| 1275 | if((node = xmlnode_get_child(query, "name"))) { | |
| 1276 | jbr->client.name = xmlnode_get_data(node); | |
| 1277 | } | |
| 1278 | if((node = xmlnode_get_child(query, "version"))) { | |
| 1279 | jbr->client.version = xmlnode_get_data(node); | |
| 1280 | } | |
| 1281 | if((node = xmlnode_get_child(query, "os"))) { | |
| 1282 | jbr->client.os = xmlnode_get_data(node); | |
| 1283 | } | |
| 1284 | } | |
| 1285 | } | |
| 1286 | } | |
| 1287 | g_free(resource_name); | |
| 10189 | 1288 | } |
| 13794 | 1289 | |
| 1290 | jabber_buddy_info_show_if_ready(jbi); | |
| 7014 | 1291 | } |
| 1292 | ||
|
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
|
1293 | 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
|
1294 | 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
|
1295 | xmlnode *packet, gpointer data) |
| 13794 | 1296 | { |
| 1297 | JabberBuddyInfo *jbi = data; | |
| 1298 | xmlnode *query; | |
| 1299 | 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
|
1300 | const char *seconds; |
| 13794 | 1301 | |
| 1302 | g_return_if_fail(jbi != NULL); | |
| 1303 | ||
| 1304 | jabber_buddy_info_remove_id(jbi, id); | |
| 1305 | ||
| 1306 | if(!from) | |
| 1307 | return; | |
| 1308 | ||
| 1309 | resource_name = jabber_get_resource(from); | |
| 1310 | ||
| 1311 | 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
|
1312 | if (type == JABBER_IQ_RESULT) { |
| 13794 | 1313 | if((query = xmlnode_get_child(packet, "query"))) { |
| 1314 | seconds = xmlnode_get_attrib(query, "seconds"); | |
| 1315 | if(seconds) { | |
| 1316 | char *end = NULL; | |
| 1317 | 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
|
1318 | JabberBuddy *jb = NULL; |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1319 | char *resource = NULL; |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1320 | 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
|
1321 | JabberBuddyResource *jbr = NULL; |
|
26958
a955bd42f529
propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
diff
changeset
|
1322 | |
| 13794 | 1323 | if(end != seconds) { |
| 1324 | JabberBuddyInfoResource *jbir = g_hash_table_lookup(jbi->resources, resource_name); | |
| 1325 | if(jbir) { | |
| 1326 | jbir->idle_seconds = sec; | |
| 1327 | } | |
| 1328 | } | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27135
diff
changeset
|
1329 | /* 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
|
1330 | 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
|
1331 | 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
|
1332 | 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
|
1333 | if (jb) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1334 | 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
|
1335 | 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
|
1336 | /* 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
|
1337 | 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
|
1338 | 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
|
1339 | 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
|
1340 | the resource getting unidle */ |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1341 | if (resource && buddy_name) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1342 | 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
|
1343 | if (jbr) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1344 | if (jbr->idle) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1345 | if (sec) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1346 | 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
|
1347 | } else { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1348 | jbr->idle = 0; |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1349 | } |
|
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
|
1350 | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27135
diff
changeset
|
1351 | if (jbr == |
|
27135
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1352 | jabber_buddy_find_resource(jb, NULL)) { |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27135
diff
changeset
|
1353 | 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
|
1354 | 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
|
1355 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1356 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1357 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1358 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1359 | g_free(resource); |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1360 | g_free(buddy_name); |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1361 | } |
| 13794 | 1362 | } |
| 1363 | } | |
| 1364 | } | |
| 1365 | g_free(resource_name); | |
| 1366 | } | |
| 1367 | ||
| 1368 | jabber_buddy_info_show_if_ready(jbi); | |
| 1369 | } | |
| 1370 | ||
|
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
|
1371 | 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
|
1372 | 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
|
1373 | 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
|
1374 | { |
|
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
|
1375 | 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
|
1376 | 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
|
1377 | 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
|
1378 | |
|
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
|
1379 | 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
|
1380 | |
|
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 | 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
|
1382 | |
|
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 | 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
|
1384 | 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
|
1385 | 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
|
1386 | 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
|
1387 | 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
|
1388 | 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
|
1389 | 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
|
1390 | 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
|
1391 | } |
|
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 | 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
|
1394 | } |
|
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 | } |
|
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 | |
|
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 | 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
|
1398 | } |
|
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 | |
|
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
|
1400 | 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
|
1401 | 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
|
1402 | 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
|
1403 | { |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1404 | JabberBuddyInfo *jbi = data; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1405 | JabberBuddyResource *jbr; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1406 | char *resource_name; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1407 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1408 | 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
|
1409 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1410 | 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
|
1411 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1412 | if (!from) |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1413 | return; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1414 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1415 | 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
|
1416 | 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
|
1417 | 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
|
1418 | 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
|
1419 | 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
|
1420 | 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
|
1421 | 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
|
1422 | 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
|
1423 | 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
|
1424 | 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
|
1425 | 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
|
1426 | 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
|
1427 | 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
|
1428 | } else { |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1429 | 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
|
1430 | /* [+-]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
|
1431 | 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
|
1432 | 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
|
1433 | 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
|
1434 | 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
|
1435 | 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
|
1436 | } else { |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1437 | 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
|
1438 | 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
|
1439 | } |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1440 | } |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1441 | |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1442 | 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
|
1443 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1444 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1445 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1446 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1447 | 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
|
1448 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1449 | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1450 | void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js) |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1451 | { |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1452 | if (js->pending_buddy_info_requests) |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1453 | { |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1454 | JabberBuddyInfo *jbi; |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1455 | GSList *l = js->pending_buddy_info_requests; |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1456 | while (l) { |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1457 | jbi = l->data; |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1458 | |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1459 | g_slist_free(jbi->ids); |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1460 | jabber_buddy_info_destroy(jbi); |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1461 | |
|
15727
0754583ceeae
Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents:
15688
diff
changeset
|
1462 | l = l->next; |
|
15363
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 | |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1465 | g_slist_free(js->pending_buddy_info_requests); |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1466 | js->pending_buddy_info_requests = NULL; |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1467 | } |
|
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 | |
| 13794 | 1470 | static gboolean jabber_buddy_get_info_timeout(gpointer data) |
| 1471 | { | |
| 1472 | JabberBuddyInfo *jbi = data; | |
| 1473 | ||
| 1474 | /* remove the pending callbacks */ | |
| 1475 | while(jbi->ids) { | |
| 1476 | char *id = jbi->ids->data; | |
| 1477 | jabber_iq_remove_callback_by_id(jbi->js, id); | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1478 | jbi->ids = g_slist_remove(jbi->ids, id); |
| 13794 | 1479 | g_free(id); |
| 1480 | } | |
| 1481 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1482 | jbi->js->pending_buddy_info_requests = g_slist_remove(jbi->js->pending_buddy_info_requests, jbi); |
| 13794 | 1483 | jbi->timeout_handle = 0; |
| 1484 | ||
| 1485 | jabber_buddy_info_show_if_ready(jbi); | |
| 1486 | ||
| 1487 | return FALSE; | |
| 1488 | } | |
| 1489 | ||
|
17029
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1490 | 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
|
1491 | { |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1492 | /* 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
|
1493 | 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
|
1494 | return FALSE; |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1495 | |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28883
diff
changeset
|
1496 | 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
|
1497 | if(!strcmp(jbr->client.name, "Trillian")) { |
|
20350
ae3f3561e698
another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
1498 | /* verified by nwalp 2007/05/09 */ |
|
ae3f3561e698
another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
1499 | if(!strcmp(jbr->client.version, "3.1.0.121") || |
|
ae3f3561e698
another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
1500 | /* verified by nwalp 2007/09/19 */ |
|
ae3f3561e698
another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
1501 | !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
|
1502 | return TRUE; |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1503 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1504 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1505 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1506 | |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1507 | return FALSE; |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1508 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1509 | |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1510 | static void |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1511 | 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
|
1512 | 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
|
1513 | JabberBuddyResource *jbr) |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1514 | { |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1515 | JabberIq *iq; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1516 | JabberBuddyInfoResource *jbir; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1517 | char *full_jid = NULL; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1518 | const char *to; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1519 | |
|
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
|
1520 | 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
|
1521 | 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
|
1522 | to = full_jid; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1523 | } else |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1524 | to = jid; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1525 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1526 | 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
|
1527 | 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
|
1528 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1529 | if(!jbr->client.name) { |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1530 | 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
|
1531 | 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
|
1532 | 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
|
1533 | 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
|
1534 | jabber_iq_send(iq); |
|
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 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1537 | /* 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
|
1538 | * 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
|
1539 | * 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
|
1540 | * 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
|
1541 | * office. */ |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28883
diff
changeset
|
1542 | 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
|
1543 | 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
|
1544 | 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
|
1545 | 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
|
1546 | 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
|
1547 | jabber_iq_send(iq); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1548 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1549 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1550 | 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
|
1551 | (!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
|
1552 | 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
|
1553 | xmlnode *child; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1554 | 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
|
1555 | 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
|
1556 | 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
|
1557 | 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
|
1558 | 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
|
1559 | 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
|
1560 | jabber_iq_send(iq); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1561 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1562 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1563 | g_free(full_jid); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1564 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1565 | |
| 13794 | 1566 | static void jabber_buddy_get_info_for_jid(JabberStream *js, const char *jid) |
| 7014 | 1567 | { |
| 1568 | JabberIq *iq; | |
| 1569 | xmlnode *vcard; | |
| 13794 | 1570 | GList *resources; |
| 1571 | JabberBuddy *jb; | |
| 1572 | 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
|
1573 | const char *slash; |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1574 | gboolean is_bare_jid; |
| 13794 | 1575 | |
| 1576 | jb = jabber_buddy_find(js, jid, TRUE); | |
| 1577 | ||
| 1578 | /* invalid JID */ | |
| 1579 | if(!jb) | |
| 1580 | return; | |
| 1581 | ||
|
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
|
1582 | 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
|
1583 | 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
|
1584 | |
| 13794 | 1585 | jbi = g_new0(JabberBuddyInfo, 1); |
| 1586 | jbi->jid = g_strdup(jid); | |
| 1587 | jbi->js = js; | |
| 1588 | 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
|
1589 | 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
|
1590 | jbi->user_info = purple_notify_user_info_new(); |
| 7014 | 1591 | |
| 1592 | iq = jabber_iq_new(js, JABBER_IQ_GET); | |
| 1593 | ||
| 13794 | 1594 | xmlnode_set_attrib(iq->node, "to", jid); |
| 7014 | 1595 | vcard = xmlnode_new_child(iq->node, "vCard"); |
| 13808 | 1596 | xmlnode_set_namespace(vcard, "vcard-temp"); |
| 7014 | 1597 | |
| 13794 | 1598 | jabber_iq_set_callback(iq, jabber_vcard_parse, jbi); |
| 1599 | jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); | |
| 7014 | 1600 | |
| 1601 | jabber_iq_send(iq); | |
| 13794 | 1602 | |
|
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
|
1603 | 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
|
1604 | if (jb->resources) { |
|
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1605 | 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
|
1606 | 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
|
1607 | 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
|
1608 | } |
|
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1609 | } else { |
|
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1610 | /* 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
|
1611 | 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
|
1612 | 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
|
1613 | 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
|
1614 | 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
|
1615 | 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
|
1616 | } |
|
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
|
1617 | } 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
|
1618 | 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
|
1619 | 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
|
1620 | 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
|
1621 | 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
|
1622 | 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
|
1623 | "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
|
1624 | "JabberBuddyResource!\n", jid); |
| 13794 | 1625 | } |
| 1626 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1627 | 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
|
1628 | jbi->timeout_handle = purple_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi); |
| 7014 | 1629 | } |
| 1630 | ||
| 15884 | 1631 | void jabber_buddy_get_info(PurpleConnection *gc, const char *who) |
| 10189 | 1632 | { |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1633 | 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
|
1634 | 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
|
1635 | |
|
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
|
1636 | 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
|
1637 | return; |
| 10189 | 1638 | |
|
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
|
1639 | 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
|
1640 | /* 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
|
1641 | 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
|
1642 | } 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
|
1643 | char *bare_jid = jabber_get_bare_jid(who); |
| 10189 | 1644 | jabber_buddy_get_info_for_jid(js, bare_jid); |
| 1645 | g_free(bare_jid); | |
| 1646 | } | |
|
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
|
1647 | |
|
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
|
1648 | jabber_id_free(jid); |
| 10189 | 1649 | } |
| 1650 | ||
| 7014 | 1651 | static void jabber_buddy_set_invisibility(JabberStream *js, const char *who, |
| 1652 | gboolean invisible) | |
| 1653 | { | |
| 15884 | 1654 | PurplePresence *gpresence; |
| 1655 | PurpleAccount *account; | |
| 1656 | PurpleStatus *status; | |
| 7014 | 1657 | JabberBuddy *jb = jabber_buddy_find(js, who, TRUE); |
| 1658 | xmlnode *presence; | |
| 9954 | 1659 | JabberBuddyState state; |
| 14525 | 1660 | char *msg; |
| 9954 | 1661 | int priority; |
| 7014 | 1662 | |
| 15884 | 1663 | account = purple_connection_get_account(js->gc); |
| 1664 | gpresence = purple_account_get_presence(account); | |
| 1665 | status = purple_presence_get_active_status(gpresence); | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9797
diff
changeset
|
1666 | |
| 15884 | 1667 | 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
|
1668 | presence = jabber_presence_create_js(js, state, msg, priority); |
| 9954 | 1669 | |
| 14525 | 1670 | g_free(msg); |
| 1671 | ||
| 7014 | 1672 | xmlnode_set_attrib(presence, "to", who); |
| 1673 | if(invisible) { | |
| 1674 | xmlnode_set_attrib(presence, "type", "invisible"); | |
| 1675 | jb->invisible |= JABBER_INVIS_BUDDY; | |
| 1676 | } else { | |
| 1677 | jb->invisible &= ~JABBER_INVIS_BUDDY; | |
| 1678 | } | |
| 1679 | ||
| 1680 | jabber_send(js, presence); | |
| 1681 | xmlnode_free(presence); | |
| 1682 | } | |
| 1683 | ||
| 15884 | 1684 | static void jabber_buddy_make_invisible(PurpleBlistNode *node, gpointer data) |
| 7014 | 1685 | { |
| 15884 | 1686 | PurpleBuddy *buddy; |
| 1687 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1688 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1689 | |
| 15884 | 1690 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1691 | |
| 15884 | 1692 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1693 | 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
|
1694 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1695 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1696 | jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), TRUE); |
| 7014 | 1697 | } |
| 1698 | ||
| 15884 | 1699 | static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data) |
| 7014 | 1700 | { |
| 15884 | 1701 | PurpleBuddy *buddy; |
| 1702 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1703 | JabberStream *js; |
| 7014 | 1704 | |
| 15884 | 1705 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 7014 | 1706 | |
| 15884 | 1707 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1708 | 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
|
1709 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1710 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1711 | jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), FALSE); |
| 7014 | 1712 | } |
| 1713 | ||
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1714 | static void cancel_presence_notification(gpointer data) |
| 7014 | 1715 | { |
| 15884 | 1716 | PurpleBuddy *buddy; |
| 1717 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1718 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1719 | |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1720 | buddy = data; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1721 | 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
|
1722 | 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
|
1723 | |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1724 | 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
|
1725 | } |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1726 | |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1727 | static void |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1728 | 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
|
1729 | gpointer data) |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1730 | { |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1731 | PurpleBuddy *buddy; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1732 | PurpleAccount *account; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1733 | PurpleConnection *gc; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1734 | const gchar *name; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1735 | char *msg; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1736 | |
| 15884 | 1737 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 7014 | 1738 | |
| 15884 | 1739 | buddy = (PurpleBuddy *) node; |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1740 | 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
|
1741 | 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
|
1742 | gc = purple_account_get_connection(account); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1743 | |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1744 | 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
|
1745 | "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
|
1746 | 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
|
1747 | 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
|
1748 | 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
|
1749 | g_free(msg); |
| 7014 | 1750 | } |
| 1751 | ||
| 15884 | 1752 | static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data) |
| 7250 | 1753 | { |
| 15884 | 1754 | PurpleBuddy *buddy; |
| 1755 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1756 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1757 | |
| 15884 | 1758 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
| 7250 | 1759 | |
| 15884 | 1760 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1761 | 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
|
1762 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1763 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1764 | jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "subscribe"); |
| 7250 | 1765 | } |
| 1766 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1767 | |
| 15884 | 1768 | static void jabber_buddy_unsubscribe(PurpleBlistNode *node, gpointer data) |
| 7014 | 1769 | { |
| 15884 | 1770 | PurpleBuddy *buddy; |
| 1771 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1772 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1773 | |
| 15884 | 1774 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1775 | |
| 15884 | 1776 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1777 | 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
|
1778 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1779 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1780 | 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
|
1781 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1782 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1783 | 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
|
1784 | 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
|
1785 | /* 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
|
1786 | PurpleBuddy *buddy = (PurpleBuddy *) node; |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1787 | 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
|
1788 | 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
|
1789 | 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
|
1790 | 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
|
1791 | 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
|
1792 | xmlnode *presence; |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1793 | JabberBuddyState state; |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1794 | char *msg; |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1795 | 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
|
1796 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1797 | 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
|
1798 | 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
|
1799 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1800 | 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
|
1801 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1802 | 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
|
1803 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1804 | 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
|
1805 | xmlnode_free(presence); |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1806 | } |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1807 | } |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1808 | |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1809 | 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
|
1810 | 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
|
1811 | /* 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
|
1812 | PurpleBuddy *buddy = (PurpleBuddy *) node; |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1813 | 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
|
1814 | 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
|
1815 | 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
|
1816 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1817 | 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
|
1818 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1819 | 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
|
1820 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1821 | 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
|
1822 | xmlnode_free(presence); |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1823 | } |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1824 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1825 | |
| 15884 | 1826 | static GList *jabber_buddy_menu(PurpleBuddy *buddy) |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1827 | { |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1828 | 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
|
1829 | 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
|
1830 | 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
|
1831 | 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
|
1832 | GList *jbrs; |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1833 | |
| 7014 | 1834 | GList *m = NULL; |
| 15884 | 1835 | PurpleMenuAction *act; |
| 7395 | 1836 | |
| 1837 | if(!jb) | |
| 1838 | return m; | |
| 1839 | ||
|
29849
d7b910200dc5
jabber: Treat the version properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
29811
diff
changeset
|
1840 | 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
|
1841 | jb != js->user_jb) { |
| 8166 | 1842 | if(jb->invisible & JABBER_INVIS_BUDDY) { |
| 15884 | 1843 | act = purple_menu_action_new(_("Un-hide From"), |
| 1844 | PURPLE_CALLBACK(jabber_buddy_make_visible), | |
| 12919 | 1845 | NULL, NULL); |
| 8166 | 1846 | } else { |
| 15884 | 1847 | act = purple_menu_action_new(_("Temporarily Hide From"), |
| 1848 | PURPLE_CALLBACK(jabber_buddy_make_invisible), | |
| 13019 | 1849 | NULL, NULL); |
| 8166 | 1850 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1851 | m = g_list_append(m, act); |
| 7014 | 1852 | } |
| 1853 | ||
|
28071
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1854 | if(jb->subscription & JABBER_SUB_FROM && jb != js->user_jb) { |
| 15884 | 1855 | act = purple_menu_action_new(_("Cancel Presence Notification"), |
| 1856 | PURPLE_CALLBACK(jabber_buddy_cancel_presence_notification), | |
| 12919 | 1857 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1858 | m = g_list_append(m, act); |
| 7014 | 1859 | } |
| 1860 | ||
| 1861 | if(!(jb->subscription & JABBER_SUB_TO)) { | |
| 15884 | 1862 | act = purple_menu_action_new(_("(Re-)Request authorization"), |
| 1863 | PURPLE_CALLBACK(jabber_buddy_rerequest_auth), | |
| 12919 | 1864 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1865 | m = g_list_append(m, act); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1866 | |
|
28071
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1867 | } else if (jb != js->user_jb) { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1868 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1869 | /* shouldn't this just happen automatically when the buddy is |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1870 | removed? */ |
| 15884 | 1871 | act = purple_menu_action_new(_("Unsubscribe"), |
| 1872 | PURPLE_CALLBACK(jabber_buddy_unsubscribe), | |
| 12919 | 1873 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1874 | m = g_list_append(m, act); |
| 7014 | 1875 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1876 | |
|
28667
7bab19738f5e
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents:
28611
diff
changeset
|
1877 | 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
|
1878 | 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
|
1879 | 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
|
1880 | NULL, NULL); |
|
7bab19738f5e
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents:
28611
diff
changeset
|
1881 | 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
|
1882 | } |
|
7bab19738f5e
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents:
28611
diff
changeset
|
1883 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1884 | /* |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1885 | * 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
|
1886 | * |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1887 | * 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
|
1888 | * 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
|
1889 | * 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
|
1890 | * 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
|
1891 | * |
|
8225f2507058
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
1892 | * 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
|
1893 | */ |
|
29059
8225f2507058
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
1894 | 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
|
1895 | 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
|
1896 | 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
|
1897 | NULL, NULL); |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1898 | 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
|
1899 | 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
|
1900 | 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
|
1901 | NULL, NULL); |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1902 | 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
|
1903 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1904 | |
|
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
|
1905 | /* 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
|
1906 | 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
|
1907 | 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
|
1908 | 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
|
1909 | 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
|
1910 | 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
|
1911 | 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
|
1912 | 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
|
1913 | 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
|
1914 | 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
|
1915 | } |
|
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 | } |
| 7014 | 1917 | |
| 1918 | return m; | |
| 1919 | } | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1920 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1921 | GList * |
| 15884 | 1922 | jabber_blist_node_menu(PurpleBlistNode *node) |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1923 | { |
| 15884 | 1924 | if(PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
| 1925 | return jabber_buddy_menu((PurpleBuddy *) node); | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1926 | } else { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1927 | return NULL; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1928 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1929 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1930 | |
| 12683 | 1931 | |
| 15884 | 1932 | static void user_search_result_add_buddy_cb(PurpleConnection *gc, GList *row, void *user_data) |
| 11675 | 1933 | { |
| 1934 | /* XXX find out the jid */ | |
| 15884 | 1935 | purple_blist_request_add_buddy(purple_connection_get_account(gc), |
| 11675 | 1936 | g_list_nth_data(row, 0), NULL, NULL); |
| 1937 | } | |
| 1938 | ||
|
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
|
1939 | 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
|
1940 | 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
|
1941 | xmlnode *packet, gpointer data) |
| 11675 | 1942 | { |
| 15884 | 1943 | PurpleNotifySearchResults *results; |
| 1944 | PurpleNotifySearchColumn *column; | |
| 11675 | 1945 | xmlnode *x, *query, *item, *field; |
| 1946 | ||
| 1947 | /* XXX error checking? */ | |
| 1948 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 1949 | return; | |
| 1950 | ||
| 15884 | 1951 | results = purple_notify_searchresults_new(); |
| 11675 | 1952 | if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) { |
| 1953 | 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
|
1954 | 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
|
1955 | |
| 15884 | 1956 | 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
|
1957 | |
| 11675 | 1958 | if((reported = xmlnode_get_child(x, "reported"))) { |
| 1959 | xmlnode *field = xmlnode_get_child(reported, "field"); | |
| 1960 | while(field) { | |
| 1961 | const char *var = xmlnode_get_attrib(field, "var"); | |
| 1962 | const char *label = xmlnode_get_attrib(field, "label"); | |
| 1963 | if(var) { | |
| 15884 | 1964 | column = purple_notify_searchresults_column_new(label ? label : var); |
| 1965 | 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
|
1966 | column_vars = g_slist_append(column_vars, (char *)var); |
| 11675 | 1967 | } |
| 1968 | field = xmlnode_get_next_twin(field); | |
| 1969 | } | |
| 1970 | } | |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1971 | |
| 11675 | 1972 | item = xmlnode_get_child(x, "item"); |
| 1973 | while(item) { | |
| 1974 | 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
|
1975 | GSList *l; |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1976 | xmlnode *valuenode; |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1977 | 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
|
1978 | |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1979 | 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
|
1980 | /* |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1981 | * 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
|
1982 | * 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
|
1983 | */ |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1984 | 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
|
1985 | field != NULL; |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1986 | 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
|
1987 | { |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1988 | 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
|
1989 | !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
|
1990 | (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
|
1991 | { |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1992 | 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
|
1993 | 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
|
1994 | break; |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1995 | } |
| 11675 | 1996 | } |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1997 | 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
|
1998 | /* 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
|
1999 | row = g_list_append(row, NULL); |
| 11675 | 2000 | } |
| 15884 | 2001 | purple_notify_searchresults_row_add(results, row); |
| 11675 | 2002 | item = xmlnode_get_next_twin(item); |
| 2003 | } | |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2004 | |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2005 | g_slist_free(column_vars); |
| 11675 | 2006 | } else { |
| 2007 | /* old skool */ | |
| 15884 | 2008 | purple_debug_info("jabber", "old-skool\n"); |
| 11675 | 2009 | |
| 15884 | 2010 | column = purple_notify_searchresults_column_new(_("JID")); |
| 2011 | purple_notify_searchresults_column_add(results, column); | |
| 2012 | column = purple_notify_searchresults_column_new(_("First Name")); | |
| 2013 | purple_notify_searchresults_column_add(results, column); | |
| 2014 | column = purple_notify_searchresults_column_new(_("Last Name")); | |
| 2015 | purple_notify_searchresults_column_add(results, column); | |
| 2016 | column = purple_notify_searchresults_column_new(_("Nickname")); | |
| 2017 | 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
|
2018 | column = purple_notify_searchresults_column_new(_("Email")); |
| 15884 | 2019 | purple_notify_searchresults_column_add(results, column); |
| 11675 | 2020 | |
| 2021 | for(item = xmlnode_get_child(query, "item"); item; item = xmlnode_get_next_twin(item)) { | |
| 2022 | const char *jid; | |
| 2023 | xmlnode *node; | |
| 2024 | GList *row = NULL; | |
| 2025 | ||
| 2026 | if(!(jid = xmlnode_get_attrib(item, "jid"))) | |
| 2027 | continue; | |
| 2028 | ||
| 2029 | row = g_list_append(row, g_strdup(jid)); | |
| 2030 | node = xmlnode_get_child(item, "first"); | |
| 2031 | row = g_list_append(row, node ? xmlnode_get_data(node) : NULL); | |
| 2032 | node = xmlnode_get_child(item, "last"); | |
| 2033 | row = g_list_append(row, node ? xmlnode_get_data(node) : NULL); | |
| 2034 | node = xmlnode_get_child(item, "nick"); | |
| 2035 | row = g_list_append(row, node ? xmlnode_get_data(node) : NULL); | |
| 2036 | node = xmlnode_get_child(item, "email"); | |
| 2037 | 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
|
2038 | purple_debug_info("jabber", "row=%p\n", row); |
| 15884 | 2039 | purple_notify_searchresults_row_add(results, row); |
| 11675 | 2040 | } |
| 2041 | } | |
| 2042 | ||
| 15884 | 2043 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD, |
| 11675 | 2044 | user_search_result_add_buddy_cb); |
| 2045 | ||
| 15884 | 2046 | purple_notify_searchresults(js->gc, NULL, NULL, _("The following are the results of your search"), results, NULL, NULL); |
| 11675 | 2047 | } |
| 2048 | ||
| 2049 | static void user_search_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) | |
| 2050 | { | |
| 2051 | xmlnode *query; | |
| 2052 | JabberIq *iq; | |
| 13345 | 2053 | char *dir_server = data; |
|
21388
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2054 | const char *type; |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2055 | |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2056 | /* 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
|
2057 | * 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
|
2058 | * a cancel, so skip it */ |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2059 | type = xmlnode_get_attrib(result, "type"); |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2060 | if(type && !strcmp(type, "cancel")) { |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2061 | g_free(dir_server); |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2062 | return; |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2063 | } |
| 11675 | 2064 | |
| 2065 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search"); | |
| 2066 | query = xmlnode_get_child(iq->node, "query"); | |
| 2067 | ||
| 2068 | xmlnode_insert_child(query, result); | |
| 2069 | ||
| 2070 | jabber_iq_set_callback(iq, user_search_result_cb, NULL); | |
| 13345 | 2071 | xmlnode_set_attrib(iq->node, "to", dir_server); |
| 11675 | 2072 | jabber_iq_send(iq); |
| 13345 | 2073 | g_free(dir_server); |
| 11675 | 2074 | } |
| 2075 | ||
| 2076 | struct user_search_info { | |
| 2077 | JabberStream *js; | |
| 2078 | char *directory_server; | |
| 2079 | }; | |
| 2080 | ||
| 15884 | 2081 | static void user_search_cancel_cb(struct user_search_info *usi, PurpleRequestFields *fields) |
| 11675 | 2082 | { |
| 2083 | g_free(usi->directory_server); | |
| 2084 | g_free(usi); | |
| 2085 | } | |
| 2086 | ||
| 15884 | 2087 | static void user_search_cb(struct user_search_info *usi, PurpleRequestFields *fields) |
| 11675 | 2088 | { |
| 2089 | JabberStream *js = usi->js; | |
| 2090 | JabberIq *iq; | |
| 2091 | xmlnode *query; | |
| 2092 | GList *groups, *flds; | |
| 2093 | ||
| 2094 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search"); | |
| 2095 | query = xmlnode_get_child(iq->node, "query"); | |
| 2096 | ||
| 15884 | 2097 | for(groups = purple_request_fields_get_groups(fields); groups; groups = groups->next) { |
| 2098 | for(flds = purple_request_field_group_get_fields(groups->data); | |
| 11675 | 2099 | flds; flds = flds->next) { |
| 15884 | 2100 | PurpleRequestField *field = flds->data; |
| 2101 | const char *id = purple_request_field_get_id(field); | |
| 2102 | const char *value = purple_request_field_string_get_value(field); | |
| 11675 | 2103 | |
| 2104 | if(value && (!strcmp(id, "first") || !strcmp(id, "last") || !strcmp(id, "nick") || !strcmp(id, "email"))) { | |
| 2105 | xmlnode *y = xmlnode_new_child(query, id); | |
| 2106 | xmlnode_insert_data(y, value, -1); | |
| 2107 | } | |
| 2108 | } | |
| 2109 | } | |
| 2110 | ||
| 2111 | jabber_iq_set_callback(iq, user_search_result_cb, NULL); | |
| 2112 | xmlnode_set_attrib(iq->node, "to", usi->directory_server); | |
| 2113 | jabber_iq_send(iq); | |
| 2114 | ||
| 2115 | g_free(usi->directory_server); | |
| 2116 | g_free(usi); | |
| 2117 | } | |
| 2118 | ||
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2119 | #if 0 |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2120 | /* 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
|
2121 | |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2122 | /* |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2123 | * 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
|
2124 | * comments for Jabber User Directories |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2125 | * |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2126 | * See discussion thread "Search comment for Jabber is not translatable" |
| 15884 | 2127 | * 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
|
2128 | */ |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2129 | 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
|
2130 | /* 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
|
2131 | 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
|
2132 | "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
|
2133 | NULL |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2134 | }; |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2135 | #endif |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2136 | |
|
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
|
2137 | 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
|
2138 | 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
|
2139 | xmlnode *packet, gpointer data) |
| 11675 | 2140 | { |
| 2141 | xmlnode *query, *x; | |
| 2142 | ||
|
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
|
2143 | if (!from) |
| 11675 | 2144 | return; |
| 2145 | ||
|
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
|
2146 | 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
|
2147 | char *msg = jabber_parse_error(js, packet, NULL); |
| 13794 | 2148 | |
|
13634
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2149 | if(!msg) |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2150 | msg = g_strdup(_("Unknown error")); |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2151 | |
| 15884 | 2152 | 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
|
2153 | _("Could not query the directory server."), msg); |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2154 | g_free(msg); |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2155 | |
| 13345 | 2156 | return; |
| 2157 | } | |
| 2158 | ||
| 11675 | 2159 | |
| 2160 | if(!(query = xmlnode_get_child(packet, "query"))) | |
| 2161 | return; | |
| 2162 | ||
| 13330 | 2163 | if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) { |
| 13345 | 2164 | jabber_x_data_request(js, x, user_search_x_data_cb, g_strdup(from)); |
| 11675 | 2165 | return; |
| 2166 | } else { | |
| 2167 | struct user_search_info *usi; | |
| 2168 | xmlnode *instnode; | |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2169 | char *instructions = NULL; |
| 15884 | 2170 | PurpleRequestFields *fields; |
| 2171 | PurpleRequestFieldGroup *group; | |
| 2172 | PurpleRequestField *field; | |
| 11675 | 2173 | |
| 2174 | /* old skool */ | |
| 15884 | 2175 | fields = purple_request_fields_new(); |
| 2176 | group = purple_request_field_group_new(NULL); | |
| 2177 | purple_request_fields_add_group(fields, group); | |
| 11675 | 2178 | |
| 2179 | if((instnode = xmlnode_get_child(query, "instructions"))) | |
|
13574
433001d94e3e
[gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents:
13572
diff
changeset
|
2180 | { |
|
433001d94e3e
[gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents:
13572
diff
changeset
|
2181 | char *tmp = xmlnode_get_data(instnode); |
| 13794 | 2182 | |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2183 | if(tmp) |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2184 | { |
| 13794 | 2185 | /* 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
|
2186 | list in jabber_user_dir_comments[]) */ |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2187 | instructions = g_strdup_printf(_("Server Instructions: %s"), _(tmp)); |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2188 | g_free(tmp); |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2189 | } |
|
13574
433001d94e3e
[gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents:
13572
diff
changeset
|
2190 | } |
| 13794 | 2191 | |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2192 | if(!instructions) |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2193 | { |
| 11675 | 2194 | 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
|
2195 | "for any matching XMPP users.")); |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2196 | } |
| 11675 | 2197 | |
| 2198 | if(xmlnode_get_child(query, "first")) { | |
| 15884 | 2199 | field = purple_request_field_string_new("first", _("First Name"), |
| 11675 | 2200 | NULL, FALSE); |
| 15884 | 2201 | purple_request_field_group_add_field(group, field); |
| 11675 | 2202 | } |
| 2203 | if(xmlnode_get_child(query, "last")) { | |
| 15884 | 2204 | field = purple_request_field_string_new("last", _("Last Name"), |
| 11675 | 2205 | NULL, FALSE); |
| 15884 | 2206 | purple_request_field_group_add_field(group, field); |
| 11675 | 2207 | } |
| 2208 | if(xmlnode_get_child(query, "nick")) { | |
| 15884 | 2209 | field = purple_request_field_string_new("nick", _("Nickname"), |
| 11675 | 2210 | NULL, FALSE); |
| 15884 | 2211 | purple_request_field_group_add_field(group, field); |
| 11675 | 2212 | } |
| 2213 | 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
|
2214 | field = purple_request_field_string_new("email", _("Email Address"), |
| 11675 | 2215 | NULL, FALSE); |
| 15884 | 2216 | purple_request_field_group_add_field(group, field); |
| 11675 | 2217 | } |
| 2218 | ||
| 2219 | usi = g_new0(struct user_search_info, 1); | |
| 2220 | usi->js = js; | |
| 2221 | usi->directory_server = g_strdup(from); | |
| 2222 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
2223 | 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
|
2224 | _("Search for XMPP users"), instructions, fields, |
| 11675 | 2225 | _("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
|
2226 | _("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
|
2227 | purple_connection_get_account(js->gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
2228 | usi); |
| 11675 | 2229 | |
| 2230 | g_free(instructions); | |
| 2231 | } | |
| 2232 | } | |
| 2233 | ||
|
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
|
2234 | void jabber_user_search(JabberStream *js, const char *directory) |
| 11675 | 2235 | { |
| 2236 | JabberIq *iq; | |
| 2237 | ||
| 2238 | /* XXX: should probably better validate the directory we're given */ | |
| 2239 | if(!directory || !*directory) { | |
| 15884 | 2240 | purple_notify_error(js->gc, _("Invalid Directory"), _("Invalid Directory"), NULL); |
| 11675 | 2241 | return; |
| 2242 | } | |
| 2243 | ||
| 2244 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:search"); | |
| 2245 | xmlnode_set_attrib(iq->node, "to", directory); | |
| 2246 | ||
| 2247 | jabber_iq_set_callback(iq, user_search_fields_result_cb, NULL); | |
| 2248 | ||
| 2249 | jabber_iq_send(iq); | |
| 2250 | } | |
| 2251 | ||
| 15884 | 2252 | void jabber_user_search_begin(PurplePluginAction *action) |
| 11675 | 2253 | { |
| 15884 | 2254 | PurpleConnection *gc = (PurpleConnection *) action->context; |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
2255 | JabberStream *js = purple_connection_get_protocol_data(gc); |
| 11675 | 2256 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
2257 | purple_request_input(gc, _("Enter a User Directory"), _("Enter a User Directory"), |
| 11675 | 2258 | _("Select a user directory to search"), |
|
17007
66c0fa6e5e2a
Removes 'jabber.org' defaults from XMPP. I think we had agreed this was a good idea.
Sean Egan <seanegan@pidgin.im>
parents:
16961
diff
changeset
|
2259 | js->user_directories ? js->user_directories->data : NULL, |
| 11675 | 2260 | 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
|
2261 | _("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
|
2262 | _("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
|
2263 | NULL, NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
2264 | js); |
| 11675 | 2265 | } |
| 13794 | 2266 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2267 | 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
|
2268 | 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
|
2269 | { |
|
27cc8217e86e
jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents:
28828
diff
changeset
|
2270 | 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
|
2271 | } |
|
27cc8217e86e
jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents:
28828
diff
changeset
|
2272 | |
|
27cc8217e86e
jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents:
28828
diff
changeset
|
2273 | gboolean |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2274 | 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
|
2275 | { |
|
24802
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24732
diff
changeset
|
2276 | 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
|
2277 | const JabberCapsNodeExts *exts; |
| 13794 | 2278 | |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
2279 | if (!jbr->caps.info) { |
|
27696
2cd9b9331f06
Lower the severity of this message.
Paul Aurich <darkrain42@pidgin.im>
parents:
27619
diff
changeset
|
2280 | 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
|
2281 | "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
|
2282 | return FALSE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2283 | } |
| 13794 | 2284 | |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
2285 | 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
|
2286 | 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
|
2287 | const GList *ext; |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
2288 | 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
|
2289 | /* 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
|
2290 | * 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
|
2291 | 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
|
2292 | 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
|
2293 | if (features) |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
2294 | 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
|
2295 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2296 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2297 | |
|
24802
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24732
diff
changeset
|
2298 | return (node != NULL); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2299 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2300 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2301 | gboolean |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2302 | 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
|
2303 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2304 | 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
|
2305 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2306 | 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
|
2307 | 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
|
2308 | "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
|
2309 | return FALSE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2310 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2311 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2312 | 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
|
2313 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2314 | |
|
25577
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2315 | const gchar * |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2316 | 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
|
2317 | const gchar *category) |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2318 | { |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2319 | const GList *iter = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2320 | |
|
27286
f637c4c27815
Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents:
27285
diff
changeset
|
2321 | if (jbr->caps.info) { |
|
f637c4c27815
Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents:
27285
diff
changeset
|
2322 | 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
|
2323 | const JabberIdentity *identity = |
|
27286
f637c4c27815
Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents:
27285
diff
changeset
|
2324 | (JabberIdentity *) iter->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2325 | |
|
25577
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2326 | 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
|
2327 | return identity->type; |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2328 | } |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2329 | } |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2330 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2331 | |
|
25577
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2332 | return NULL; |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2333 | } |