Thu, 15 Jun 2017 13:33:02 -0500
Remove purple_timeout_* function usage
Now that the purple_timeout_* functions internally just use their
GLib equivalents, we can just replace them with the GLib equivalents.
This patch replaces purple_timeout_* functions with
g_timeout_add{_seconds}() and g_source_remove() functions.
There are probably places in this which could use g_timeout_add_full()
or g_idle_add{_full}(), but this was a straight replacement to keep
the functionality identical for now. Further patches can update to use
these instead if desired.
| 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" | |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
25 | #include "image-store.h" |
|
36543
a8c3fecee2d3
Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents:
36496
diff
changeset
|
26 | #include "protocol.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; |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
54 | GSList *vcard_images; |
|
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; |
|
38266
7c1706b2bd11
Remove found redundant NULL checks
qarkai <qarkai@gmail.com>
parents:
38260
diff
changeset
|
221 | if (purple_strequal(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 | /* | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
390 | * Insert a tag node into an PurpleXmlNode tree, recursively inserting parent tag |
| 7014 | 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 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
398 | static PurpleXmlNode *insert_tag_to_parent_tag(PurpleXmlNode *start, const char *parent_tag, const char *new_tag) |
| 7014 | 399 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
400 | PurpleXmlNode *x = NULL; |
| 7014 | 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) { | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
410 | if(purple_strequal(vc_tp->tag, new_tag)) { |
| 7014 | 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 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
425 | if((x = purple_xmlnode_get_child(start, parent_tag)) == NULL) { |
| 7014 | 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 { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
436 | x = purple_xmlnode_new_child(start, grand_parent); |
| 7014 | 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 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
444 | PurpleXmlNode *y; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
445 | if((y = purple_xmlnode_get_child(x, new_tag)) != NULL) { |
| 7014 | 446 | return(y); |
| 447 | } | |
| 448 | } | |
| 449 | } | |
| 450 | ||
| 451 | /* | |
| 452 | * insert the new tag into its parent node | |
| 453 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
454 | return(purple_xmlnode_new_child((x == NULL? start : x), new_tag)); |
| 7014 | 455 | } |
| 456 | ||
| 457 | /* | |
| 458 | * Send vCard info to Jabber server | |
| 459 | */ | |
| 15884 | 460 | void jabber_set_info(PurpleConnection *gc, const char *info) |
| 7014 | 461 | { |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
462 | PurpleImage *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); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
465 | PurpleXmlNode *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) { |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
471 | PurpleImage *image; |
|
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
|
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) { |
|
38327
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
475 | js->initial_avatar_hash = g_compute_checksum_for_data( |
|
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
476 | G_CHECKSUM_SHA1, |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
477 | purple_image_get_data(image), |
|
38334
cb3f85d86752
Merge/update port to GChecksum changes, resolving conflicts
Mike Ruprecht <cmaiku@gmail.com>
diff
changeset
|
478 | purple_image_get_data_size(image) |
|
38298
f0a8f63f9312
rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents:
37134
diff
changeset
|
479 | ); |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
480 | g_object_unref(image); |
|
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
|
481 | } 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
|
482 | 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
|
483 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
484 | 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
|
485 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
486 | |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
487 | if (js->vcard_timer) { |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
488 | g_source_remove(js->vcard_timer); |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
489 | js->vcard_timer = 0; |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
490 | } |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
491 | |
|
15273
a7838f939207
[gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
492 | g_free(js->avatar_hash); |
| 10189 | 493 | js->avatar_hash = NULL; |
| 7014 | 494 | |
| 495 | /* | |
| 496 | * Send only if there's actually any *information* to send | |
| 497 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
498 | vc_node = info ? purple_xmlnode_from_str(info, -1) : NULL; |
| 10189 | 499 | |
|
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
|
500 | 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
|
501 | g_ascii_strncasecmp(vc_node->name, "vCard", 5))) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
502 | purple_xmlnode_free(vc_node); |
|
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
|
503 | vc_node = NULL; |
| 10189 | 504 | } |
| 7014 | 505 | |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32277
diff
changeset
|
506 | if ((img = purple_buddy_icons_find_account_icon(purple_connection_get_account(gc)))) { |
|
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
|
507 | 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
|
508 | gsize avatar_len; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
509 | PurpleXmlNode *photo, *binval, *type; |
|
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 | gchar *enc; |
| 10189 | 511 | |
|
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
|
512 | if(!vc_node) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
513 | vc_node = purple_xmlnode_new("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
|
514 | for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
515 | purple_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
|
516 | } |
| 10189 | 517 | |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
518 | avatar_data = purple_image_get_data(img); |
|
38298
f0a8f63f9312
rename purple_image_get_size to purple_image_get_data_size and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents:
37134
diff
changeset
|
519 | avatar_len = purple_image_get_data_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
|
520 | /* 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
|
521 | * 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
|
522 | * 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
|
523 | * multiple PHOTO entries in their vCard. */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
524 | if((photo = purple_xmlnode_get_child(vc_node, "PHOTO"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
525 | purple_xmlnode_free(photo); |
|
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
|
526 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
527 | photo = purple_xmlnode_new_child(vc_node, "PHOTO"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
528 | type = purple_xmlnode_new_child(photo, "TYPE"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
529 | purple_xmlnode_insert_data(type, "image/png", -1); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
530 | binval = purple_xmlnode_new_child(photo, "BINVAL"); |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38334
diff
changeset
|
531 | enc = g_base64_encode(avatar_data, avatar_len); |
|
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
|
532 | |
|
38327
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
533 | js->avatar_hash = g_compute_checksum_for_data(G_CHECKSUM_SHA1, |
|
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
534 | avatar_data, avatar_len); |
|
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
|
535 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
536 | purple_xmlnode_insert_data(binval, enc, -1); |
|
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
|
537 | g_free(enc); |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
538 | g_object_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
|
539 | } else if (vc_node) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
540 | PurpleXmlNode *photo; |
|
25386
7ca88088e0de
Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents:
25385
diff
changeset
|
541 | /* TODO: Remove all PHOTO children? (see above note) */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
542 | if ((photo = purple_xmlnode_get_child(vc_node, "PHOTO"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
543 | purple_xmlnode_free(photo); |
|
25386
7ca88088e0de
Allow us to remove vCard avatars when the PurpleAccount doesn't have one
Paul Aurich <darkrain42@pidgin.im>
parents:
25385
diff
changeset
|
544 | } |
|
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
|
545 | } |
|
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
|
546 | |
|
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
|
547 | if (vc_node != NULL) { |
|
15273
a7838f939207
[gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
548 | iq = jabber_iq_new(js, JABBER_IQ_SET); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
549 | purple_xmlnode_insert_child(iq->node, vc_node); |
|
15273
a7838f939207
[gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
550 | 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
|
551 | |
|
0a7f22678a35
Send presence updates from jabber_set_info, not jabber_set_buddy_icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
552 | /* 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
|
553 | jabber_presence_send(js, FALSE); |
| 7014 | 554 | } |
| 555 | } | |
| 556 | ||
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
557 | void jabber_set_buddy_icon(PurpleConnection *gc, PurpleImage *img) |
| 10189 | 558 | { |
|
25811
57012229a242
Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents:
25542
diff
changeset
|
559 | PurpleAccount *account = purple_connection_get_account(gc); |
| 10189 | 560 | |
|
26950
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26947
diff
changeset
|
561 | /* Publish the avatar as specified in XEP-0084 */ |
|
32277
97f16af01a05
Convert jabber prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32204
diff
changeset
|
562 | jabber_avatar_set(purple_connection_get_protocol_data(gc), img); |
|
26950
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26947
diff
changeset
|
563 | /* 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
|
564 | 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
|
565 | |
|
25811
57012229a242
Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents:
25542
diff
changeset
|
566 | /* 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
|
567 | * 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
|
568 | * 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
|
569 | * an existing icon/stored image). */ |
| 10189 | 570 | } |
| 571 | ||
| 7014 | 572 | /* |
| 573 | * This is the callback from the "ok clicked" for "set vCard" | |
| 574 | * | |
|
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
|
575 | * Sets the vCard with data from PurpleRequestFields. |
| 7014 | 576 | */ |
| 577 | static void | |
| 15884 | 578 | jabber_format_info(PurpleConnection *gc, PurpleRequestFields *fields) |
| 7014 | 579 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
580 | PurpleXmlNode *vc_node; |
| 15884 | 581 | PurpleRequestField *field; |
| 7014 | 582 | const char *text; |
| 583 | char *p; | |
| 584 | 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
|
585 | const struct tag_attr *tag_attr; |
| 7014 | 586 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
587 | vc_node = purple_xmlnode_new("vCard"); |
| 7014 | 588 | |
| 589 | for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr) | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
590 | purple_xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value); |
| 7014 | 591 | |
| 592 | for (vc_tp = vcard_template_data; vc_tp->label != NULL; vc_tp++) { | |
| 593 | if (*vc_tp->label == '\0') | |
| 594 | continue; | |
| 595 | ||
| 15884 | 596 | field = purple_request_fields_get_field(fields, vc_tp->tag); |
| 597 | text = purple_request_field_string_get_value(field); | |
| 7014 | 598 | |
| 599 | ||
| 600 | if (text != NULL && *text != '\0') { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
601 | PurpleXmlNode *xp; |
| 7014 | 602 | |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28667
diff
changeset
|
603 | purple_debug_info("jabber", "Setting %s to '%s'\n", vc_tp->tag, text); |
| 9339 | 604 | |
| 7014 | 605 | if ((xp = insert_tag_to_parent_tag(vc_node, |
| 606 | NULL, vc_tp->tag)) != NULL) { | |
| 607 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
608 | purple_xmlnode_insert_data(xp, text, -1); |
| 7014 | 609 | } |
| 610 | } | |
| 611 | } | |
| 612 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
613 | p = purple_xmlnode_to_str(vc_node, NULL); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
614 | purple_xmlnode_free(vc_node); |
| 7014 | 615 | |
| 15884 | 616 | purple_account_set_user_info(purple_connection_get_account(gc), p); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
617 | purple_serv_set_info(gc, p); |
| 7014 | 618 | |
| 619 | g_free(p); | |
| 620 | } | |
| 621 | ||
| 622 | /* | |
| 623 | * This gets executed by the proto action | |
| 624 | * | |
| 15884 | 625 | * Creates a new PurpleRequestFields struct, gets the XML-formatted user_info |
| 7014 | 626 | * string (if any) into GSLists for the (multi-entry) edit dialog and |
| 627 | * calls the set_vcard dialog. | |
| 628 | */ | |
|
36496
e7fe371c60a6
Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
629 | void jabber_setup_set_info(PurpleProtocolAction *action) |
| 7014 | 630 | { |
|
36496
e7fe371c60a6
Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
631 | PurpleConnection *gc = (PurpleConnection *) action->connection; |
| 15884 | 632 | PurpleRequestFields *fields; |
| 633 | PurpleRequestFieldGroup *group; | |
| 634 | PurpleRequestField *field; | |
| 7014 | 635 | const struct vcard_template *vc_tp; |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
636 | const char *user_info; |
|
14130
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
637 | char *cdata = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
638 | PurpleXmlNode *x_vc_data = NULL; |
| 7014 | 639 | |
| 15884 | 640 | fields = purple_request_fields_new(); |
| 641 | group = purple_request_field_group_new(NULL); | |
| 642 | purple_request_fields_add_group(fields, group); | |
| 7014 | 643 | |
| 644 | /* | |
| 645 | * Get existing, XML-formatted, user info | |
| 646 | */ | |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32277
diff
changeset
|
647 | if((user_info = purple_account_get_user_info(purple_connection_get_account(gc))) != NULL) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
648 | x_vc_data = purple_xmlnode_from_str(user_info, -1); |
| 7014 | 649 | |
| 650 | /* | |
| 651 | * Set up GSLists for edit with labels from "template," data from user info | |
| 652 | */ | |
| 653 | for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
654 | PurpleXmlNode *data_node; |
| 7014 | 655 | if((vc_tp->label)[0] == '\0') |
| 656 | continue; | |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
657 | |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
658 | if (x_vc_data != NULL) { |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
659 | if(vc_tp->ptag == NULL) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
660 | data_node = purple_xmlnode_get_child(x_vc_data, vc_tp->tag); |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
661 | } else { |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
662 | gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
663 | data_node = purple_xmlnode_get_child(x_vc_data, tag); |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
664 | g_free(tag); |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
665 | } |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
666 | if(data_node) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
667 | cdata = purple_xmlnode_get_data(data_node); |
|
14130
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
668 | } |
| 7014 | 669 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
670 | if(purple_strequal(vc_tp->tag, "DESC")) { |
| 15884 | 671 | field = purple_request_field_string_new(vc_tp->tag, |
| 7014 | 672 | _(vc_tp->label), cdata, |
| 673 | TRUE); | |
| 674 | } else { | |
| 15884 | 675 | field = purple_request_field_string_new(vc_tp->tag, |
| 7014 | 676 | _(vc_tp->label), cdata, |
| 677 | FALSE); | |
| 678 | } | |
| 679 | ||
|
14130
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
680 | g_free(cdata); |
|
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
681 | cdata = NULL; |
|
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
682 | |
| 15884 | 683 | purple_request_field_group_add_field(group, field); |
| 7014 | 684 | } |
| 685 | ||
| 686 | if(x_vc_data != NULL) | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
687 | purple_xmlnode_free(x_vc_data); |
| 7014 | 688 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
689 | 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
|
690 | _("Edit XMPP vCard"), |
| 7014 | 691 | _("All items below are optional. Enter only the " |
| 692 | "information with which you feel comfortable."), | |
| 693 | fields, | |
| 694 | _("Save"), G_CALLBACK(jabber_format_info), | |
| 695 | _("Cancel"), NULL, | |
|
34332
876483829700
Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
696 | purple_request_cpar_from_connection(gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
697 | gc); |
| 7014 | 698 | } |
| 699 | ||
| 700 | /*---------------------------------------*/ | |
| 701 | /* End Jabber "set info" (vCard) support */ | |
| 702 | /*---------------------------------------*/ | |
| 703 | ||
| 704 | /****** | |
| 705 | * end of that ancient crap that needs to die | |
| 706 | ******/ | |
| 707 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
708 | static void jabber_buddy_info_destroy(JabberBuddyInfo *jbi) |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
709 | { |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
710 | /* 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
|
711 | if (jbi->timeout_handle > 0) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
712 | g_source_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
|
713 | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
714 | g_free(jbi->jid); |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
715 | 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
|
716 | 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
|
717 | 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
|
718 | g_free(jbi); |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
719 | } |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
720 | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
721 | static void |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
722 | 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
|
723 | JabberBuddyResource *jbr) |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
724 | { |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
725 | JabberBuddyInfoResource *jbir; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
726 | PurpleNotifyUserInfo *user_info; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
727 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
728 | 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
|
729 | 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
|
730 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
731 | if (jbr && jbr->client.name) { |
| 27551 | 732 | char *tmp = |
| 733 | g_strdup_printf("%s%s%s", jbr->client.name, | |
| 734 | (jbr->client.version ? " " : ""), | |
| 735 | (jbr->client.version ? jbr->client.version : "")); | |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
736 | /* TODO: Check whether it's correct to call prepend_pair_html, |
|
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
737 | or if we should be using prepend_pair_plaintext */ |
|
32204
2a09624616c3
Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents:
32203
diff
changeset
|
738 | purple_notify_user_info_prepend_pair_html(user_info, _("Client"), tmp); |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
739 | g_free(tmp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
740 | |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
741 | if (jbr->client.os) { |
|
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
742 | /* TODO: Check whether it's correct to call prepend_pair_html, |
|
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
743 | or if we should be using prepend_pair_plaintext */ |
|
32204
2a09624616c3
Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents:
32203
diff
changeset
|
744 | purple_notify_user_info_prepend_pair_html(user_info, _("Operating System"), jbr->client.os); |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
745 | } |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
746 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
747 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
748 | 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
|
749 | time_t now_t; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
750 | struct tm *now; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
751 | char *timestamp; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
752 | time(&now_t); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
753 | 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
|
754 | now = gmtime(&now_t); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
755 | |
| 27551 | 756 | timestamp = |
| 757 | g_strdup_printf("%s %c%02d%02d", purple_time_format(now), | |
| 758 | jbr->tz_off < 0 ? '-' : '+', | |
| 759 | abs(jbr->tz_off / (60*60)), | |
| 760 | abs((jbr->tz_off % (60*60)) / 60)); | |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
761 | purple_notify_user_info_prepend_pair_plaintext(user_info, _("Local Time"), timestamp); |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
762 | g_free(timestamp); |
|
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 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
765 | 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
|
766 | char *idle = purple_str_seconds_to_string(jbir->idle_seconds); |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
767 | purple_notify_user_info_prepend_pair_plaintext(user_info, _("Idle"), idle); |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
768 | g_free(idle); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
769 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
770 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
771 | if (jbr) { |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
772 | char *purdy = NULL; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
773 | char *tmp; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
774 | char priority[12]; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
775 | 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
|
776 | |
| 27551 | 777 | 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
|
778 | 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
|
779 | 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
|
780 | g_free(tmp); |
| 27551 | 781 | |
| 782 | if (purple_strequal(status_name, purdy)) | |
| 783 | status_name = NULL; | |
| 784 | } | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
785 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
786 | 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
|
787 | ((status_name && purdy) ? ": " : ""), |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
788 | (purdy ? purdy : "")); |
|
32204
2a09624616c3
Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents:
32203
diff
changeset
|
789 | purple_notify_user_info_prepend_pair_html(user_info, _("Status"), tmp); |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
790 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
791 | g_snprintf(priority, sizeof(priority), "%d", jbr->priority); |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
792 | purple_notify_user_info_prepend_pair_plaintext(user_info, _("Priority"), priority); |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
793 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
794 | g_free(tmp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
795 | g_free(purdy); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
796 | } else { |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
797 | purple_notify_user_info_prepend_pair_plaintext(user_info, _("Status"), _("Unknown")); |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
798 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
799 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
800 | |
| 13794 | 801 | static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi) |
| 7014 | 802 | { |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
803 | char *resource_name; |
| 13794 | 804 | JabberBuddyResource *jbr; |
| 805 | GList *resources; | |
| 15884 | 806 | PurpleNotifyUserInfo *user_info; |
| 7014 | 807 | |
| 13794 | 808 | /* not yet */ |
| 27551 | 809 | if (jbi->ids) |
| 11361 | 810 | return; |
| 811 | ||
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
812 | user_info = jbi->user_info; |
| 13794 | 813 | resource_name = jabber_get_resource(jbi->jid); |
| 7014 | 814 | |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
815 | /* If we have one or more pairs from the vcard, put a section break above it */ |
|
32193
42173d1c1317
Change PurpleNotifyUserInfo->user_info_entries from a GList to a GQueue.
Mark Doliner <markdoliner@pidgin.im>
parents:
32191
diff
changeset
|
816 | if (g_queue_get_length(purple_notify_user_info_get_entries(user_info))) |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
817 | 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
|
818 | |
| 27551 | 819 | /* Add the information about the user's resource(s) */ |
| 820 | if (resource_name) { | |
| 13794 | 821 | 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
|
822 | add_jbr_info(jbi, resource_name, jbr); |
| 7014 | 823 | } else { |
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
824 | /* 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
|
825 | * 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
|
826 | for (resources = jbi->jb->resources; resources; resources = resources->next) { |
| 7014 | 827 | 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
|
828 | |
|
27053
fb088f01758d
Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents:
26958
diff
changeset
|
829 | /* 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
|
830 | 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
|
831 | section */ |
| 27551 | 832 | 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
|
833 | 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
|
834 | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
835 | add_jbr_info(jbi, jbr->name, jbr); |
| 13794 | 836 | |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
837 | if (jbr->name) { |
|
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
838 | /* TODO: Check whether it's correct to call prepend_pair_html, |
|
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
839 | or if we should be using prepend_pair_plaintext */ |
|
32204
2a09624616c3
Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents:
32203
diff
changeset
|
840 | purple_notify_user_info_prepend_pair_html(user_info, _("Resource"), jbr->name); |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
841 | } |
| 7014 | 842 | } |
| 843 | } | |
| 844 | ||
|
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
|
845 | 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
|
846 | /* 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
|
847 | 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
|
848 | |
|
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
|
849 | 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
|
850 | 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
|
851 | 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
|
852 | 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
|
853 | 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
|
854 | 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
|
855 | message = last; |
|
6218763ad5b4
This string is already translated; so it need not be translated again.
Paul Aurich <darkrain42@pidgin.im>
parents:
29097
diff
changeset
|
856 | 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
|
857 | } 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
|
858 | 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
|
859 | 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
|
860 | } |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
861 | purple_notify_user_info_prepend_pair_plaintext(user_info, title, message); |
|
27069
8eabf79a99fe
Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents:
27053
diff
changeset
|
862 | 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
|
863 | 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
|
864 | } |
|
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
|
865 | |
|
29097
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
866 | if (!is_domain) { |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
867 | gchar *status = |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
868 | g_strdup_printf("%s%s%s", _("Offline"), |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
869 | jbi->last_message ? ": " : "", |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
870 | jbi->last_message ? jbi->last_message : ""); |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
871 | /* TODO: Check whether it's correct to call prepend_pair_html, |
|
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
872 | or if we should be using prepend_pair_plaintext */ |
|
32204
2a09624616c3
Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents:
32203
diff
changeset
|
873 | purple_notify_user_info_prepend_pair_html(user_info, _("Status"), status); |
|
29097
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
874 | g_free(status); |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
875 | } |
|
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
|
876 | } |
|
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
|
877 | |
| 7306 | 878 | g_free(resource_name); |
| 879 | ||
| 15884 | 880 | purple_notify_userinfo(jbi->js->gc, jbi->jid, user_info, NULL, NULL); |
| 13794 | 881 | |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
882 | while (jbi->vcard_images) { |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
883 | g_object_unref(jbi->vcard_images->data); |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
884 | jbi->vcard_images = g_slist_delete_link(jbi->vcard_images, jbi->vcard_images); |
| 13794 | 885 | } |
| 886 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
887 | 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
|
888 | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
889 | jabber_buddy_info_destroy(jbi); |
| 13794 | 890 | } |
| 891 | ||
| 892 | static void jabber_buddy_info_remove_id(JabberBuddyInfo *jbi, const char *id) | |
| 893 | { | |
| 894 | 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
|
895 | char *comp_id; |
| 13794 | 896 | |
| 897 | if(!id) | |
| 898 | return; | |
| 899 | ||
| 900 | while(l) { | |
|
15727
0754583ceeae
Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents:
15688
diff
changeset
|
901 | comp_id = l->data; |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
902 | if(purple_strequal(id, comp_id)) { |
|
15727
0754583ceeae
Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents:
15688
diff
changeset
|
903 | 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
|
904 | g_free(comp_id); |
| 13794 | 905 | return; |
| 906 | } | |
| 907 | l = l->next; | |
| 908 | } | |
| 909 | } | |
| 910 | ||
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
911 | static gboolean |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
912 | set_own_vcard_cb(gpointer data) |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
913 | { |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
914 | JabberStream *js = data; |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
915 | 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
|
916 | |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
917 | js->vcard_timer = 0; |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
918 | |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
919 | 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
|
920 | |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
921 | return FALSE; |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
922 | } |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
923 | |
|
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
|
924 | 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
|
925 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
926 | PurpleXmlNode *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
|
927 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
928 | PurpleXmlNode *vcard, *photo, *binval; |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
929 | char *txt, *vcard_hash = NULL; |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
930 | PurpleAccount *account; |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
931 | |
|
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
|
932 | if (type == JABBER_IQ_ERROR) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
933 | PurpleXmlNode *error; |
| 27417 | 934 | 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
|
935 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
936 | error = purple_xmlnode_get_child(packet, "error"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
937 | if (!error || !purple_xmlnode_get_child(error, "item-not-found")) |
|
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
|
938 | 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
|
939 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
940 | |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
941 | 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
|
942 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
943 | if((vcard = purple_xmlnode_get_child(packet, "vCard")) || |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
944 | (vcard = purple_xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
945 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
946 | txt = purple_xmlnode_to_str(vcard, NULL); |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
947 | 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
|
948 | g_free(txt); |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
949 | } else { |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
950 | /* 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
|
951 | } |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
952 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
953 | 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
|
954 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
955 | if (vcard && (photo = purple_xmlnode_get_child(vcard, "PHOTO")) && |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
956 | (binval = purple_xmlnode_get_child(photo, "BINVAL"))) { |
|
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 | gsize size; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
958 | char *bintext = purple_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
|
959 | if (bintext) { |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38334
diff
changeset
|
960 | guchar *data = g_base64_decode(bintext, &size); |
|
28311
9c92aae99f62
jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents:
28290
diff
changeset
|
961 | 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
|
962 | |
|
28311
9c92aae99f62
jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents:
28290
diff
changeset
|
963 | if (data) { |
|
38327
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
964 | vcard_hash = g_compute_checksum_for_data( |
|
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
965 | G_CHECKSUM_SHA1, data, size); |
|
28311
9c92aae99f62
jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents:
28290
diff
changeset
|
966 | g_free(data); |
|
9c92aae99f62
jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents:
28290
diff
changeset
|
967 | } |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
968 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
969 | } |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
970 | |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
971 | /* 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
|
972 | 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
|
973 | /* |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
974 | * 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
|
975 | * 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
|
976 | * it returns an error (namespaces trimmed): |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
977 | * <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
|
978 | */ |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
979 | if (js->googletalk) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
980 | js->vcard_timer = g_timeout_add_seconds(10, set_own_vcard_cb, |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
981 | js); |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
982 | else |
|
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
983 | 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
|
984 | } 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
|
985 | /* 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
|
986 | 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
|
987 | vcard_hash = NULL; |
|
4d43dd2afadb
jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents:
28881
diff
changeset
|
988 | |
|
4d43dd2afadb
jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents:
28881
diff
changeset
|
989 | /* 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
|
990 | 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
|
991 | } |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
992 | |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
993 | 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
|
994 | } |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
995 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
996 | 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
|
997 | { |
|
21957
0ce77f86c7f3
Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents:
21681
diff
changeset
|
998 | 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
|
999 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1000 | PurpleXmlNode *vcard = purple_xmlnode_new_child(iq->node, "vCard"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1001 | purple_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
|
1002 | 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
|
1003 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
1004 | 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
|
1005 | } |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
1006 | |
|
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
|
1007 | 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
|
1008 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1009 | PurpleXmlNode *packet, gpointer data) |
| 13794 | 1010 | { |
| 1011 | char *bare_jid; | |
| 1012 | 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
|
1013 | char *serverside_alias = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1014 | PurpleXmlNode *vcard; |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1015 | PurpleAccount *account; |
| 13794 | 1016 | 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
|
1017 | PurpleNotifyUserInfo *user_info; |
| 13794 | 1018 | |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1019 | g_return_if_fail(jbi != NULL); |
| 13794 | 1020 | |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
1021 | jabber_buddy_info_remove_id(jbi, id); |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
1022 | |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1023 | 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
|
1024 | 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
|
1025 | jabber_buddy_info_show_if_ready(jbi); |
| 13794 | 1026 | return; |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1027 | } |
| 13794 | 1028 | |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1029 | 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
|
1030 | 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
|
1031 | bare_jid = jabber_get_bare_jid(from ? from : purple_account_get_username(account)); |
| 13794 | 1032 | |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1033 | /* TODO: Is the query xmlns='vcard-temp' version of this still necessary? */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1034 | if((vcard = purple_xmlnode_get_child(packet, "vCard")) || |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1035 | (vcard = purple_xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1036 | PurpleXmlNode *child; |
| 7014 | 1037 | for(child = vcard->child; child; child = child->next) |
| 1038 | { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1039 | PurpleXmlNode *child2; |
| 7014 | 1040 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1041 | if(child->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 1042 | continue; |
| 1043 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1044 | text = purple_xmlnode_get_data(child); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1045 | if(text && purple_strequal(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
|
1046 | 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
|
1047 | 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
|
1048 | |
|
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, _("Full Name"), text); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1050 | } else if(purple_strequal(child->name, "N")) { |
| 7014 | 1051 | for(child2 = child->child; child2; child2 = child2->next) |
| 1052 | { | |
| 1053 | char *text2; | |
| 1054 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1055 | if(child2->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 1056 | continue; |
| 1057 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1058 | text2 = purple_xmlnode_get_data(child2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1059 | if(text2 && purple_strequal(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
|
1060 | purple_notify_user_info_add_pair_plaintext(user_info, _("Family Name"), text2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1061 | } else if(text2 && purple_strequal(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
|
1062 | purple_notify_user_info_add_pair_plaintext(user_info, _("Given Name"), text2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1063 | } else if(text2 && purple_strequal(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
|
1064 | purple_notify_user_info_add_pair_plaintext(user_info, _("Middle Name"), text2); |
| 7014 | 1065 | } |
| 1066 | g_free(text2); | |
| 1067 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1068 | } else if(text && purple_strequal(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
|
1069 | /* 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
|
1070 | * 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
|
1071 | 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
|
1072 | 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
|
1073 | 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
|
1074 | |
|
30537
9f833935ecd7
Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents:
29965
diff
changeset
|
1075 | purple_notify_user_info_add_pair_plaintext(user_info, _("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
|
1076 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1077 | } else if(text && purple_strequal(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
|
1078 | purple_notify_user_info_add_pair_plaintext(user_info, _("Birthday"), text); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1079 | } else if(purple_strequal(child->name, "ADR")) { |
|
12933
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1080 | gboolean address_line_added = FALSE; |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1081 | |
| 7014 | 1082 | for(child2 = child->child; child2; child2 = child2->next) |
| 1083 | { | |
| 1084 | char *text2; | |
| 1085 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1086 | if(child2->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 1087 | continue; |
| 1088 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1089 | text2 = purple_xmlnode_get_data(child2); |
|
12933
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1090 | if (text2 == NULL) |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1091 | continue; |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1092 | |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1093 | /* 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
|
1094 | * elements are empty. */ |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1095 | if (!address_line_added) |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1096 | { |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1097 | purple_notify_user_info_add_section_header(user_info, _("Address")); |
|
12933
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1098 | address_line_added = TRUE; |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1099 | } |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1100 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1101 | if(purple_strequal(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
|
1102 | purple_notify_user_info_add_pair_plaintext(user_info, _("P.O. Box"), text2); |
|
38256
035f00c4fd87
Replace misused g_str_equal() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
31660
diff
changeset
|
1103 | } else if (purple_strequal(child2->name, "EXTADD") || purple_strequal(child2->name, "EXTADR")) { |
|
27998
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1104 | /* |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1105 | * EXTADD is correct, EXTADR is generated by other |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1106 | * clients. The next time someone reads this, remove |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1107 | * EXTADR. |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1108 | */ |
|
30537
9f833935ecd7
Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents:
29965
diff
changeset
|
1109 | purple_notify_user_info_add_pair_plaintext(user_info, _("Extended Address"), text2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1110 | } else if(purple_strequal(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
|
1111 | purple_notify_user_info_add_pair_plaintext(user_info, _("Street Address"), text2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1112 | } else if(purple_strequal(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
|
1113 | purple_notify_user_info_add_pair_plaintext(user_info, _("Locality"), text2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1114 | } else if(purple_strequal(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
|
1115 | purple_notify_user_info_add_pair_plaintext(user_info, _("Region"), text2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1116 | } else if(purple_strequal(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
|
1117 | purple_notify_user_info_add_pair_plaintext(user_info, _("Postal Code"), text2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1118 | } else if(purple_strequal(child2->name, "CTRY") |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1119 | || purple_strequal(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
|
1120 | purple_notify_user_info_add_pair_plaintext(user_info, _("Country"), text2); |
| 7014 | 1121 | } |
| 1122 | g_free(text2); | |
| 1123 | } | |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1124 | |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1125 | 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
|
1126 | 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
|
1127 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1128 | } else if(purple_strequal(child->name, "TEL")) { |
| 7014 | 1129 | char *number; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1130 | if((child2 = purple_xmlnode_get_child(child, "NUMBER"))) { |
| 7014 | 1131 | /* show what kind of number it is */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1132 | number = purple_xmlnode_get_data(child2); |
| 7014 | 1133 | 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
|
1134 | purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number); |
| 7014 | 1135 | g_free(number); |
| 1136 | } | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1137 | } else if((number = purple_xmlnode_get_data(child))) { |
| 15884 | 1138 | /* lots of clients (including purple) do this, but it's |
| 7014 | 1139 | * 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
|
1140 | purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number); |
| 7014 | 1141 | g_free(number); |
| 1142 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1143 | } else if(purple_strequal(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
|
1144 | char *userid, *escaped; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1145 | if((child2 = purple_xmlnode_get_child(child, "USERID"))) { |
| 7014 | 1146 | /* show what kind of email it is */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1147 | userid = purple_xmlnode_get_data(child2); |
| 7014 | 1148 | 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
|
1149 | 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
|
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); |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
31694
diff
changeset
|
1152 | purple_notify_user_info_add_pair_html(user_info, _("Email"), mailto); |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1153 | |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
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 | } | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1158 | } else if((userid = purple_xmlnode_get_data(child))) { |
| 15884 | 1159 | /* lots of clients (including purple) do this, but it's |
| 7014 | 1160 | * 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
|
1161 | 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
|
1162 | |
|
19931
229fb62285b0
Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents:
19921
diff
changeset
|
1163 | 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
|
1164 | mailto = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", escaped, escaped); |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
31694
diff
changeset
|
1165 | purple_notify_user_info_add_pair_html(user_info, _("Email"), mailto); |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1166 | |
|
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1167 | 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
|
1168 | g_free(escaped); |
| 7014 | 1169 | g_free(userid); |
| 1170 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1171 | } else if(purple_strequal(child->name, "ORG")) { |
| 7014 | 1172 | for(child2 = child->child; child2; child2 = child2->next) |
| 1173 | { | |
| 1174 | char *text2; | |
| 1175 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1176 | if(child2->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 1177 | continue; |
| 1178 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1179 | text2 = purple_xmlnode_get_data(child2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1180 | if(text2 && purple_strequal(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
|
1181 | purple_notify_user_info_add_pair_plaintext(user_info, _("Organization Name"), text2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1182 | } else if(text2 && purple_strequal(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
|
1183 | purple_notify_user_info_add_pair_plaintext(user_info, _("Organization Unit"), text2); |
| 7014 | 1184 | } |
| 1185 | g_free(text2); | |
| 1186 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1187 | } else if(text && purple_strequal(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
|
1188 | purple_notify_user_info_add_pair_plaintext(user_info, _("Job Title"), text); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1189 | } else if(text && purple_strequal(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
|
1190 | purple_notify_user_info_add_pair_plaintext(user_info, _("Role"), text); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1191 | } else if(text && purple_strequal(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
|
1192 | purple_notify_user_info_add_pair_plaintext(user_info, _("Description"), text); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1193 | } else if(purple_strequal(child->name, "PHOTO") || |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1194 | purple_strequal(child->name, "LOGO")) { |
| 10941 | 1195 | char *bintext = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1196 | PurpleXmlNode *binval; |
| 11361 | 1197 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1198 | if ((binval = purple_xmlnode_get_child(child, "BINVAL")) && |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1199 | (bintext = purple_xmlnode_get_data(binval))) { |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10941
diff
changeset
|
1200 | gsize size; |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
1201 | guchar *data; |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
1202 | gboolean photo = purple_strequal(child->name, "PHOTO"); |
| 10189 | 1203 | |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38334
diff
changeset
|
1204 | data = g_base64_decode(bintext, &size); |
|
16587
50de12a4b81b
disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents:
16585
diff
changeset
|
1205 | if (data) { |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1206 | PurpleImage *img; |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1207 | guint img_id; |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1208 | 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
|
1209 | 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
|
1210 | |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1211 | img = purple_image_new_from_data(g_memdup(data, size), size); |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1212 | img_id = purple_image_store_add(img); |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1213 | |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1214 | jbi->vcard_images = g_slist_prepend(jbi->vcard_images, img); |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1215 | img_text = g_strdup_printf("<img src='" |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1216 | PURPLE_IMAGE_STORE_PROTOCOL "%u'>", img_id); |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1217 | |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
31694
diff
changeset
|
1218 | purple_notify_user_info_add_pair_html(user_info, (photo ? _("Photo") : _("Logo")), img_text); |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1219 | |
|
38327
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
1220 | hash = g_compute_checksum_for_data(G_CHECKSUM_SHA1, data, size); |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1221 | 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
|
1222 | 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
|
1223 | g_free(img_text); |
|
16587
50de12a4b81b
disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents:
16585
diff
changeset
|
1224 | } |
|
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
|
1225 | g_free(bintext); |
| 10941 | 1226 | } |
| 7014 | 1227 | } |
| 1228 | g_free(text); | |
| 1229 | } | |
| 1230 | } | |
| 1231 | ||
|
22586
ae2d0016b91e
If we receive a Full Name and no nickname, use the Full Name as the serverside alias for an XMPP contact. If we receive just a nickname or both a full name and a nickname, prefer the nickname.
Evan Schoenberg <evands@pidgin.im>
parents:
22550
diff
changeset
|
1232 | 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
|
1233 | 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
|
1234 | /* If we found a serverside alias, set it and tell the core */ |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
1235 | purple_serv_got_alias(js->gc, bare_jid, serverside_alias); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
1236 | b = purple_blist_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
|
1237 | 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
|
1238 | 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
|
1239 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1240 | |
|
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
|
1241 | 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
|
1242 | } |
|
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
|
1243 | |
| 13794 | 1244 | g_free(bare_jid); |
| 1245 | ||
| 1246 | jabber_buddy_info_show_if_ready(jbi); | |
| 1247 | } | |
| 1248 | ||
| 1249 | static void jabber_buddy_info_resource_free(gpointer data) | |
| 1250 | { | |
| 1251 | JabberBuddyInfoResource *jbri = data; | |
| 1252 | g_free(jbri); | |
| 1253 | } | |
| 1254 | ||
|
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
|
1255 | 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
|
1256 | { |
|
091771455e05
jabber: Fix a crash due to a contact having a resource with jbr->name == NULL
Paul Aurich <darkrain42@pidgin.im>
parents:
28071
diff
changeset
|
1257 | 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
|
1258 | 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
|
1259 | 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
|
1260 | 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
|
1261 | } |
|
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
|
1262 | |
|
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
|
1263 | 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
|
1264 | { |
|
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
|
1265 | 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
|
1266 | 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
|
1267 | |
|
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
|
1268 | 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
|
1269 | } |
|
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
|
1270 | |
|
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
|
1271 | 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
|
1272 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1273 | PurpleXmlNode *packet, gpointer data) |
| 13794 | 1274 | { |
| 1275 | JabberBuddyInfo *jbi = data; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1276 | PurpleXmlNode *query; |
| 13794 | 1277 | char *resource_name; |
| 1278 | ||
| 1279 | g_return_if_fail(jbi != NULL); | |
| 1280 | ||
| 1281 | jabber_buddy_info_remove_id(jbi, id); | |
| 1282 | ||
| 1283 | if(!from) | |
| 1284 | return; | |
| 1285 | ||
| 1286 | resource_name = jabber_get_resource(from); | |
| 1287 | ||
| 1288 | 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
|
1289 | if (type == JABBER_IQ_RESULT) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1290 | if((query = purple_xmlnode_get_child(packet, "query"))) { |
| 13794 | 1291 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jbi->jb, resource_name); |
| 1292 | if(jbr) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1293 | PurpleXmlNode *node; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1294 | if((node = purple_xmlnode_get_child(query, "name"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1295 | jbr->client.name = purple_xmlnode_get_data(node); |
| 13794 | 1296 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1297 | if((node = purple_xmlnode_get_child(query, "version"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1298 | jbr->client.version = purple_xmlnode_get_data(node); |
| 13794 | 1299 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1300 | if((node = purple_xmlnode_get_child(query, "os"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1301 | jbr->client.os = purple_xmlnode_get_data(node); |
| 13794 | 1302 | } |
| 1303 | } | |
| 1304 | } | |
| 1305 | } | |
| 1306 | g_free(resource_name); | |
| 10189 | 1307 | } |
| 13794 | 1308 | |
| 1309 | jabber_buddy_info_show_if_ready(jbi); | |
| 7014 | 1310 | } |
| 1311 | ||
|
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 | 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
|
1313 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1314 | PurpleXmlNode *packet, gpointer data) |
| 13794 | 1315 | { |
| 1316 | JabberBuddyInfo *jbi = data; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1317 | PurpleXmlNode *query; |
| 13794 | 1318 | 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
|
1319 | const char *seconds; |
| 13794 | 1320 | |
| 1321 | g_return_if_fail(jbi != NULL); | |
| 1322 | ||
| 1323 | jabber_buddy_info_remove_id(jbi, id); | |
| 1324 | ||
| 1325 | if(!from) | |
| 1326 | return; | |
| 1327 | ||
| 1328 | resource_name = jabber_get_resource(from); | |
| 1329 | ||
| 1330 | 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
|
1331 | if (type == JABBER_IQ_RESULT) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1332 | if((query = purple_xmlnode_get_child(packet, "query"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1333 | seconds = purple_xmlnode_get_attrib(query, "seconds"); |
| 13794 | 1334 | if(seconds) { |
| 1335 | char *end = NULL; | |
| 1336 | 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
|
1337 | JabberBuddy *jb = NULL; |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1338 | char *resource = NULL; |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1339 | 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
|
1340 | JabberBuddyResource *jbr = NULL; |
|
26958
a955bd42f529
propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
diff
changeset
|
1341 | |
| 13794 | 1342 | if(end != seconds) { |
| 1343 | JabberBuddyInfoResource *jbir = g_hash_table_lookup(jbi->resources, resource_name); | |
| 1344 | if(jbir) { | |
| 1345 | jbir->idle_seconds = sec; | |
| 1346 | } | |
| 1347 | } | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27135
diff
changeset
|
1348 | /* 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
|
1349 | 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
|
1350 | 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
|
1351 | 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
|
1352 | if (jb) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1353 | 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
|
1354 | 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
|
1355 | /* 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
|
1356 | 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
|
1357 | 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
|
1358 | 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
|
1359 | the resource getting unidle */ |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1360 | if (resource && buddy_name) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1361 | 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
|
1362 | if (jbr) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1363 | if (jbr->idle) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1364 | if (sec) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1365 | 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
|
1366 | } else { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1367 | jbr->idle = 0; |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1368 | } |
|
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
|
1369 | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27135
diff
changeset
|
1370 | if (jbr == |
|
27135
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1371 | jabber_buddy_find_resource(jb, NULL)) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36543
diff
changeset
|
1372 | purple_protocol_got_user_idle(purple_connection_get_account(js->gc), |
|
27135
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1373 | 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
|
1374 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1375 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1376 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1377 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1378 | g_free(resource); |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1379 | g_free(buddy_name); |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1380 | } |
| 13794 | 1381 | } |
| 1382 | } | |
| 1383 | } | |
| 1384 | g_free(resource_name); | |
| 1385 | } | |
| 1386 | ||
| 1387 | jabber_buddy_info_show_if_ready(jbi); | |
| 1388 | } | |
| 1389 | ||
|
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
|
1390 | 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
|
1391 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1392 | PurpleXmlNode *packet, gpointer data) |
|
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
|
1393 | { |
|
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 | JabberBuddyInfo *jbi = data; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1395 | PurpleXmlNode *query; |
|
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
|
1396 | 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
|
1397 | |
|
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 | 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
|
1399 | |
|
8eabf79a99fe
Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents:
27053
diff
changeset
|
1400 | 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
|
1401 | |
|
8eabf79a99fe
Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents:
27053
diff
changeset
|
1402 | if (type == JABBER_IQ_RESULT) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1403 | if((query = purple_xmlnode_get_child(packet, "query"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1404 | seconds = purple_xmlnode_get_attrib(query, "seconds"); |
|
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
|
1405 | 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
|
1406 | 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
|
1407 | 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
|
1408 | 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
|
1409 | 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
|
1410 | } |
|
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
|
1411 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1412 | jbi->last_message = purple_xmlnode_get_data(query); |
|
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
|
1413 | } |
|
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
|
1414 | } |
|
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
|
1415 | |
|
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
|
1416 | 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
|
1417 | } |
|
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
|
1418 | |
|
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 | 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
|
1420 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1421 | PurpleXmlNode *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
|
1422 | { |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1423 | JabberBuddyInfo *jbi = data; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1424 | JabberBuddyResource *jbr; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1425 | char *resource_name; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1426 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1427 | 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
|
1428 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1429 | 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
|
1430 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1431 | if (!from) |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1432 | return; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1433 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1434 | 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
|
1435 | 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
|
1436 | 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
|
1437 | 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
|
1438 | if (type == JABBER_IQ_RESULT) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1439 | PurpleXmlNode *time = purple_xmlnode_get_child(packet, "time"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1440 | PurpleXmlNode *tzo = time ? purple_xmlnode_get_child(time, "tzo") : NULL; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1441 | char *tzo_data = tzo ? purple_xmlnode_get_data(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
|
1442 | 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
|
1443 | 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
|
1444 | 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
|
1445 | 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
|
1446 | 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
|
1447 | } else { |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1448 | 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
|
1449 | /* [+-]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
|
1450 | 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
|
1451 | 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
|
1452 | 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
|
1453 | 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
|
1454 | 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
|
1455 | } else { |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1456 | 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
|
1457 | 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
|
1458 | } |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1459 | } |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1460 | |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1461 | 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
|
1462 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1463 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1464 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1465 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1466 | 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
|
1467 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1468 | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1469 | void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js) |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1470 | { |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1471 | if (js->pending_buddy_info_requests) |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1472 | { |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1473 | JabberBuddyInfo *jbi; |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1474 | GSList *l = js->pending_buddy_info_requests; |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1475 | while (l) { |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1476 | jbi = l->data; |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1477 | |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1478 | g_slist_free(jbi->ids); |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1479 | jabber_buddy_info_destroy(jbi); |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1480 | |
|
15727
0754583ceeae
Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents:
15688
diff
changeset
|
1481 | l = l->next; |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1482 | } |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1483 | |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1484 | g_slist_free(js->pending_buddy_info_requests); |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1485 | js->pending_buddy_info_requests = NULL; |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1486 | } |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1487 | } |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1488 | |
| 13794 | 1489 | static gboolean jabber_buddy_get_info_timeout(gpointer data) |
| 1490 | { | |
| 1491 | JabberBuddyInfo *jbi = data; | |
| 1492 | ||
| 1493 | /* remove the pending callbacks */ | |
| 1494 | while(jbi->ids) { | |
| 1495 | char *id = jbi->ids->data; | |
| 1496 | jabber_iq_remove_callback_by_id(jbi->js, id); | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1497 | jbi->ids = g_slist_remove(jbi->ids, id); |
| 13794 | 1498 | g_free(id); |
| 1499 | } | |
| 1500 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1501 | jbi->js->pending_buddy_info_requests = g_slist_remove(jbi->js->pending_buddy_info_requests, jbi); |
| 13794 | 1502 | jbi->timeout_handle = 0; |
| 1503 | ||
| 1504 | jabber_buddy_info_show_if_ready(jbi); | |
| 1505 | ||
| 1506 | return FALSE; | |
| 1507 | } | |
| 1508 | ||
|
17029
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1509 | 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
|
1510 | { |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1511 | /* 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
|
1512 | 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
|
1513 | return FALSE; |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1514 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1515 | if(purple_strequal(ns, NS_LAST_ACTIVITY)) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1516 | if(purple_strequal(jbr->client.name, "Trillian")) { |
|
20350
ae3f3561e698
another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
1517 | /* verified by nwalp 2007/05/09 */ |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1518 | if(purple_strequal(jbr->client.version, "3.1.0.121") || |
|
20350
ae3f3561e698
another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
1519 | /* verified by nwalp 2007/09/19 */ |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1520 | purple_strequal(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
|
1521 | return TRUE; |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1522 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1523 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1524 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1525 | |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1526 | return FALSE; |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1527 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1528 | |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1529 | static void |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1530 | 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
|
1531 | 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
|
1532 | JabberBuddyResource *jbr) |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1533 | { |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1534 | JabberIq *iq; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1535 | JabberBuddyInfoResource *jbir; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1536 | char *full_jid = NULL; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1537 | const char *to; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1538 | |
|
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
|
1539 | 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
|
1540 | 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
|
1541 | to = full_jid; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1542 | } else |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1543 | to = jid; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1544 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1545 | 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
|
1546 | 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
|
1547 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1548 | if(!jbr->client.name) { |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1549 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:version"); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1550 | purple_xmlnode_set_attrib(iq->node, "to", to); |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1551 | 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
|
1552 | 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
|
1553 | jabber_iq_send(iq); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1554 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1555 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1556 | /* 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
|
1557 | * 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
|
1558 | * 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
|
1559 | * 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
|
1560 | * office. */ |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28883
diff
changeset
|
1561 | 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
|
1562 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_LAST_ACTIVITY); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1563 | purple_xmlnode_set_attrib(iq->node, "to", to); |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1564 | 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
|
1565 | 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
|
1566 | jabber_iq_send(iq); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1567 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1568 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1569 | 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
|
1570 | (!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
|
1571 | jabber_resource_has_capability(jbr, NS_ENTITY_TIME))) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1572 | PurpleXmlNode *child; |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1573 | iq = jabber_iq_new(js, JABBER_IQ_GET); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1574 | purple_xmlnode_set_attrib(iq->node, "to", to); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1575 | child = purple_xmlnode_new_child(iq->node, "time"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1576 | purple_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
|
1577 | 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
|
1578 | 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
|
1579 | jabber_iq_send(iq); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1580 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1581 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1582 | g_free(full_jid); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1583 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1584 | |
| 13794 | 1585 | static void jabber_buddy_get_info_for_jid(JabberStream *js, const char *jid) |
| 7014 | 1586 | { |
| 1587 | JabberIq *iq; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1588 | PurpleXmlNode *vcard; |
| 13794 | 1589 | GList *resources; |
| 1590 | JabberBuddy *jb; | |
| 1591 | 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
|
1592 | const char *slash; |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1593 | gboolean is_bare_jid; |
| 13794 | 1594 | |
| 1595 | jb = jabber_buddy_find(js, jid, TRUE); | |
| 1596 | ||
| 1597 | /* invalid JID */ | |
| 1598 | if(!jb) | |
| 1599 | return; | |
| 1600 | ||
|
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
|
1601 | 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
|
1602 | 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
|
1603 | |
| 13794 | 1604 | jbi = g_new0(JabberBuddyInfo, 1); |
| 1605 | jbi->jid = g_strdup(jid); | |
| 1606 | jbi->js = js; | |
| 1607 | 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
|
1608 | 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
|
1609 | jbi->user_info = purple_notify_user_info_new(); |
| 7014 | 1610 | |
| 1611 | iq = jabber_iq_new(js, JABBER_IQ_GET); | |
| 1612 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1613 | purple_xmlnode_set_attrib(iq->node, "to", jid); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1614 | vcard = purple_xmlnode_new_child(iq->node, "vCard"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1615 | purple_xmlnode_set_namespace(vcard, "vcard-temp"); |
| 7014 | 1616 | |
| 13794 | 1617 | jabber_iq_set_callback(iq, jabber_vcard_parse, jbi); |
| 1618 | jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); | |
| 7014 | 1619 | |
| 1620 | jabber_iq_send(iq); | |
| 13794 | 1621 | |
|
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
|
1622 | 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
|
1623 | if (jb->resources) { |
|
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1624 | 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
|
1625 | 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
|
1626 | 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
|
1627 | } |
|
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1628 | } else { |
|
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1629 | /* 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
|
1630 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_LAST_ACTIVITY); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1631 | purple_xmlnode_set_attrib(iq->node, "to", jid); |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1632 | 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
|
1633 | 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
|
1634 | 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
|
1635 | } |
|
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
|
1636 | } 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
|
1637 | 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
|
1638 | 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
|
1639 | 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
|
1640 | 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
|
1641 | 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
|
1642 | "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
|
1643 | "JabberBuddyResource!\n", jid); |
| 13794 | 1644 | } |
| 1645 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1646 | js->pending_buddy_info_requests = g_slist_prepend(js->pending_buddy_info_requests, jbi); |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
1647 | jbi->timeout_handle = g_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi); |
| 7014 | 1648 | } |
| 1649 | ||
| 15884 | 1650 | void jabber_buddy_get_info(PurpleConnection *gc, const char *who) |
| 10189 | 1651 | { |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1652 | 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
|
1653 | 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
|
1654 | |
|
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
|
1655 | 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
|
1656 | return; |
| 10189 | 1657 | |
|
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
|
1658 | 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
|
1659 | /* 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
|
1660 | 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
|
1661 | } 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
|
1662 | char *bare_jid = jabber_get_bare_jid(who); |
| 10189 | 1663 | jabber_buddy_get_info_for_jid(js, bare_jid); |
| 1664 | g_free(bare_jid); | |
| 1665 | } | |
|
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
|
1666 | |
|
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
|
1667 | jabber_id_free(jid); |
| 10189 | 1668 | } |
| 1669 | ||
| 7014 | 1670 | static void jabber_buddy_set_invisibility(JabberStream *js, const char *who, |
| 1671 | gboolean invisible) | |
| 1672 | { | |
| 15884 | 1673 | PurplePresence *gpresence; |
| 1674 | PurpleAccount *account; | |
| 1675 | PurpleStatus *status; | |
| 7014 | 1676 | JabberBuddy *jb = jabber_buddy_find(js, who, TRUE); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1677 | PurpleXmlNode *presence; |
| 9954 | 1678 | JabberBuddyState state; |
| 14525 | 1679 | char *msg; |
| 9954 | 1680 | int priority; |
| 7014 | 1681 | |
| 15884 | 1682 | account = purple_connection_get_account(js->gc); |
| 1683 | gpresence = purple_account_get_presence(account); | |
| 1684 | status = purple_presence_get_active_status(gpresence); | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9797
diff
changeset
|
1685 | |
| 15884 | 1686 | 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
|
1687 | presence = jabber_presence_create_js(js, state, msg, priority); |
| 9954 | 1688 | |
| 14525 | 1689 | g_free(msg); |
| 1690 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1691 | purple_xmlnode_set_attrib(presence, "to", who); |
| 7014 | 1692 | if(invisible) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1693 | purple_xmlnode_set_attrib(presence, "type", "invisible"); |
| 7014 | 1694 | jb->invisible |= JABBER_INVIS_BUDDY; |
| 1695 | } else { | |
| 1696 | jb->invisible &= ~JABBER_INVIS_BUDDY; | |
| 1697 | } | |
| 1698 | ||
| 1699 | jabber_send(js, presence); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1700 | purple_xmlnode_free(presence); |
| 7014 | 1701 | } |
| 1702 | ||
| 15884 | 1703 | static void jabber_buddy_make_invisible(PurpleBlistNode *node, gpointer data) |
| 7014 | 1704 | { |
| 15884 | 1705 | PurpleBuddy *buddy; |
| 1706 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1707 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1708 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1709 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1710 | |
| 15884 | 1711 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1712 | 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
|
1713 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1714 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1715 | jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), TRUE); |
| 7014 | 1716 | } |
| 1717 | ||
| 15884 | 1718 | static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data) |
| 7014 | 1719 | { |
| 15884 | 1720 | PurpleBuddy *buddy; |
| 1721 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1722 | JabberStream *js; |
| 7014 | 1723 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1724 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 7014 | 1725 | |
| 15884 | 1726 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1727 | 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
|
1728 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1729 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1730 | jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), FALSE); |
| 7014 | 1731 | } |
| 1732 | ||
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1733 | static void cancel_presence_notification(gpointer data) |
| 7014 | 1734 | { |
| 15884 | 1735 | PurpleBuddy *buddy; |
| 1736 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1737 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1738 | |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1739 | buddy = data; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1740 | 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
|
1741 | 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
|
1742 | |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1743 | 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
|
1744 | } |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1745 | |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1746 | static void |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1747 | 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
|
1748 | gpointer data) |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1749 | { |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1750 | PurpleBuddy *buddy; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1751 | PurpleAccount *account; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1752 | PurpleConnection *gc; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1753 | const gchar *name; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1754 | char *msg; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1755 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1756 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 7014 | 1757 | |
| 15884 | 1758 | buddy = (PurpleBuddy *) node; |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1759 | 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
|
1760 | 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
|
1761 | gc = purple_account_get_connection(account); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1762 | |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1763 | 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
|
1764 | "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
|
1765 | purple_request_yes_no(gc, NULL, _("Cancel Presence Notification"), |
|
34331
c8486462bb63
Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34329
diff
changeset
|
1766 | msg, 0 /* Yes */, purple_request_cpar_from_account(account), buddy, |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1767 | 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
|
1768 | g_free(msg); |
| 7014 | 1769 | } |
| 1770 | ||
| 15884 | 1771 | static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data) |
| 7250 | 1772 | { |
| 15884 | 1773 | PurpleBuddy *buddy; |
| 1774 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1775 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1776 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1777 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 7250 | 1778 | |
| 15884 | 1779 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1780 | 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
|
1781 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1782 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1783 | jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "subscribe"); |
| 7250 | 1784 | } |
| 1785 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1786 | |
| 15884 | 1787 | static void jabber_buddy_unsubscribe(PurpleBlistNode *node, gpointer data) |
| 7014 | 1788 | { |
| 15884 | 1789 | PurpleBuddy *buddy; |
| 1790 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1791 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1792 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1793 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1794 | |
| 15884 | 1795 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1796 | 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
|
1797 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1798 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1799 | 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
|
1800 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1801 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1802 | static void jabber_buddy_login(PurpleBlistNode *node, gpointer data) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1803 | if(PURPLE_IS_BUDDY(node)) { |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1804 | /* 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
|
1805 | PurpleBuddy *buddy = (PurpleBuddy *) node; |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1806 | 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
|
1807 | 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
|
1808 | 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
|
1809 | 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
|
1810 | PurpleStatus *status = purple_presence_get_active_status(gpresence); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1811 | PurpleXmlNode *presence; |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1812 | JabberBuddyState state; |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1813 | char *msg; |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1814 | 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
|
1815 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1816 | 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
|
1817 | 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
|
1818 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1819 | 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
|
1820 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1821 | purple_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
|
1822 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1823 | jabber_send(js, presence); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1824 | purple_xmlnode_free(presence); |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1825 | } |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1826 | } |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1827 | |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1828 | static void jabber_buddy_logout(PurpleBlistNode *node, gpointer data) { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1829 | if(PURPLE_IS_BUDDY(node)) { |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1830 | /* 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
|
1831 | PurpleBuddy *buddy = (PurpleBuddy *) node; |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1832 | 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
|
1833 | JabberStream *js = purple_connection_get_protocol_data(gc); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1834 | PurpleXmlNode *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
|
1835 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1836 | 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
|
1837 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1838 | purple_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
|
1839 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1840 | jabber_send(js, presence); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1841 | purple_xmlnode_free(presence); |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1842 | } |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1843 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1844 | |
| 15884 | 1845 | static GList *jabber_buddy_menu(PurpleBuddy *buddy) |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1846 | { |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1847 | 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
|
1848 | 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
|
1849 | 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
|
1850 | 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
|
1851 | GList *jbrs; |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1852 | |
| 7014 | 1853 | GList *m = NULL; |
| 15884 | 1854 | PurpleMenuAction *act; |
| 7395 | 1855 | |
| 1856 | if(!jb) | |
| 1857 | return m; | |
| 1858 | ||
|
29849
d7b910200dc5
jabber: Treat the version properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
29811
diff
changeset
|
1859 | 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
|
1860 | jb != js->user_jb) { |
| 8166 | 1861 | if(jb->invisible & JABBER_INVIS_BUDDY) { |
| 15884 | 1862 | act = purple_menu_action_new(_("Un-hide From"), |
| 1863 | PURPLE_CALLBACK(jabber_buddy_make_visible), | |
| 12919 | 1864 | NULL, NULL); |
| 8166 | 1865 | } else { |
| 15884 | 1866 | act = purple_menu_action_new(_("Temporarily Hide From"), |
| 1867 | PURPLE_CALLBACK(jabber_buddy_make_invisible), | |
| 13019 | 1868 | NULL, NULL); |
| 8166 | 1869 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1870 | m = g_list_append(m, act); |
| 7014 | 1871 | } |
| 1872 | ||
|
28071
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1873 | if(jb->subscription & JABBER_SUB_FROM && jb != js->user_jb) { |
| 15884 | 1874 | act = purple_menu_action_new(_("Cancel Presence Notification"), |
| 1875 | PURPLE_CALLBACK(jabber_buddy_cancel_presence_notification), | |
| 12919 | 1876 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1877 | m = g_list_append(m, act); |
| 7014 | 1878 | } |
| 1879 | ||
| 1880 | if(!(jb->subscription & JABBER_SUB_TO)) { | |
| 15884 | 1881 | act = purple_menu_action_new(_("(Re-)Request authorization"), |
| 1882 | PURPLE_CALLBACK(jabber_buddy_rerequest_auth), | |
| 12919 | 1883 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1884 | m = g_list_append(m, act); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1885 | |
|
28071
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1886 | } else if (jb != js->user_jb) { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1887 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1888 | /* shouldn't this just happen automatically when the buddy is |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1889 | removed? */ |
| 15884 | 1890 | act = purple_menu_action_new(_("Unsubscribe"), |
| 1891 | PURPLE_CALLBACK(jabber_buddy_unsubscribe), | |
| 12919 | 1892 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1893 | m = g_list_append(m, act); |
| 7014 | 1894 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1895 | |
|
28667
7bab19738f5e
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents:
28611
diff
changeset
|
1896 | 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
|
1897 | 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
|
1898 | 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
|
1899 | NULL, NULL); |
|
7bab19738f5e
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents:
28611
diff
changeset
|
1900 | 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
|
1901 | } |
|
7bab19738f5e
jabber: Add an "Initiate Chat" blist context menu option for GTalk accounts.
Eion Robb <eion@robbmob.com>
parents:
28611
diff
changeset
|
1902 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1903 | /* |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1904 | * 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
|
1905 | * |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1906 | * 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
|
1907 | * 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
|
1908 | * 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
|
1909 | * 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
|
1910 | * |
|
8225f2507058
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
1911 | * 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
|
1912 | */ |
|
29059
8225f2507058
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
1913 | 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
|
1914 | 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
|
1915 | 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
|
1916 | NULL, NULL); |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1917 | 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
|
1918 | 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
|
1919 | 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
|
1920 | NULL, NULL); |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1921 | 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
|
1922 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1923 | |
|
17816
1b7362b4a7a2
Implemented ad-hoc commands for the buddy action menu (untested), implemented the receiving end of XEP-0115: Entity Capabilities. Note that this seems not to be reliable right now, since some clients seem to have a very broken [read: completely non-functional] implementation (most notably Gajim and the py-transports).
Andreas Monitzer <am@adiumx.com>
parents:
17808
diff
changeset
|
1924 | /* 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
|
1925 | 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
|
1926 | 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
|
1927 | 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
|
1928 | 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
|
1929 | 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
|
1930 | 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
|
1931 | 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
|
1932 | 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
|
1933 | 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
|
1934 | } |
|
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
|
1935 | } |
| 7014 | 1936 | |
| 1937 | return m; | |
| 1938 | } | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1939 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1940 | GList * |
| 15884 | 1941 | jabber_blist_node_menu(PurpleBlistNode *node) |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1942 | { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1943 | if(PURPLE_IS_BUDDY(node)) { |
| 15884 | 1944 | return jabber_buddy_menu((PurpleBuddy *) node); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1945 | } else { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1946 | return NULL; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1947 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1948 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1949 | |
| 12683 | 1950 | |
| 15884 | 1951 | static void user_search_result_add_buddy_cb(PurpleConnection *gc, GList *row, void *user_data) |
| 11675 | 1952 | { |
| 1953 | /* XXX find out the jid */ | |
| 15884 | 1954 | purple_blist_request_add_buddy(purple_connection_get_account(gc), |
| 11675 | 1955 | g_list_nth_data(row, 0), NULL, NULL); |
| 1956 | } | |
| 1957 | ||
|
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
|
1958 | 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
|
1959 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1960 | PurpleXmlNode *packet, gpointer data) |
| 11675 | 1961 | { |
| 15884 | 1962 | PurpleNotifySearchResults *results; |
| 1963 | PurpleNotifySearchColumn *column; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1964 | PurpleXmlNode *x, *query, *item, *field; |
| 11675 | 1965 | |
| 1966 | /* XXX error checking? */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1967 | if(!(query = purple_xmlnode_get_child(packet, "query"))) |
| 11675 | 1968 | return; |
| 1969 | ||
| 15884 | 1970 | results = purple_notify_searchresults_new(); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1971 | if((x = purple_xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1972 | PurpleXmlNode *reported; |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1973 | 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
|
1974 | |
| 15884 | 1975 | 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
|
1976 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1977 | if((reported = purple_xmlnode_get_child(x, "reported"))) { |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1978 | PurpleXmlNode *field = purple_xmlnode_get_child(reported, "field"); |
| 11675 | 1979 | while(field) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1980 | const char *var = purple_xmlnode_get_attrib(field, "var"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1981 | const char *label = purple_xmlnode_get_attrib(field, "label"); |
| 11675 | 1982 | if(var) { |
| 15884 | 1983 | column = purple_notify_searchresults_column_new(label ? label : var); |
| 1984 | 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
|
1985 | column_vars = g_slist_append(column_vars, (char *)var); |
| 11675 | 1986 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1987 | field = purple_xmlnode_get_next_twin(field); |
| 11675 | 1988 | } |
| 1989 | } | |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1990 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1991 | item = purple_xmlnode_get_child(x, "item"); |
| 11675 | 1992 | while(item) { |
| 1993 | 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
|
1994 | GSList *l; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1995 | PurpleXmlNode *valuenode; |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1996 | 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
|
1997 | |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1998 | 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
|
1999 | /* |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2000 | * 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
|
2001 | * 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
|
2002 | */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2003 | for (field = purple_xmlnode_get_child(item, "field"); |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2004 | field != NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2005 | field = purple_xmlnode_get_next_twin(field)) |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2006 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2007 | if ((var = purple_xmlnode_get_attrib(field, "var")) && |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
2008 | purple_strequal(var, l->data) && |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2009 | (valuenode = purple_xmlnode_get_child(field, "value"))) |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2010 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2011 | char *value = purple_xmlnode_get_data(valuenode); |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2012 | 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
|
2013 | break; |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2014 | } |
| 11675 | 2015 | } |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2016 | 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
|
2017 | /* 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
|
2018 | row = g_list_append(row, NULL); |
| 11675 | 2019 | } |
| 15884 | 2020 | purple_notify_searchresults_row_add(results, row); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2021 | item = purple_xmlnode_get_next_twin(item); |
| 11675 | 2022 | } |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2023 | |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
2024 | g_slist_free(column_vars); |
| 11675 | 2025 | } else { |
| 2026 | /* old skool */ | |
| 15884 | 2027 | purple_debug_info("jabber", "old-skool\n"); |
| 11675 | 2028 | |
| 15884 | 2029 | column = purple_notify_searchresults_column_new(_("JID")); |
| 2030 | purple_notify_searchresults_column_add(results, column); | |
| 2031 | column = purple_notify_searchresults_column_new(_("First Name")); | |
| 2032 | purple_notify_searchresults_column_add(results, column); | |
| 2033 | column = purple_notify_searchresults_column_new(_("Last Name")); | |
| 2034 | purple_notify_searchresults_column_add(results, column); | |
| 2035 | column = purple_notify_searchresults_column_new(_("Nickname")); | |
| 2036 | 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
|
2037 | column = purple_notify_searchresults_column_new(_("Email")); |
| 15884 | 2038 | purple_notify_searchresults_column_add(results, column); |
| 11675 | 2039 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2040 | for(item = purple_xmlnode_get_child(query, "item"); item; item = purple_xmlnode_get_next_twin(item)) { |
| 11675 | 2041 | const char *jid; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2042 | PurpleXmlNode *node; |
| 11675 | 2043 | GList *row = NULL; |
| 2044 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2045 | if(!(jid = purple_xmlnode_get_attrib(item, "jid"))) |
| 11675 | 2046 | continue; |
| 2047 | ||
| 2048 | row = g_list_append(row, g_strdup(jid)); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2049 | node = purple_xmlnode_get_child(item, "first"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2050 | row = g_list_append(row, node ? purple_xmlnode_get_data(node) : NULL); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2051 | node = purple_xmlnode_get_child(item, "last"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2052 | row = g_list_append(row, node ? purple_xmlnode_get_data(node) : NULL); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2053 | node = purple_xmlnode_get_child(item, "nick"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2054 | row = g_list_append(row, node ? purple_xmlnode_get_data(node) : NULL); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2055 | node = purple_xmlnode_get_child(item, "email"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2056 | row = g_list_append(row, node ? purple_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
|
2057 | purple_debug_info("jabber", "row=%p\n", row); |
| 15884 | 2058 | purple_notify_searchresults_row_add(results, row); |
| 11675 | 2059 | } |
| 2060 | } | |
| 2061 | ||
| 15884 | 2062 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD, |
| 11675 | 2063 | user_search_result_add_buddy_cb); |
| 2064 | ||
| 15884 | 2065 | purple_notify_searchresults(js->gc, NULL, NULL, _("The following are the results of your search"), results, NULL, NULL); |
| 11675 | 2066 | } |
| 2067 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2068 | static void user_search_x_data_cb(JabberStream *js, PurpleXmlNode *result, gpointer data) |
| 11675 | 2069 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2070 | PurpleXmlNode *query; |
| 11675 | 2071 | JabberIq *iq; |
| 13345 | 2072 | char *dir_server = data; |
|
21388
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2073 | const char *type; |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2074 | |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2075 | /* 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
|
2076 | * 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
|
2077 | * a cancel, so skip it */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2078 | type = purple_xmlnode_get_attrib(result, "type"); |
| 38260 | 2079 | if(purple_strequal(type, "cancel")) { |
|
21388
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2080 | g_free(dir_server); |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2081 | return; |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2082 | } |
| 11675 | 2083 | |
| 2084 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search"); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2085 | query = purple_xmlnode_get_child(iq->node, "query"); |
| 11675 | 2086 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2087 | purple_xmlnode_insert_child(query, result); |
| 11675 | 2088 | |
| 2089 | jabber_iq_set_callback(iq, user_search_result_cb, NULL); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2090 | purple_xmlnode_set_attrib(iq->node, "to", dir_server); |
| 11675 | 2091 | jabber_iq_send(iq); |
| 13345 | 2092 | g_free(dir_server); |
| 11675 | 2093 | } |
| 2094 | ||
| 2095 | struct user_search_info { | |
| 2096 | JabberStream *js; | |
| 2097 | char *directory_server; | |
| 2098 | }; | |
| 2099 | ||
| 15884 | 2100 | static void user_search_cancel_cb(struct user_search_info *usi, PurpleRequestFields *fields) |
| 11675 | 2101 | { |
| 2102 | g_free(usi->directory_server); | |
| 2103 | g_free(usi); | |
| 2104 | } | |
| 2105 | ||
| 15884 | 2106 | static void user_search_cb(struct user_search_info *usi, PurpleRequestFields *fields) |
| 11675 | 2107 | { |
| 2108 | JabberStream *js = usi->js; | |
| 2109 | JabberIq *iq; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2110 | PurpleXmlNode *query; |
| 11675 | 2111 | GList *groups, *flds; |
| 2112 | ||
| 2113 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:search"); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2114 | query = purple_xmlnode_get_child(iq->node, "query"); |
| 11675 | 2115 | |
| 15884 | 2116 | for(groups = purple_request_fields_get_groups(fields); groups; groups = groups->next) { |
| 2117 | for(flds = purple_request_field_group_get_fields(groups->data); | |
| 11675 | 2118 | flds; flds = flds->next) { |
| 15884 | 2119 | PurpleRequestField *field = flds->data; |
| 2120 | const char *id = purple_request_field_get_id(field); | |
| 2121 | const char *value = purple_request_field_string_get_value(field); | |
| 11675 | 2122 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
2123 | if(value && (purple_strequal(id, "first") || purple_strequal(id, "last") || purple_strequal(id, "nick") || purple_strequal(id, "email"))) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2124 | PurpleXmlNode *y = purple_xmlnode_new_child(query, id); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2125 | purple_xmlnode_insert_data(y, value, -1); |
| 11675 | 2126 | } |
| 2127 | } | |
| 2128 | } | |
| 2129 | ||
| 2130 | jabber_iq_set_callback(iq, user_search_result_cb, NULL); | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2131 | purple_xmlnode_set_attrib(iq->node, "to", usi->directory_server); |
| 11675 | 2132 | jabber_iq_send(iq); |
| 2133 | ||
| 2134 | g_free(usi->directory_server); | |
| 2135 | g_free(usi); | |
| 2136 | } | |
| 2137 | ||
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2138 | #if 0 |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2139 | /* 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
|
2140 | |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2141 | /* |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2142 | * 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
|
2143 | * comments for Jabber User Directories |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2144 | * |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2145 | * See discussion thread "Search comment for Jabber is not translatable" |
| 15884 | 2146 | * 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
|
2147 | */ |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2148 | 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
|
2149 | /* 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
|
2150 | 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
|
2151 | "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
|
2152 | NULL |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2153 | }; |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2154 | #endif |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2155 | |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
26088
diff
changeset
|
2156 | 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
|
2157 | JabberIqType type, const char *id, |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2158 | PurpleXmlNode *packet, gpointer data) |
| 11675 | 2159 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2160 | PurpleXmlNode *query, *x; |
| 11675 | 2161 | |
|
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
|
2162 | if (!from) |
| 11675 | 2163 | return; |
| 2164 | ||
|
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
|
2165 | 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
|
2166 | char *msg = jabber_parse_error(js, packet, NULL); |
| 13794 | 2167 | |
|
13634
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2168 | if(!msg) |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2169 | msg = g_strdup(_("Unknown error")); |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2170 | |
| 15884 | 2171 | purple_notify_error(js->gc, _("Directory Query Failed"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
2172 | _("Could not query the directory server."), msg, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
2173 | purple_request_cpar_from_connection(js->gc)); |
|
13634
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2174 | g_free(msg); |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2175 | |
| 13345 | 2176 | return; |
| 2177 | } | |
| 2178 | ||
| 11675 | 2179 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2180 | if(!(query = purple_xmlnode_get_child(packet, "query"))) |
| 11675 | 2181 | return; |
| 2182 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2183 | if((x = purple_xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) { |
| 13345 | 2184 | jabber_x_data_request(js, x, user_search_x_data_cb, g_strdup(from)); |
| 11675 | 2185 | return; |
| 2186 | } else { | |
| 2187 | struct user_search_info *usi; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2188 | PurpleXmlNode *instnode; |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2189 | char *instructions = NULL; |
| 15884 | 2190 | PurpleRequestFields *fields; |
| 2191 | PurpleRequestFieldGroup *group; | |
| 2192 | PurpleRequestField *field; | |
| 11675 | 2193 | |
| 2194 | /* old skool */ | |
| 15884 | 2195 | fields = purple_request_fields_new(); |
| 2196 | group = purple_request_field_group_new(NULL); | |
| 2197 | purple_request_fields_add_group(fields, group); | |
| 11675 | 2198 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2199 | if((instnode = purple_xmlnode_get_child(query, "instructions"))) |
|
13574
433001d94e3e
[gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents:
13572
diff
changeset
|
2200 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2201 | char *tmp = purple_xmlnode_get_data(instnode); |
| 13794 | 2202 | |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2203 | if(tmp) |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2204 | { |
| 13794 | 2205 | /* 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
|
2206 | list in jabber_user_dir_comments[]) */ |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2207 | instructions = g_strdup_printf(_("Server Instructions: %s"), _(tmp)); |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2208 | g_free(tmp); |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2209 | } |
|
13574
433001d94e3e
[gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents:
13572
diff
changeset
|
2210 | } |
| 13794 | 2211 | |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2212 | if(!instructions) |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2213 | { |
| 11675 | 2214 | 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
|
2215 | "for any matching XMPP users.")); |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2216 | } |
| 11675 | 2217 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2218 | if(purple_xmlnode_get_child(query, "first")) { |
| 15884 | 2219 | field = purple_request_field_string_new("first", _("First Name"), |
| 11675 | 2220 | NULL, FALSE); |
| 15884 | 2221 | purple_request_field_group_add_field(group, field); |
| 11675 | 2222 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2223 | if(purple_xmlnode_get_child(query, "last")) { |
| 15884 | 2224 | field = purple_request_field_string_new("last", _("Last Name"), |
| 11675 | 2225 | NULL, FALSE); |
| 15884 | 2226 | purple_request_field_group_add_field(group, field); |
| 11675 | 2227 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2228 | if(purple_xmlnode_get_child(query, "nick")) { |
| 15884 | 2229 | field = purple_request_field_string_new("nick", _("Nickname"), |
| 11675 | 2230 | NULL, FALSE); |
| 15884 | 2231 | purple_request_field_group_add_field(group, field); |
| 11675 | 2232 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2233 | if(purple_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
|
2234 | field = purple_request_field_string_new("email", _("Email Address"), |
| 11675 | 2235 | NULL, FALSE); |
| 15884 | 2236 | purple_request_field_group_add_field(group, field); |
| 11675 | 2237 | } |
| 2238 | ||
| 2239 | usi = g_new0(struct user_search_info, 1); | |
| 2240 | usi->js = js; | |
| 2241 | usi->directory_server = g_strdup(from); | |
| 2242 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
2243 | 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
|
2244 | _("Search for XMPP users"), instructions, fields, |
| 11675 | 2245 | _("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
|
2246 | _("Cancel"), G_CALLBACK(user_search_cancel_cb), |
|
34332
876483829700
Request API refactoring: switch purple_request_fields to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34331
diff
changeset
|
2247 | purple_request_cpar_from_connection(js->gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
2248 | usi); |
| 11675 | 2249 | |
| 2250 | g_free(instructions); | |
| 2251 | } | |
| 2252 | } | |
| 2253 | ||
|
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
|
2254 | void jabber_user_search(JabberStream *js, const char *directory) |
| 11675 | 2255 | { |
| 2256 | JabberIq *iq; | |
| 2257 | ||
| 2258 | /* XXX: should probably better validate the directory we're given */ | |
| 2259 | if(!directory || !*directory) { | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
2260 | purple_notify_error(js->gc, _("Invalid Directory"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
2261 | _("Invalid Directory"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
2262 | purple_request_cpar_from_connection(js->gc)); |
| 11675 | 2263 | return; |
| 2264 | } | |
| 2265 | ||
|
31660
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2266 | /* If the value provided isn't the disco#info default, persist it. Otherwise, |
|
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2267 | make sure we aren't persisting an old value */ |
|
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2268 | if(js->user_directories && js->user_directories->data && |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
2269 | purple_strequal(directory, js->user_directories->data)) { |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32277
diff
changeset
|
2270 | purple_account_set_string(purple_connection_get_account(js->gc), "user_directory", ""); |
|
31660
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2271 | } |
|
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2272 | else { |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32277
diff
changeset
|
2273 | purple_account_set_string(purple_connection_get_account(js->gc), "user_directory", directory); |
|
31660
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2274 | } |
|
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2275 | |
| 11675 | 2276 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:search"); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2277 | purple_xmlnode_set_attrib(iq->node, "to", directory); |
| 11675 | 2278 | |
| 2279 | jabber_iq_set_callback(iq, user_search_fields_result_cb, NULL); | |
| 2280 | ||
| 2281 | jabber_iq_send(iq); | |
| 2282 | } | |
| 2283 | ||
|
36496
e7fe371c60a6
Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2284 | void jabber_user_search_begin(PurpleProtocolAction *action) |
| 11675 | 2285 | { |
|
36496
e7fe371c60a6
Refactored jabber to use the new API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2286 | PurpleConnection *gc = (PurpleConnection *) action->connection; |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
2287 | JabberStream *js = purple_connection_get_protocol_data(gc); |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32277
diff
changeset
|
2288 | const char *def_val = purple_account_get_string(purple_connection_get_account(js->gc), "user_directory", ""); |
|
31660
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2289 | if(!*def_val && js->user_directories) |
|
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2290 | def_val = js->user_directories->data; |
| 11675 | 2291 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
2292 | purple_request_input(gc, _("Enter a User Directory"), _("Enter a User Directory"), |
| 11675 | 2293 | _("Select a user directory to search"), |
|
31660
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2294 | def_val, |
| 11675 | 2295 | 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
|
2296 | _("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
|
2297 | _("Cancel"), NULL, |
|
34329
ddbc1337332c
Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33661
diff
changeset
|
2298 | NULL, js); |
| 11675 | 2299 | } |
| 13794 | 2300 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2301 | 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
|
2302 | 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
|
2303 | { |
|
27cc8217e86e
jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents:
28828
diff
changeset
|
2304 | 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
|
2305 | } |
|
27cc8217e86e
jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents:
28828
diff
changeset
|
2306 | |
|
27cc8217e86e
jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents:
28828
diff
changeset
|
2307 | gboolean |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2308 | 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
|
2309 | { |
|
24802
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24732
diff
changeset
|
2310 | 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
|
2311 | const JabberCapsNodeExts *exts; |
| 13794 | 2312 | |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
2313 | if (!jbr->caps.info) { |
|
27696
2cd9b9331f06
Lower the severity of this message.
Paul Aurich <darkrain42@pidgin.im>
parents:
27619
diff
changeset
|
2314 | 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
|
2315 | "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
|
2316 | return FALSE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2317 | } |
| 13794 | 2318 | |
|
24880
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
2319 | 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
|
2320 | 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
|
2321 | const GList *ext; |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
2322 | 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
|
2323 | /* 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
|
2324 | * 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
|
2325 | 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
|
2326 | 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
|
2327 | if (features) |
|
ae4e8598d0bf
Support old (XEP v1.3) Entity Capabilities alongside the new ones.
Paul Aurich <darkrain42@pidgin.im>
parents:
24878
diff
changeset
|
2328 | 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
|
2329 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2330 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2331 | |
|
24802
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24732
diff
changeset
|
2332 | return (node != NULL); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2333 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2334 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2335 | gboolean |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2336 | 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
|
2337 | { |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2338 | 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
|
2339 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2340 | 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
|
2341 | 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
|
2342 | "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
|
2343 | return FALSE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2344 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2345 | |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2346 | 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
|
2347 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2348 | |
|
25577
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2349 | const gchar * |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2350 | 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
|
2351 | const gchar *category) |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2352 | { |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2353 | const GList *iter = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2354 | |
|
27286
f637c4c27815
Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents:
27285
diff
changeset
|
2355 | if (jbr->caps.info) { |
|
f637c4c27815
Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents:
27285
diff
changeset
|
2356 | 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
|
2357 | const JabberIdentity *identity = |
|
27286
f637c4c27815
Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents:
27285
diff
changeset
|
2358 | (JabberIdentity *) iter->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2359 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
2360 | if (purple_strequal(identity->category, category)) { |
|
25577
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2361 | return identity->type; |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2362 | } |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2363 | } |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2364 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2365 | |
|
25577
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2366 | return NULL; |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2367 | } |