Fri, 07 Oct 2022 01:21:28 -0500
xmpp: Remove unused prototypes and code
Many functions are 'public' in that they are in header files, but they don't need to be. The `jabber.c` ones were likely there because of the xmpp/gtalk multi-library thing that's gone now.
This removal is 'naive', in that if a prototype is necessary for now-`static` functions, then that's all I did, instead of any re-ordering.
I also left in some 'unused' `data.c` functions as their use was deleted when removing smileys and they _may_ still be needed.
Testing Done:
Compiled.
Reviewed at https://reviews.imfreedom.org/r/1905/
| 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 | */ | |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
24 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
40160
diff
changeset
|
25 | #include <purple.h> |
| 7014 | 26 | |
|
40818
3891ef6e3b56
Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
27 | #include "glibcompat.h" |
|
3891ef6e3b56
Fix building on glib < 2.58.0 as we have a minimum of 2.52.0
Gary Kramlich <grim@reaperworld.com>
parents:
40726
diff
changeset
|
28 | |
| 7014 | 29 | #include "buddy.h" |
| 30 | #include "chat.h" | |
| 31 | #include "jabber.h" | |
| 32 | #include "iq.h" | |
| 33 | #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
|
34 | #include "useravatar.h" |
| 11675 | 35 | #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
|
36 | #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
|
37 | #include "adhoccommands.h" |
| 7014 | 38 | |
| 13794 | 39 | typedef struct { |
| 40 | long idle_seconds; | |
| 41 | } JabberBuddyInfoResource; | |
| 42 | ||
| 43 | typedef struct { | |
| 44 | JabberStream *js; | |
| 45 | JabberBuddy *jb; | |
| 46 | char *jid; | |
| 47 | GSList *ids; | |
| 48 | GHashTable *resources; | |
|
27305
ef06405deeb0
Use guint for a timeout handle here, too.
Paul Aurich <darkrain42@pidgin.im>
parents:
27297
diff
changeset
|
49 | guint timeout_handle; |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
50 | 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
|
51 | 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
|
52 | 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
|
53 | gchar *last_message; |
| 13794 | 54 | } JabberBuddyInfo; |
| 55 | ||
|
29388
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
56 | static void |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
57 | jabber_buddy_resource_free(JabberBuddyResource *jbr) |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
58 | { |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
59 | g_return_if_fail(jbr != NULL); |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
60 | |
|
40137
016690872c6c
Add new and free functions for structs to reduce duplication
qarkai <qarkai@gmail.com>
parents:
40135
diff
changeset
|
61 | g_list_free_full(jbr->commands, (GDestroyNotify)jabber_adhoc_commands_free); |
|
29388
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
62 | g_free(jbr->name); |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
63 | g_free(jbr->status); |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
64 | g_free(jbr->thread_id); |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
65 | g_free(jbr->client.name); |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
66 | g_free(jbr->client.version); |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
67 | g_free(jbr->client.os); |
|
41764
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
68 | g_clear_pointer(&jbr->tz_off, g_time_zone_unref); |
|
29388
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
69 | g_free(jbr); |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
70 | } |
|
d46f089712e8
jabber: --header_contents;
Paul Aurich <darkrain42@pidgin.im>
parents:
29387
diff
changeset
|
71 | |
| 7116 | 72 | void jabber_buddy_free(JabberBuddy *jb) |
| 73 | { | |
| 74 | g_return_if_fail(jb != NULL); | |
| 75 | ||
|
22942
2bf494f8e2a4
Change the string "screen name" to "username" everywhere. I think most
Mark Doliner <markdoliner@pidgin.im>
parents:
22928
diff
changeset
|
76 | g_free(jb->error_msg); |
|
40145
27c5004a6c65
Re-arrange jabber_buddy_resource_free to avoid use-after-free warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40139
diff
changeset
|
77 | g_list_free_full(jb->resources, (GDestroyNotify)jabber_buddy_resource_free); |
| 7116 | 78 | |
| 79 | g_free(jb); | |
| 80 | } | |
| 81 | ||
| 7014 | 82 | JabberBuddy *jabber_buddy_find(JabberStream *js, const char *name, |
| 83 | gboolean create) | |
| 84 | { | |
| 85 | 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
|
86 | char *realname; |
| 7014 | 87 | |
|
15143
37451143f5c4
[gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents:
15092
diff
changeset
|
88 | if (js->buddies == NULL) |
|
37451143f5c4
[gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents:
15092
diff
changeset
|
89 | return NULL; |
|
37451143f5c4
[gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents:
15092
diff
changeset
|
90 | |
|
27110
05ca719b901b
Support custom smileys in MUCs (when all participants support BoB and a maximum
Marcus Lundblad <malu@pidgin.im>
parents:
27075
diff
changeset
|
91 | if(!(realname = jabber_get_bare_jid(name))) |
| 7014 | 92 | return NULL; |
| 93 | ||
| 94 | jb = g_hash_table_lookup(js->buddies, realname); | |
| 95 | ||
| 96 | if(!jb && create) { | |
| 97 | 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
|
98 | 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
|
99 | } 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
|
100 | g_free(realname); |
| 7014 | 101 | |
| 102 | return jb; | |
| 103 | } | |
| 104 | ||
|
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
|
105 | /* 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
|
106 | * "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
|
107 | * 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
|
108 | */ |
|
27965
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
109 | 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
|
110 | { |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
111 | const JabberBuddyResource *jbra = a; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
112 | const JabberBuddyResource *jbrb = b; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
113 | JabberBuddyState state_a, state_b; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
114 | |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
115 | 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
|
116 | 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
|
117 | |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
118 | /* 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
|
119 | /* 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
|
120 | switch (jbra->state) { |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
121 | case JABBER_BUDDY_STATE_ONLINE: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
122 | case JABBER_BUDDY_STATE_CHAT: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
123 | 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
|
124 | break; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
125 | case JABBER_BUDDY_STATE_AWAY: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
126 | case JABBER_BUDDY_STATE_DND: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
127 | 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
|
128 | break; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
129 | case JABBER_BUDDY_STATE_XA: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
130 | 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
|
131 | break; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
132 | case JABBER_BUDDY_STATE_UNAVAILABLE: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
133 | 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
|
134 | break; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
135 | default: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
136 | 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
|
137 | break; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
138 | } |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
139 | |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
140 | switch (jbrb->state) { |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
141 | case JABBER_BUDDY_STATE_ONLINE: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
142 | case JABBER_BUDDY_STATE_CHAT: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
143 | 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
|
144 | break; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
145 | case JABBER_BUDDY_STATE_AWAY: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
146 | case JABBER_BUDDY_STATE_DND: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
147 | 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
|
148 | break; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
149 | case JABBER_BUDDY_STATE_XA: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
150 | 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
|
151 | break; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
152 | case JABBER_BUDDY_STATE_UNAVAILABLE: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
153 | 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
|
154 | break; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
155 | default: |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
156 | 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
|
157 | break; |
|
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 | |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
160 | if (state_a == state_b) { |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
161 | if (jbra->idle == jbrb->idle) |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
162 | return 0; |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
163 | 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
|
164 | (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
|
165 | return 1; |
|
27965
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
166 | 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
|
167 | return -1; |
|
27965
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
168 | } |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
169 | |
|
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
170 | 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
|
171 | return -1; |
|
27965
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
172 | 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
|
173 | (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
|
174 | 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
|
175 | 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
|
176 | return -1; |
|
27965
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
177 | 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
|
178 | (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
|
179 | 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
|
180 | return -1; |
|
27965
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
181 | 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
|
182 | 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
|
183 | return -1; |
|
27965
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
184 | |
|
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
|
185 | return 1; |
|
27965
d2f136953034
jabber: Move the jbr comparison logic to a GCompareFunc
Paul Aurich <darkrain42@pidgin.im>
parents:
27846
diff
changeset
|
186 | } |
| 7014 | 187 | |
| 188 | JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb, | |
| 189 | const char *resource) | |
| 190 | { | |
| 191 | GList *l; | |
| 192 | ||
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
193 | if (!jb) |
| 7014 | 194 | return NULL; |
| 195 | ||
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
196 | if (resource == NULL) |
|
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
197 | 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
|
198 | |
|
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
199 | for (l = jb->resources; l; l = l->next) |
| 7014 | 200 | { |
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
201 | JabberBuddyResource *jbr = l->data; |
|
38266
7c1706b2bd11
Remove found redundant NULL checks
qarkai <qarkai@gmail.com>
parents:
38260
diff
changeset
|
202 | 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
|
203 | return jbr; |
| 7014 | 204 | } |
| 205 | ||
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
206 | return NULL; |
| 7014 | 207 | } |
| 208 | ||
| 9954 | 209 | JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource, |
| 210 | int priority, JabberBuddyState state, const char *status) | |
| 7014 | 211 | { |
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
212 | /* TODO: Optimization: Only reinsert if priority+state changed */ |
| 7014 | 213 | 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
|
214 | if (jbr) { |
|
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
215 | 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
|
216 | } else { |
| 7014 | 217 | jbr = g_new0(JabberBuddyResource, 1); |
| 7116 | 218 | jbr->jb = jb; |
| 7014 | 219 | 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
|
220 | jbr->capabilities = JABBER_CAP_NONE; |
| 7014 | 221 | } |
| 222 | jbr->priority = priority; | |
| 223 | jbr->state = state; | |
| 22928 | 224 | 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
|
225 | jbr->status = g_strdup(status); |
| 9954 | 226 | |
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
227 | 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
|
228 | resource_compare_cb); |
| 9954 | 229 | return jbr; |
| 7014 | 230 | } |
| 231 | ||
| 232 | void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource) | |
| 233 | { | |
| 234 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource); | |
| 235 | ||
| 236 | if(!jbr) | |
| 237 | return; | |
| 238 | ||
|
40145
27c5004a6c65
Re-arrange jabber_buddy_resource_free to avoid use-after-free warning.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40139
diff
changeset
|
239 | jbr->jb->resources = g_list_remove(jbr->jb->resources, jbr); |
| 7116 | 240 | jabber_buddy_resource_free(jbr); |
| 7014 | 241 | } |
| 242 | ||
| 243 | /******* | |
| 244 | * This is the old vCard stuff taken from the old prpl. vCards, by definition | |
| 245 | * are a temporary thing until jabber can get its act together and come up | |
| 246 | * with a format for user information, hence the namespace of 'vcard-temp' | |
| 247 | * | |
| 248 | * Since I don't feel like putting that much work into something that's | |
| 249 | * _supposed_ to go away, i'm going to just copy the kludgy old code here, | |
| 250 | * and make it purdy when jabber comes up with a standards-track JEP to | |
| 251 | * replace vcard-temp | |
| 252 | * --Nathan | |
| 253 | *******/ | |
| 254 | ||
| 255 | /*---------------------------------------*/ | |
| 256 | /* Jabber "set info" (vCard) support */ | |
| 257 | /*---------------------------------------*/ | |
| 258 | ||
| 259 | /* | |
| 260 | * V-Card format: | |
| 261 | * | |
| 262 | * <vCard prodid='' version='' xmlns=''> | |
| 263 | * <FN></FN> | |
| 264 | * <N> | |
| 265 | * <FAMILY/> | |
| 266 | * <GIVEN/> | |
| 267 | * </N> | |
| 268 | * <NICKNAME/> | |
| 269 | * <URL/> | |
| 270 | * <ADR> | |
| 271 | * <STREET/> | |
| 272 | * <EXTADD/> | |
| 273 | * <LOCALITY/> | |
| 274 | * <REGION/> | |
| 275 | * <PCODE/> | |
| 276 | * <COUNTRY/> | |
| 277 | * </ADR> | |
| 278 | * <TEL/> | |
| 279 | * <EMAIL/> | |
| 280 | * <ORG> | |
| 281 | * <ORGNAME/> | |
| 282 | * <ORGUNIT/> | |
| 283 | * </ORG> | |
| 284 | * <TITLE/> | |
| 285 | * <ROLE/> | |
| 286 | * <DESC/> | |
| 287 | * <BDAY/> | |
| 288 | * </vCard> | |
| 289 | * | |
| 290 | * See also: | |
| 291 | * | |
| 292 | * http://docs.jabber.org/proto/html/vcard-temp.html | |
| 293 | * http://www.vcard-xml.org/dtd/vCard-XML-v2-20010520.dtd | |
| 294 | */ | |
| 295 | ||
| 296 | /* | |
| 297 | * Cross-reference user-friendly V-Card entry labels to vCard XML tags | |
| 298 | * and attributes. | |
| 299 | * | |
| 300 | * Order is (or should be) unimportant. For example: we have no way of | |
| 301 | * knowing in what order real data will arrive. | |
| 302 | * | |
| 303 | * Format: Label, Pre-set text, "visible" flag, "editable" flag, XML tag | |
| 304 | * name, XML tag's parent tag "path" (relative to vCard node). | |
| 305 | * | |
| 306 | * List is terminated by a NULL label pointer. | |
| 307 | * | |
| 308 | * Entries with no label text, but with XML tag and parent tag | |
| 309 | * entries, are used by V-Card XML construction routines to | |
| 310 | * "automagically" construct the appropriate XML node tree. | |
| 311 | * | |
| 312 | * Thoughts on future direction/expansion | |
| 313 | * | |
| 314 | * This is a "simple" vCard. | |
| 315 | * | |
| 316 | * It is possible for nodes other than the "vCard" node to have | |
| 317 | * attributes. Should that prove necessary/desirable, add an | |
| 318 | * "attributes" pointer to the vcard_template struct, create the | |
| 319 | * necessary tag_attr structs, and add 'em to the vcard_dflt_data | |
| 320 | * array. | |
| 321 | * | |
| 322 | * The above changes will (obviously) require changes to the vCard | |
| 323 | * construction routines. | |
| 324 | */ | |
| 325 | ||
| 326 | struct vcard_template { | |
| 327 | char *label; /* label text pointer */ | |
| 328 | char *tag; /* tag text */ | |
| 329 | 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
|
330 | } 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
|
331 | {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
|
332 | {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
|
333 | {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
|
334 | {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
|
335 | {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
|
336 | {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
|
337 | {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
|
338 | {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
|
339 | {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
|
340 | {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
|
341 | {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
|
342 | {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
|
343 | {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
|
344 | {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
|
345 | {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
|
346 | {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
|
347 | {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
|
348 | {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
|
349 | {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
|
350 | {"", "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
|
351 | {"", "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
|
352 | {"", "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
|
353 | {NULL, NULL, NULL} |
| 7014 | 354 | }; |
| 355 | ||
| 356 | /* | |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8401
diff
changeset
|
357 | * The "vCard" tag's attribute list... |
| 7014 | 358 | */ |
| 359 | struct tag_attr { | |
| 360 | char *attr; | |
| 361 | 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
|
362 | } const vcard_tag_attr_list[] = { |
| 7014 | 363 | {"prodid", "-//HandGen//NONSGML vGen v1.0//EN"}, |
| 364 | {"version", "2.0", }, | |
| 365 | {"xmlns", "vcard-temp", }, | |
| 366 | {NULL, NULL}, | |
| 367 | }; | |
| 368 | ||
| 369 | ||
| 370 | /* | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
371 | * Insert a tag node into an PurpleXmlNode tree, recursively inserting parent tag |
| 7014 | 372 | * nodes as necessary |
| 373 | * | |
| 374 | * Returns pointer to inserted node | |
| 375 | * | |
| 376 | * Note to hackers: this code is designed to be re-entrant (it's recursive--it | |
| 377 | * calls itself), so don't put any "static"s in here! | |
| 378 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
379 | static PurpleXmlNode *insert_tag_to_parent_tag(PurpleXmlNode *start, const char *parent_tag, const char *new_tag) |
| 7014 | 380 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
381 | PurpleXmlNode *x = NULL; |
| 7014 | 382 | |
| 383 | /* | |
| 384 | * If the parent tag wasn't specified, see if we can get it | |
| 385 | * from the vCard template struct. | |
| 386 | */ | |
| 387 | 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
|
388 | const struct vcard_template *vc_tp = vcard_template_data; |
| 7014 | 389 | |
| 390 | while(vc_tp->label != NULL) { | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
391 | if(purple_strequal(vc_tp->tag, new_tag)) { |
| 7014 | 392 | parent_tag = vc_tp->ptag; |
| 393 | break; | |
| 394 | } | |
| 395 | ++vc_tp; | |
| 396 | } | |
| 397 | } | |
| 398 | ||
| 399 | /* | |
| 400 | * If we have a parent tag... | |
| 401 | */ | |
| 402 | if(parent_tag != NULL ) { | |
| 403 | /* | |
| 404 | * Try to get the parent node for a tag | |
| 405 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
406 | if((x = purple_xmlnode_get_child(start, parent_tag)) == NULL) { |
| 7014 | 407 | /* |
| 408 | * Descend? | |
| 409 | */ | |
| 410 | char *grand_parent = g_strdup(parent_tag); | |
| 411 | char *parent; | |
| 412 | ||
| 413 | if((parent = strrchr(grand_parent, '/')) != NULL) { | |
| 414 | *(parent++) = '\0'; | |
| 415 | x = insert_tag_to_parent_tag(start, grand_parent, parent); | |
| 416 | } else { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
417 | x = purple_xmlnode_new_child(start, grand_parent); |
| 7014 | 418 | } |
| 419 | g_free(grand_parent); | |
| 420 | } else { | |
| 421 | /* | |
| 422 | * We found *something* to be the parent node. | |
| 423 | * Note: may be the "root" node! | |
| 424 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
425 | PurpleXmlNode *y; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
426 | if((y = purple_xmlnode_get_child(x, new_tag)) != NULL) { |
| 7014 | 427 | return(y); |
| 428 | } | |
| 429 | } | |
| 430 | } | |
| 431 | ||
| 432 | /* | |
| 433 | * insert the new tag into its parent node | |
| 434 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
435 | return(purple_xmlnode_new_child((x == NULL? start : x), new_tag)); |
| 7014 | 436 | } |
| 437 | ||
| 438 | /* | |
| 439 | * Send vCard info to Jabber server | |
| 440 | */ | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
441 | void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
442 | jabber_set_info(PurpleProtocolServer *protocol_server, PurpleConnection *gc, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
443 | const gchar *info) |
| 7014 | 444 | { |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
445 | PurpleImage *img; |
| 7014 | 446 | JabberIq *iq; |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
447 | 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
|
448 | 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
|
449 | const struct tag_attr *tag_attr; |
| 7014 | 450 | |
| 31691 | 451 | /* 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
|
452 | * 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
|
453 | if(!js->vcard_fetched) { |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
454 | 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
|
455 | 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
|
456 | 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
|
457 | if (image != NULL) { |
|
38327
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
458 | 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
|
459 | G_CHECKSUM_SHA1, |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
460 | purple_image_get_data(image), |
|
38334
cb3f85d86752
Merge/update port to GChecksum changes, resolving conflicts
Mike Ruprecht <cmaiku@gmail.com>
diff
changeset
|
461 | 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
|
462 | ); |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
463 | 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
|
464 | } 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
|
465 | 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
|
466 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
467 | 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
|
468 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
469 | |
|
15273
a7838f939207
[gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
470 | g_free(js->avatar_hash); |
| 10189 | 471 | js->avatar_hash = NULL; |
| 7014 | 472 | |
| 473 | /* | |
| 474 | * Send only if there's actually any *information* to send | |
| 475 | */ | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
476 | vc_node = info ? purple_xmlnode_from_str(info, -1) : NULL; |
| 10189 | 477 | |
|
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
|
478 | 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
|
479 | 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
|
480 | 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
|
481 | vc_node = NULL; |
| 10189 | 482 | } |
| 7014 | 483 | |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32277
diff
changeset
|
484 | 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
|
485 | 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
|
486 | 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
|
487 | 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
|
488 | gchar *enc; |
| 10189 | 489 | |
|
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
|
490 | 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
|
491 | 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
|
492 | 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
|
493 | 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
|
494 | } |
| 10189 | 495 | |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
496 | 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
|
497 | 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
|
498 | /* 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
|
499 | * 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
|
500 | * 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
|
501 | * 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
|
502 | 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
|
503 | 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
|
504 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
505 | 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
|
506 | 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
|
507 | 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
|
508 | binval = purple_xmlnode_new_child(photo, "BINVAL"); |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38334
diff
changeset
|
509 | 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
|
510 | |
|
38327
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
511 | 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
|
512 | 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
|
513 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
514 | 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
|
515 | g_free(enc); |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
516 | 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
|
517 | } 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
|
518 | 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
|
519 | /* 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
|
520 | 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
|
521 | 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
|
522 | } |
|
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
|
523 | } |
|
42142a0938a2
Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21957
diff
changeset
|
524 | |
|
42142a0938a2
Fix setting vCard buddy icons when we don't have any other user info set.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21957
diff
changeset
|
525 | if (vc_node != NULL) { |
|
15273
a7838f939207
[gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
526 | 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
|
527 | purple_xmlnode_insert_child(iq->node, vc_node); |
|
15273
a7838f939207
[gaim-migrate @ 18001]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
528 | 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
|
529 | |
|
0a7f22678a35
Send presence updates from jabber_set_info, not jabber_set_buddy_icon.
Paul Aurich <darkrain42@pidgin.im>
parents:
25477
diff
changeset
|
530 | /* 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
|
531 | jabber_presence_send(js, FALSE); |
| 7014 | 532 | } |
| 533 | } | |
| 534 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
535 | void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
536 | jabber_set_buddy_icon(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
537 | PurpleConnection *gc, PurpleImage *img) |
| 10189 | 538 | { |
|
25811
57012229a242
Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents:
25542
diff
changeset
|
539 | PurpleAccount *account = purple_connection_get_account(gc); |
| 10189 | 540 | |
|
26950
842628304397
Publish only 'new' xmlns of avatars and delete old.
Paul Aurich <darkrain42@pidgin.im>
parents:
26947
diff
changeset
|
541 | /* 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
|
542 | 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
|
543 | /* Set the image in our vCard */ |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
544 | jabber_set_info(NULL, 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
|
545 | |
|
25811
57012229a242
Use a JabberStream variable instead of a setting for the initial hash
Paul Aurich <darkrain42@pidgin.im>
parents:
25542
diff
changeset
|
546 | /* 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
|
547 | * 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
|
548 | * 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
|
549 | * an existing icon/stored image). */ |
| 10189 | 550 | } |
| 551 | ||
| 7014 | 552 | /* |
| 553 | * This is the callback from the "ok clicked" for "set vCard" | |
| 554 | * | |
|
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
|
555 | * Sets the vCard with data from PurpleRequestFields. |
| 7014 | 556 | */ |
| 557 | static void | |
| 15884 | 558 | jabber_format_info(PurpleConnection *gc, PurpleRequestFields *fields) |
| 7014 | 559 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
560 | PurpleXmlNode *vc_node; |
| 15884 | 561 | PurpleRequestField *field; |
| 7014 | 562 | const char *text; |
| 563 | char *p; | |
| 564 | 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
|
565 | const struct tag_attr *tag_attr; |
| 7014 | 566 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
567 | vc_node = purple_xmlnode_new("vCard"); |
| 7014 | 568 | |
| 569 | 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
|
570 | purple_xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value); |
| 7014 | 571 | |
| 572 | for (vc_tp = vcard_template_data; vc_tp->label != NULL; vc_tp++) { | |
| 573 | if (*vc_tp->label == '\0') | |
| 574 | continue; | |
| 575 | ||
| 15884 | 576 | field = purple_request_fields_get_field(fields, vc_tp->tag); |
| 577 | text = purple_request_field_string_get_value(field); | |
| 7014 | 578 | |
| 579 | ||
| 580 | 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
|
581 | PurpleXmlNode *xp; |
| 7014 | 582 | |
|
28828
7c1855f037e7
jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <darkrain42@pidgin.im>
parents:
28667
diff
changeset
|
583 | purple_debug_info("jabber", "Setting %s to '%s'\n", vc_tp->tag, text); |
| 9339 | 584 | |
| 7014 | 585 | if ((xp = insert_tag_to_parent_tag(vc_node, |
| 586 | NULL, vc_tp->tag)) != NULL) { | |
| 587 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
588 | purple_xmlnode_insert_data(xp, text, -1); |
| 7014 | 589 | } |
| 590 | } | |
| 591 | } | |
| 592 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
593 | 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
|
594 | purple_xmlnode_free(vc_node); |
| 7014 | 595 | |
| 15884 | 596 | 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
|
597 | purple_serv_set_info(gc, p); |
| 7014 | 598 | |
| 599 | g_free(p); | |
| 600 | } | |
| 601 | ||
| 602 | /* | |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
603 | * This gets executed as the protocol action. |
| 7014 | 604 | * |
| 15884 | 605 | * Creates a new PurpleRequestFields struct, gets the XML-formatted user_info |
| 7014 | 606 | * string (if any) into GSLists for the (multi-entry) edit dialog and |
| 607 | * calls the set_vcard dialog. | |
| 608 | */ | |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
609 | void |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
610 | jabber_setup_set_info(G_GNUC_UNUSED GSimpleAction *action, GVariant *parameter, |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
611 | G_GNUC_UNUSED gpointer data) |
| 7014 | 612 | { |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
613 | const char *account_id = NULL; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
614 | PurpleAccountManager *manager = NULL; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
615 | PurpleAccount *account = NULL; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
616 | PurpleConnection *connection = NULL; |
| 15884 | 617 | PurpleRequestFields *fields; |
| 618 | PurpleRequestFieldGroup *group; | |
| 619 | PurpleRequestField *field; | |
| 7014 | 620 | const struct vcard_template *vc_tp; |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
621 | const char *user_info; |
|
14130
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
622 | 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
|
623 | PurpleXmlNode *x_vc_data = NULL; |
| 7014 | 624 | |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
625 | if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
626 | g_critical("XMPP Set Info action parameter is of incorrect type %s", |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
627 | g_variant_get_type_string(parameter)); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
628 | } |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
629 | |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
630 | account_id = g_variant_get_string(parameter, NULL); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
631 | manager = purple_account_manager_get_default(); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
632 | account = purple_account_manager_find_by_id(manager, account_id); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
633 | connection = purple_account_get_connection(account); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
634 | |
| 15884 | 635 | fields = purple_request_fields_new(); |
| 636 | group = purple_request_field_group_new(NULL); | |
| 637 | purple_request_fields_add_group(fields, group); | |
| 7014 | 638 | |
| 639 | /* | |
| 640 | * Get existing, XML-formatted, user info | |
| 641 | */ | |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
642 | if((user_info = purple_account_get_user_info(account)) != NULL) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
643 | x_vc_data = purple_xmlnode_from_str(user_info, -1); |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
644 | } |
| 7014 | 645 | |
| 646 | /* | |
| 647 | * Set up GSLists for edit with labels from "template," data from user info | |
| 648 | */ | |
| 649 | 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
|
650 | PurpleXmlNode *data_node; |
| 7014 | 651 | if((vc_tp->label)[0] == '\0') |
| 652 | continue; | |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
653 | |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
654 | if (x_vc_data != NULL) { |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
655 | 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
|
656 | 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
|
657 | } else { |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
658 | 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
|
659 | data_node = purple_xmlnode_get_child(x_vc_data, tag); |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
660 | g_free(tag); |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
661 | } |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
662 | 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
|
663 | cdata = purple_xmlnode_get_data(data_node); |
|
14130
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
664 | } |
| 7014 | 665 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
666 | if(purple_strequal(vc_tp->tag, "DESC")) { |
| 15884 | 667 | field = purple_request_field_string_new(vc_tp->tag, |
| 7014 | 668 | _(vc_tp->label), cdata, |
| 669 | TRUE); | |
| 670 | } else { | |
| 15884 | 671 | field = purple_request_field_string_new(vc_tp->tag, |
| 7014 | 672 | _(vc_tp->label), cdata, |
| 673 | FALSE); | |
| 674 | } | |
| 675 | ||
|
14130
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
676 | g_free(cdata); |
|
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
677 | cdata = NULL; |
|
02a5f8dad9cf
[gaim-migrate @ 16689]
Daniel Atallah <datallah@pidgin.im>
parents:
14129
diff
changeset
|
678 | |
| 15884 | 679 | purple_request_field_group_add_field(group, field); |
| 7014 | 680 | } |
| 681 | ||
| 682 | 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
|
683 | purple_xmlnode_free(x_vc_data); |
| 7014 | 684 | |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
685 | purple_request_fields(connection, _("Edit XMPP vCard"), |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
686 | _("Edit XMPP vCard"), |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
687 | _("All items below are optional. Enter only the " |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
688 | "information with which you feel comfortable."), |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
689 | fields, |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
690 | _("Save"), G_CALLBACK(jabber_format_info), |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
691 | _("Cancel"), NULL, |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
692 | purple_request_cpar_from_connection(connection), |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
693 | connection); |
| 7014 | 694 | } |
| 695 | ||
| 696 | /*---------------------------------------*/ | |
| 697 | /* End Jabber "set info" (vCard) support */ | |
| 698 | /*---------------------------------------*/ | |
| 699 | ||
| 700 | /****** | |
| 701 | * end of that ancient crap that needs to die | |
| 702 | ******/ | |
| 703 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
704 | static void jabber_buddy_info_destroy(JabberBuddyInfo *jbi) |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
705 | { |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
706 | /* 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
|
707 | if (jbi->timeout_handle > 0) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
38358
diff
changeset
|
708 | 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
|
709 | |
| 40135 | 710 | g_slist_free(jbi->ids); |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
711 | g_free(jbi->jid); |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
712 | 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
|
713 | 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
|
714 | 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
|
715 | g_free(jbi); |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
716 | } |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
717 | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
718 | static void |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
719 | 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
|
720 | JabberBuddyResource *jbr) |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
721 | { |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
722 | JabberBuddyInfoResource *jbir; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
723 | PurpleNotifyUserInfo *user_info; |
|
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 | 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
|
726 | 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
|
727 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
728 | if (jbr && jbr->client.name) { |
| 27551 | 729 | char *tmp = |
| 730 | g_strdup_printf("%s%s%s", jbr->client.name, | |
| 731 | (jbr->client.version ? " " : ""), | |
| 732 | (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
|
733 | /* 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
|
734 | 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
|
735 | 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
|
736 | g_free(tmp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
737 | |
|
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
|
738 | 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
|
739 | /* 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
|
740 | 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
|
741 | 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
|
742 | } |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
743 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
744 | |
|
41764
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
745 | if (jbr && jbr->tz_off != NULL) { |
|
40551
e9573eaa68f9
Start replacing time utility functions with GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
746 | GDateTime *dt = NULL; |
|
e9573eaa68f9
Start replacing time utility functions with GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
747 | char *timestamp = NULL; |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
748 | |
|
41764
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
749 | dt = g_date_time_new_now(jbr->tz_off); |
|
40551
e9573eaa68f9
Start replacing time utility functions with GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
750 | |
|
e9573eaa68f9
Start replacing time utility functions with GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
751 | timestamp = g_date_time_format(dt, "%X %:z"); |
|
e9573eaa68f9
Start replacing time utility functions with GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
752 | g_date_time_unref(dt); |
|
e9573eaa68f9
Start replacing time utility functions with GDateTime
Gary Kramlich <grim@reaperworld.com>
parents:
40474
diff
changeset
|
753 | |
|
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
|
754 | 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
|
755 | g_free(timestamp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
756 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
757 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
758 | if (jbir && jbir->idle_seconds > 0) { |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
759 | char *idle = purple_str_seconds_to_string(jbir->idle_seconds); |
|
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
|
760 | 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
|
761 | g_free(idle); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
762 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
763 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
764 | if (jbr) { |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
765 | char *purdy = NULL; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
766 | char *tmp; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
767 | char priority[12]; |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
768 | const char *status_name = jabber_buddy_state_get_name(jbr->state); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
769 | |
| 27551 | 770 | if (jbr->status) { |
|
28290
55c4b5a11af7
jabber: Escape status messages with a '<' or '>' in the Get Info dialog.
Paul Aurich <darkrain42@pidgin.im>
parents:
28278
diff
changeset
|
771 | tmp = purple_markup_escape_text(jbr->status, -1); |
|
55c4b5a11af7
jabber: Escape status messages with a '<' or '>' in the Get Info dialog.
Paul Aurich <darkrain42@pidgin.im>
parents:
28278
diff
changeset
|
772 | purdy = purple_strdup_withhtml(tmp); |
|
55c4b5a11af7
jabber: Escape status messages with a '<' or '>' in the Get Info dialog.
Paul Aurich <darkrain42@pidgin.im>
parents:
28278
diff
changeset
|
773 | g_free(tmp); |
| 27551 | 774 | |
| 775 | if (purple_strequal(status_name, purdy)) | |
| 776 | status_name = NULL; | |
| 777 | } | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
778 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
779 | tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""), |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
780 | ((status_name && purdy) ? ": " : ""), |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
781 | (purdy ? purdy : "")); |
|
32204
2a09624616c3
Actually commit the purple_notify_user_info_prepend_pair_plaintext
Mark Doliner <markdoliner@pidgin.im>
parents:
32203
diff
changeset
|
782 | 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
|
783 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
784 | g_snprintf(priority, sizeof(priority), "%d", jbr->priority); |
|
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
|
785 | 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
|
786 | |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
787 | g_free(tmp); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
788 | g_free(purdy); |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
789 | } else { |
|
32203
e7c2d37aecd5
Add purple_notify_user_info_prepend_pair_plaintext and use it in a few
Mark Doliner <markdoliner@pidgin.im>
parents:
32202
diff
changeset
|
790 | purple_notify_user_info_prepend_pair_plaintext(user_info, _("Status"), _("Unknown")); |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
791 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
792 | } |
|
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
793 | |
| 13794 | 794 | static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi) |
| 7014 | 795 | { |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
796 | char *resource_name; |
| 13794 | 797 | JabberBuddyResource *jbr; |
| 798 | GList *resources; | |
| 15884 | 799 | PurpleNotifyUserInfo *user_info; |
| 7014 | 800 | |
| 13794 | 801 | /* not yet */ |
| 27551 | 802 | if (jbi->ids) |
| 11361 | 803 | return; |
| 804 | ||
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
805 | user_info = jbi->user_info; |
| 13794 | 806 | resource_name = jabber_get_resource(jbi->jid); |
| 7014 | 807 | |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
808 | /* If we have one or more pairs from the vcard, put a section break above it */ |
|
32193
42173d1c1317
Change PurpleNotifyUserInfo->user_info_entries from a GList to a GQueue.
Mark Doliner <markdoliner@pidgin.im>
parents:
32191
diff
changeset
|
809 | 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
|
810 | purple_notify_user_info_prepend_section_break(user_info); |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
811 | |
| 27551 | 812 | /* Add the information about the user's resource(s) */ |
| 813 | if (resource_name) { | |
| 13794 | 814 | jbr = jabber_buddy_find_resource(jbi->jb, resource_name); |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
815 | add_jbr_info(jbi, resource_name, jbr); |
| 7014 | 816 | } else { |
|
29387
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
817 | /* TODO: This is in priority-ascending order (lowest prio first), because |
|
21ecdd98e791
jabber: Treat JabberBuddy->resources as a sorted list.
Paul Aurich <darkrain42@pidgin.im>
parents:
29385
diff
changeset
|
818 | * everything is prepended. Is that ok? */ |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
819 | for (resources = jbi->jb->resources; resources; resources = resources->next) { |
| 7014 | 820 | jbr = resources->data; |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
821 | |
|
27053
fb088f01758d
Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents:
26958
diff
changeset
|
822 | /* put a section break between resources, this is not needed if |
|
fb088f01758d
Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents:
26958
diff
changeset
|
823 | we are at the first, because one was already added for the vcard |
|
fb088f01758d
Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents:
26958
diff
changeset
|
824 | section */ |
| 27551 | 825 | if (resources != jbi->jb->resources) |
|
27053
fb088f01758d
Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents:
26958
diff
changeset
|
826 | purple_notify_user_info_prepend_section_break(user_info); |
|
fb088f01758d
Add a section break between resources in "Get info"
Marcus Lundblad <malu@pidgin.im>
parents:
26958
diff
changeset
|
827 | |
|
27550
775140c24a35
Factor out the duplicated code for displaying XMPP Get Info
Paul Aurich <darkrain42@pidgin.im>
parents:
27549
diff
changeset
|
828 | add_jbr_info(jbi, jbr->name, jbr); |
| 13794 | 829 | |
|
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
|
830 | 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
|
831 | /* 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
|
832 | 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
|
833 | 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
|
834 | } |
| 7014 | 835 | } |
| 836 | } | |
| 837 | ||
|
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
|
838 | 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
|
839 | /* 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
|
840 | 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
|
841 | |
|
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
|
842 | 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
|
843 | 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
|
844 | 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
|
845 | 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
|
846 | 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
|
847 | 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
|
848 | message = last; |
|
6218763ad5b4
This string is already translated; so it need not be translated again.
Paul Aurich <darkrain42@pidgin.im>
parents:
29097
diff
changeset
|
849 | 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
|
850 | } 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
|
851 | 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
|
852 | 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
|
853 | } |
|
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
|
854 | 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
|
855 | 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
|
856 | 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
|
857 | } |
|
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
|
858 | |
|
29097
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
859 | if (!is_domain) { |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
860 | gchar *status = |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
861 | g_strdup_printf("%s%s%s", _("Offline"), |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
862 | jbi->last_message ? ": " : "", |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
863 | 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
|
864 | /* 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
|
865 | 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
|
866 | 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
|
867 | g_free(status); |
|
0834410aa178
Tighter scoping and slightly less memory usage.
Paul Aurich <darkrain42@pidgin.im>
parents:
29064
diff
changeset
|
868 | } |
|
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
|
869 | } |
|
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
|
870 | |
| 7306 | 871 | g_free(resource_name); |
| 872 | ||
| 15884 | 873 | purple_notify_userinfo(jbi->js->gc, jbi->jid, user_info, NULL, NULL); |
| 13794 | 874 | |
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39483
diff
changeset
|
875 | g_slist_free_full(jbi->vcard_images, g_object_unref); |
| 13794 | 876 | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
877 | 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
|
878 | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
879 | jabber_buddy_info_destroy(jbi); |
| 13794 | 880 | } |
| 881 | ||
| 882 | static void jabber_buddy_info_remove_id(JabberBuddyInfo *jbi, const char *id) | |
| 883 | { | |
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39483
diff
changeset
|
884 | GSList *l; |
|
15727
0754583ceeae
Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents:
15688
diff
changeset
|
885 | char *comp_id; |
| 13794 | 886 | |
| 887 | if(!id) | |
| 888 | return; | |
| 889 | ||
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39483
diff
changeset
|
890 | l = g_slist_find_custom(jbi->ids, id, (GCompareFunc)g_strcmp0); |
|
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39483
diff
changeset
|
891 | if(l) { |
|
15727
0754583ceeae
Don't access the list element after it has been freed.
Daniel Atallah <datallah@pidgin.im>
parents:
15688
diff
changeset
|
892 | comp_id = l->data; |
|
40053
abbd9caef452
Use g_slist_delete_link instead of g_slist_remove
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40052
diff
changeset
|
893 | jbi->ids = g_slist_delete_link(jbi->ids, l); |
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39483
diff
changeset
|
894 | g_free(comp_id); |
| 13794 | 895 | } |
| 896 | } | |
| 897 | ||
|
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
|
898 | 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
|
899 | 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
|
900 | 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
|
901 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
902 | 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
|
903 | char *txt, *vcard_hash = NULL; |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
904 | PurpleAccount *account; |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
905 | |
|
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
|
906 | 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
|
907 | PurpleXmlNode *error; |
| 27417 | 908 | 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
|
909 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
910 | 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
|
911 | 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
|
912 | 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
|
913 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
914 | |
|
28046
8b6fcc2c95b3
jabber: Fix setting Google Talk avatar at login.
Paul Aurich <darkrain42@pidgin.im>
parents:
27998
diff
changeset
|
915 | 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 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
917 | 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
|
918 | (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
|
919 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
920 | 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
|
921 | 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
|
922 | g_free(txt); |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
923 | } else { |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
924 | /* 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
|
925 | } |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
926 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
927 | 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
|
928 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
929 | 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
|
930 | (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
|
931 | gsize size; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
932 | 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
|
933 | if (bintext) { |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38334
diff
changeset
|
934 | 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
|
935 | 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
|
936 | |
|
28311
9c92aae99f62
jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents:
28290
diff
changeset
|
937 | if (data) { |
|
38327
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
938 | 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
|
939 | 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
|
940 | g_free(data); |
|
9c92aae99f62
jabber: Fix a crash when the vcard includes an empty BINVAL.
Paul Aurich <darkrain42@pidgin.im>
parents:
28290
diff
changeset
|
941 | } |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
942 | } |
|
18235
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
943 | } |
|
25477
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
944 | |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
945 | /* 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
|
946 | if (js->initial_avatar_hash && !purple_strequal(vcard_hash, js->initial_avatar_hash)) { |
|
40726
645607090674
Remove Google Talk from the XMPP plugin.
Gary Kramlich <grim@reaperworld.com>
parents:
40708
diff
changeset
|
947 | jabber_set_info(NULL, js->gc, purple_account_get_user_info(account)); |
|
28883
b005808ee1a5
jabber: This is more correct.
Paul Aurich <darkrain42@pidgin.im>
parents:
28882
diff
changeset
|
948 | } 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
|
949 | /* 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
|
950 | 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
|
951 | vcard_hash = NULL; |
|
4d43dd2afadb
jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents:
28881
diff
changeset
|
952 | |
|
4d43dd2afadb
jabber: The second half; advertise the vCard avatar, whatever it is.
Paul Aurich <darkrain42@pidgin.im>
parents:
28881
diff
changeset
|
953 | /* 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
|
954 | 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
|
955 | } |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
956 | |
|
ada9e5c4a10a
Only (re)publish XMPP avatars at login if the server's avatar differs
Paul Aurich <darkrain42@pidgin.im>
parents:
25475
diff
changeset
|
957 | 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
|
958 | } |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
959 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
960 | 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
|
961 | { |
|
21957
0ce77f86c7f3
Fix XMPP buddy icons. Somehow a 'VCard' element got changed to a query
Sean Egan <seanegan@pidgin.im>
parents:
21681
diff
changeset
|
962 | 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
|
963 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
964 | 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
|
965 | 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
|
966 | 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
|
967 | |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
968 | 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
|
969 | } |
|
60a9bd99f035
server-side jabber vcards now take precedence over local vcards, so
Nathan Walp <nwalp@pidgin.im>
parents:
18196
diff
changeset
|
970 | |
|
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
|
971 | 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
|
972 | 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
|
973 | PurpleXmlNode *packet, gpointer data) |
| 13794 | 974 | { |
| 975 | char *bare_jid; | |
| 976 | 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
|
977 | 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
|
978 | PurpleXmlNode *vcard; |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
979 | PurpleAccount *account; |
| 13794 | 980 | 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
|
981 | PurpleNotifyUserInfo *user_info; |
| 13794 | 982 | |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
983 | g_return_if_fail(jbi != NULL); |
| 13794 | 984 | |
|
14129
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
985 | jabber_buddy_info_remove_id(jbi, id); |
|
70db31dfeeb1
[gaim-migrate @ 16688]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
986 | |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
987 | 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
|
988 | 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
|
989 | jabber_buddy_info_show_if_ready(jbi); |
| 13794 | 990 | return; |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
991 | } |
| 13794 | 992 | |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
993 | 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
|
994 | 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
|
995 | bare_jid = jabber_get_bare_jid(from ? from : purple_account_get_username(account)); |
| 13794 | 996 | |
|
29368
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
997 | /* 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
|
998 | 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
|
999 | (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
|
1000 | PurpleXmlNode *child; |
| 7014 | 1001 | for(child = vcard->child; child; child = child->next) |
| 1002 | { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1003 | PurpleXmlNode *child2; |
| 7014 | 1004 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1005 | if(child->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 1006 | continue; |
| 1007 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1008 | text = purple_xmlnode_get_data(child); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1009 | 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
|
1010 | 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
|
1011 | 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
|
1012 | |
|
30537
9f833935ecd7
Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents:
29965
diff
changeset
|
1013 | 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
|
1014 | } else if(purple_strequal(child->name, "N")) { |
| 7014 | 1015 | for(child2 = child->child; child2; child2 = child2->next) |
| 1016 | { | |
| 1017 | char *text2; | |
| 1018 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1019 | if(child2->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 1020 | continue; |
| 1021 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1022 | text2 = purple_xmlnode_get_data(child2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1023 | 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
|
1024 | 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
|
1025 | } 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
|
1026 | 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
|
1027 | } 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
|
1028 | purple_notify_user_info_add_pair_plaintext(user_info, _("Middle Name"), text2); |
| 7014 | 1029 | } |
| 1030 | g_free(text2); | |
| 1031 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1032 | } 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
|
1033 | /* 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
|
1034 | * 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
|
1035 | 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
|
1036 | 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
|
1037 | 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
|
1038 | |
|
30537
9f833935ecd7
Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents:
29965
diff
changeset
|
1039 | 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
|
1040 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1041 | } 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
|
1042 | 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
|
1043 | } else if(purple_strequal(child->name, "ADR")) { |
|
12933
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1044 | gboolean address_line_added = FALSE; |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1045 | |
| 7014 | 1046 | for(child2 = child->child; child2; child2 = child2->next) |
| 1047 | { | |
| 1048 | char *text2; | |
| 1049 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1050 | if(child2->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 1051 | continue; |
| 1052 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1053 | text2 = purple_xmlnode_get_data(child2); |
|
12933
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1054 | if (text2 == NULL) |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1055 | continue; |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1056 | |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1057 | /* 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
|
1058 | * elements are empty. */ |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1059 | if (!address_line_added) |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1060 | { |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1061 | purple_notify_user_info_add_section_header(user_info, _("Address")); |
|
12933
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1062 | address_line_added = TRUE; |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1063 | } |
|
885970470a9b
[gaim-migrate @ 15286]
Richard Laager <rlaager@pidgin.im>
parents:
12919
diff
changeset
|
1064 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1065 | 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
|
1066 | 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
|
1067 | } 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
|
1068 | /* |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1069 | * EXTADD is correct, EXTADR is generated by other |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1070 | * clients. The next time someone reads this, remove |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1071 | * EXTADR. |
|
889b1fbece5b
jabber: Handle "Extended Address" correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27965
diff
changeset
|
1072 | */ |
|
30537
9f833935ecd7
Add a purple_notify_user_info_add_pair_plaintext function that accepts a
Mark Doliner <markdoliner@pidgin.im>
parents:
29965
diff
changeset
|
1073 | 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
|
1074 | } 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
|
1075 | 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
|
1076 | } 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
|
1077 | 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
|
1078 | } 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
|
1079 | 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
|
1080 | } 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
|
1081 | 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
|
1082 | } else if(purple_strequal(child2->name, "CTRY") |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1083 | || 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
|
1084 | purple_notify_user_info_add_pair_plaintext(user_info, _("Country"), text2); |
| 7014 | 1085 | } |
| 1086 | g_free(text2); | |
| 1087 | } | |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1088 | |
|
23347
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1089 | 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
|
1090 | 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
|
1091 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1092 | } else if(purple_strequal(child->name, "TEL")) { |
| 7014 | 1093 | char *number; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1094 | if((child2 = purple_xmlnode_get_child(child, "NUMBER"))) { |
| 7014 | 1095 | /* 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
|
1096 | number = purple_xmlnode_get_data(child2); |
| 7014 | 1097 | 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
|
1098 | purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number); |
| 7014 | 1099 | g_free(number); |
| 1100 | } | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1101 | } else if((number = purple_xmlnode_get_data(child))) { |
| 15884 | 1102 | /* lots of clients (including purple) do this, but it's |
| 7014 | 1103 | * 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
|
1104 | purple_notify_user_info_add_pair_plaintext(user_info, _("Telephone"), number); |
| 7014 | 1105 | g_free(number); |
| 1106 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1107 | } 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
|
1108 | 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
|
1109 | if((child2 = purple_xmlnode_get_child(child, "USERID"))) { |
| 7014 | 1110 | /* 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
|
1111 | userid = purple_xmlnode_get_data(child2); |
| 7014 | 1112 | 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
|
1113 | 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
|
1114 | 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
|
1115 | 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
|
1116 | 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
|
1117 | |
|
4b62b4732afd
Use the notify_user_info API for the vcard information instead of creating
Evan Schoenberg <evands@pidgin.im>
parents:
23325
diff
changeset
|
1118 | 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
|
1119 | g_free(escaped); |
| 7014 | 1120 | g_free(userid); |
| 1121 | } | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1122 | } else if((userid = purple_xmlnode_get_data(child))) { |
| 15884 | 1123 | /* lots of clients (including purple) do this, but it's |
| 7014 | 1124 | * 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
|
1125 | 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
|
1126 | |
|
19931
229fb62285b0
Data in vCards is supposed to be plain text, not HTML. So escape
Mark Doliner <markdoliner@pidgin.im>
parents:
19921
diff
changeset
|
1127 | 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
|
1128 | 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
|
1129 | 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
|
1130 | |
|
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1131 | 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
|
1132 | g_free(escaped); |
| 7014 | 1133 | g_free(userid); |
| 1134 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1135 | } else if(purple_strequal(child->name, "ORG")) { |
| 7014 | 1136 | for(child2 = child->child; child2; child2 = child2->next) |
| 1137 | { | |
| 1138 | char *text2; | |
| 1139 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1140 | if(child2->type != PURPLE_XMLNODE_TYPE_TAG) |
| 7014 | 1141 | continue; |
| 1142 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1143 | text2 = purple_xmlnode_get_data(child2); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1144 | 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
|
1145 | 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
|
1146 | } 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
|
1147 | purple_notify_user_info_add_pair_plaintext(user_info, _("Organization Unit"), text2); |
| 7014 | 1148 | } |
| 1149 | g_free(text2); | |
| 1150 | } | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1151 | } 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
|
1152 | 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
|
1153 | } 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
|
1154 | 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
|
1155 | } 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
|
1156 | 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
|
1157 | } else if(purple_strequal(child->name, "PHOTO") || |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1158 | purple_strequal(child->name, "LOGO")) { |
| 10941 | 1159 | 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
|
1160 | PurpleXmlNode *binval; |
| 11361 | 1161 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1162 | 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
|
1163 | (bintext = purple_xmlnode_get_data(binval))) { |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10941
diff
changeset
|
1164 | gsize size; |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
1165 | guchar *data; |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
1166 | gboolean photo = purple_strequal(child->name, "PHOTO"); |
| 10189 | 1167 | |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
38334
diff
changeset
|
1168 | data = g_base64_decode(bintext, &size); |
|
16587
50de12a4b81b
disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents:
16585
diff
changeset
|
1169 | if (data) { |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1170 | PurpleImage *img; |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1171 | 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
|
1172 | 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
|
1173 | 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
|
1174 | |
|
39463
d47e230b9d75
Fix leaky calls to purple_image_new_from_data.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38854
diff
changeset
|
1175 | img = purple_image_new_from_data(data, size); |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1176 | 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
|
1177 | |
|
35823
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1178 | jbi->vcard_images = g_slist_prepend(jbi->vcard_images, img); |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1179 | img_text = g_strdup_printf("<img src='" |
|
268a9d3b3fd7
imgstore: unref xmpp
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
1180 | 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
|
1181 | |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
31694
diff
changeset
|
1182 | 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
|
1183 | |
|
38327
c842a56b9967
jabber: Port to use GChecksum instead of PurpleHash
Mike Ruprecht <cmaiku@gmail.com>
parents:
37134
diff
changeset
|
1184 | 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
|
1185 | 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
|
1186 | 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
|
1187 | g_free(img_text); |
|
16587
50de12a4b81b
disapproval of revision 'f95b376c0d2f066996620c5bb595dc71b5ee22d9'
Richard Laager <rlaager@pidgin.im>
parents:
16585
diff
changeset
|
1188 | } |
|
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
|
1189 | g_free(bintext); |
| 10941 | 1190 | } |
| 7014 | 1191 | } |
| 1192 | g_free(text); | |
| 1193 | } | |
| 1194 | } | |
| 1195 | ||
|
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
|
1196 | 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
|
1197 | 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
|
1198 | /* 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
|
1199 | 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
|
1200 | 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
|
1201 | 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
|
1202 | 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
|
1203 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1204 | |
|
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
|
1205 | 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
|
1206 | } |
|
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
|
1207 | |
| 13794 | 1208 | g_free(bare_jid); |
| 1209 | ||
| 1210 | jabber_buddy_info_show_if_ready(jbi); | |
| 1211 | } | |
| 1212 | ||
| 1213 | static void jabber_buddy_info_resource_free(gpointer data) | |
| 1214 | { | |
| 1215 | JabberBuddyInfoResource *jbri = data; | |
| 1216 | g_free(jbri); | |
| 1217 | } | |
| 1218 | ||
|
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
|
1219 | 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
|
1220 | { |
|
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
|
1221 | 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
|
1222 | 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
|
1223 | 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
|
1224 | 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
|
1225 | } |
|
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
|
1226 | |
|
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
|
1227 | 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
|
1228 | { |
|
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
|
1229 | 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
|
1230 | 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
|
1231 | |
|
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
|
1232 | 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
|
1233 | } |
|
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
|
1234 | |
|
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
|
1235 | 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
|
1236 | 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
|
1237 | PurpleXmlNode *packet, gpointer data) |
| 13794 | 1238 | { |
| 1239 | 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
|
1240 | PurpleXmlNode *query; |
| 13794 | 1241 | char *resource_name; |
| 1242 | ||
| 1243 | g_return_if_fail(jbi != NULL); | |
| 1244 | ||
| 1245 | jabber_buddy_info_remove_id(jbi, id); | |
| 1246 | ||
| 1247 | if(!from) | |
| 1248 | return; | |
| 1249 | ||
| 1250 | resource_name = jabber_get_resource(from); | |
| 1251 | ||
| 1252 | 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
|
1253 | 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
|
1254 | if((query = purple_xmlnode_get_child(packet, "query"))) { |
| 13794 | 1255 | JabberBuddyResource *jbr = jabber_buddy_find_resource(jbi->jb, resource_name); |
| 1256 | if(jbr) { | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1257 | PurpleXmlNode *node; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1258 | 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
|
1259 | jbr->client.name = purple_xmlnode_get_data(node); |
| 13794 | 1260 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1261 | 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
|
1262 | jbr->client.version = purple_xmlnode_get_data(node); |
| 13794 | 1263 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1264 | 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
|
1265 | jbr->client.os = purple_xmlnode_get_data(node); |
| 13794 | 1266 | } |
| 1267 | } | |
| 1268 | } | |
| 1269 | } | |
| 1270 | g_free(resource_name); | |
| 10189 | 1271 | } |
| 13794 | 1272 | |
| 1273 | jabber_buddy_info_show_if_ready(jbi); | |
| 7014 | 1274 | } |
| 1275 | ||
|
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
|
1276 | 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
|
1277 | 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
|
1278 | PurpleXmlNode *packet, gpointer data) |
| 13794 | 1279 | { |
| 1280 | 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
|
1281 | PurpleXmlNode *query; |
| 13794 | 1282 | 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
|
1283 | const char *seconds; |
| 13794 | 1284 | |
| 1285 | g_return_if_fail(jbi != NULL); | |
| 1286 | ||
| 1287 | jabber_buddy_info_remove_id(jbi, id); | |
| 1288 | ||
| 1289 | if(!from) | |
| 1290 | return; | |
| 1291 | ||
| 1292 | resource_name = jabber_get_resource(from); | |
| 1293 | ||
| 1294 | 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
|
1295 | 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
|
1296 | 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
|
1297 | seconds = purple_xmlnode_get_attrib(query, "seconds"); |
| 13794 | 1298 | if(seconds) { |
| 1299 | char *end = NULL; | |
| 1300 | 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
|
1301 | JabberBuddy *jb = NULL; |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1302 | char *resource = NULL; |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1303 | 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
|
1304 | JabberBuddyResource *jbr = NULL; |
|
26958
a955bd42f529
propagate from branch 'im.pidgin.pidgin' (head 36f75a1d52a6af5574bf847d60054a1392dcbc67)
Paul Aurich <darkrain42@pidgin.im>
diff
changeset
|
1305 | |
| 13794 | 1306 | if(end != seconds) { |
| 1307 | JabberBuddyInfoResource *jbir = g_hash_table_lookup(jbi->resources, resource_name); | |
| 1308 | if(jbir) { | |
| 1309 | jbir->idle_seconds = sec; | |
| 1310 | } | |
| 1311 | } | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27135
diff
changeset
|
1312 | /* 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
|
1313 | 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
|
1314 | 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
|
1315 | 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
|
1316 | if (jb) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1317 | 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
|
1318 | 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
|
1319 | /* 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
|
1320 | 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
|
1321 | 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
|
1322 | 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
|
1323 | the resource getting unidle */ |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1324 | if (resource && buddy_name) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1325 | 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
|
1326 | if (jbr) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1327 | if (jbr->idle) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1328 | if (sec) { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1329 | 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
|
1330 | } else { |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1331 | jbr->idle = 0; |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1332 | } |
|
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
|
1333 | |
|
27155
53502d71efdd
Remove trailing whitespace that has snuck in.
Paul Aurich <darkrain42@pidgin.im>
parents:
27135
diff
changeset
|
1334 | if (jbr == |
|
27135
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1335 | jabber_buddy_find_resource(jb, NULL)) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36543
diff
changeset
|
1336 | 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
|
1337 | 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
|
1338 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1339 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1340 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1341 | } |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1342 | g_free(resource); |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1343 | g_free(buddy_name); |
|
32f298815b9e
This whole section was partially using spaces instead of tabs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27134
diff
changeset
|
1344 | } |
| 13794 | 1345 | } |
| 1346 | } | |
| 1347 | } | |
| 1348 | g_free(resource_name); | |
| 1349 | } | |
| 1350 | ||
| 1351 | jabber_buddy_info_show_if_ready(jbi); | |
| 1352 | } | |
| 1353 | ||
|
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
|
1354 | 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
|
1355 | 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
|
1356 | 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
|
1357 | { |
|
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
|
1358 | 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
|
1359 | 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
|
1360 | 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
|
1361 | |
|
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
|
1362 | 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
|
1363 | |
|
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
|
1364 | 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
|
1365 | |
|
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
|
1366 | 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
|
1367 | 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
|
1368 | 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
|
1369 | 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
|
1370 | 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
|
1371 | 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
|
1372 | 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
|
1373 | 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
|
1374 | } |
|
8eabf79a99fe
Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents:
27053
diff
changeset
|
1375 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1376 | 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
|
1377 | } |
|
8eabf79a99fe
Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents:
27053
diff
changeset
|
1378 | } |
|
8eabf79a99fe
Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents:
27053
diff
changeset
|
1379 | |
|
8eabf79a99fe
Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents:
27053
diff
changeset
|
1380 | 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
|
1381 | } |
|
8eabf79a99fe
Show when a user was last online (as seen by the server) when doing "Get Info"
Marcus Lundblad <malu@pidgin.im>
parents:
27053
diff
changeset
|
1382 | |
|
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
|
1383 | 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
|
1384 | 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
|
1385 | 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
|
1386 | { |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1387 | JabberBuddyInfo *jbi = data; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1388 | JabberBuddyResource *jbr; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1389 | char *resource_name; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1390 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1391 | 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
|
1392 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1393 | 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
|
1394 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1395 | if (!from) |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1396 | return; |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1397 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1398 | 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
|
1399 | 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
|
1400 | 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
|
1401 | 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
|
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 | 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
|
1404 | 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
|
1405 | 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
|
1406 | 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
|
1407 | 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
|
1408 | 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
|
1409 | if (tzo_data[0] == 'Z' && tzo_data[1] == '\0') { |
|
41764
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1410 | jbr->tz_off = g_time_zone_new_offset(0); |
|
25827
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1411 | } else { |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1412 | 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
|
1413 | /* [+-]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
|
1414 | if (((*c == '+' || *c == '-') && (c = c + 1)) && |
|
41764
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1415 | sscanf(c, "%02d:%02d", &hours, &minutes) == 2) |
|
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1416 | { |
|
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1417 | gint32 tz_off = 60*60*hours + 60*minutes; |
|
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1418 | if (!offset_positive) { |
|
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1419 | tz_off *= -1; |
|
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1420 | } |
|
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1421 | |
|
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1422 | jbr->tz_off = g_time_zone_new_offset(tz_off); |
|
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1423 | |
|
25827
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1424 | } else { |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1425 | 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
|
1426 | 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
|
1427 | } |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1428 | } |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1429 | |
|
6adc5c7df7ae
Fix the timezone parsing (again) and display the timezone in the info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25825
diff
changeset
|
1430 | 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
|
1431 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1432 | } |
|
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 | |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1435 | 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
|
1436 | } |
|
23f62dd4aed5
Retrieve and display buddy's local time in Get Info dialog
Paul Aurich <darkrain42@pidgin.im>
parents:
25454
diff
changeset
|
1437 | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1438 | void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js) |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1439 | { |
| 40135 | 1440 | g_slist_free_full(js->pending_buddy_info_requests, (GDestroyNotify)jabber_buddy_info_destroy); |
| 1441 | js->pending_buddy_info_requests = NULL; | |
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1442 | } |
|
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1443 | |
| 13794 | 1444 | static gboolean jabber_buddy_get_info_timeout(gpointer data) |
| 1445 | { | |
| 1446 | JabberBuddyInfo *jbi = data; | |
| 1447 | ||
| 1448 | /* remove the pending callbacks */ | |
| 1449 | while(jbi->ids) { | |
| 1450 | char *id = jbi->ids->data; | |
| 1451 | jabber_iq_remove_callback_by_id(jbi->js, id); | |
|
40079
a37a1e349491
Replace g_[s]list_remove with g_[s]list_delete_link.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40062
diff
changeset
|
1452 | jbi->ids = g_slist_delete_link(jbi->ids, jbi->ids); |
| 13794 | 1453 | g_free(id); |
| 1454 | } | |
| 1455 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1456 | jbi->js->pending_buddy_info_requests = g_slist_remove(jbi->js->pending_buddy_info_requests, jbi); |
| 13794 | 1457 | jbi->timeout_handle = 0; |
| 1458 | ||
| 1459 | jabber_buddy_info_show_if_ready(jbi); | |
| 1460 | ||
| 1461 | return FALSE; | |
| 1462 | } | |
| 1463 | ||
|
17029
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1464 | 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
|
1465 | { |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1466 | /* 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
|
1467 | 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
|
1468 | return FALSE; |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1469 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1470 | if(purple_strequal(ns, NS_LAST_ACTIVITY)) { |
|
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1471 | if(purple_strequal(jbr->client.name, "Trillian")) { |
|
20350
ae3f3561e698
another day, another irritating workaround
Nathan Walp <nwalp@pidgin.im>
parents:
20320
diff
changeset
|
1472 | /* verified by nwalp 2007/05/09 */ |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1473 | 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
|
1474 | /* verified by nwalp 2007/09/19 */ |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1475 | 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
|
1476 | return TRUE; |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1477 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1478 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1479 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1480 | |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1481 | return FALSE; |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1482 | } |
|
dea59a003028
gross hack that will save me time in 30 second chunks
Nathan Walp <nwalp@pidgin.im>
parents:
17007
diff
changeset
|
1483 | |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1484 | static void |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1485 | 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
|
1486 | 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
|
1487 | JabberBuddyResource *jbr) |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1488 | { |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1489 | JabberIq *iq; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1490 | JabberBuddyInfoResource *jbir; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1491 | char *full_jid = NULL; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1492 | const char *to; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1493 | |
|
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
|
1494 | 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
|
1495 | 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
|
1496 | to = full_jid; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1497 | } else |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1498 | to = jid; |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1499 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1500 | 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
|
1501 | 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
|
1502 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1503 | if(!jbr->client.name) { |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1504 | 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
|
1505 | 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
|
1506 | 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
|
1507 | 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
|
1508 | jabber_iq_send(iq); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1509 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1510 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1511 | /* 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
|
1512 | * 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
|
1513 | * 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
|
1514 | * 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
|
1515 | * office. */ |
|
28984
1d84517d56eb
jabber: More namespaces! This is a good stopping point for now.
Paul Aurich <darkrain42@pidgin.im>
parents:
28883
diff
changeset
|
1516 | 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
|
1517 | 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
|
1518 | 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
|
1519 | 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
|
1520 | 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
|
1521 | jabber_iq_send(iq); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1522 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1523 | |
|
41764
5d2bc2736da2
Remove PURPLE_NO_TZ_OFF
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41314
diff
changeset
|
1524 | if (jbr->tz_off == NULL && |
|
41784
f864fee87775
Remove support for XEP 0115 Legacy Format
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41764
diff
changeset
|
1525 | (jbr->caps == NULL || |
|
f864fee87775
Remove support for XEP 0115 Legacy Format
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41764
diff
changeset
|
1526 | 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
|
1527 | PurpleXmlNode *child; |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1528 | 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
|
1529 | 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
|
1530 | 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
|
1531 | 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
|
1532 | 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
|
1533 | jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1534 | jabber_iq_send(iq); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1535 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1536 | |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1537 | g_free(full_jid); |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1538 | } |
|
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1539 | |
| 13794 | 1540 | static void jabber_buddy_get_info_for_jid(JabberStream *js, const char *jid) |
| 7014 | 1541 | { |
| 1542 | JabberIq *iq; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1543 | PurpleXmlNode *vcard; |
| 13794 | 1544 | GList *resources; |
| 1545 | JabberBuddy *jb; | |
| 1546 | 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
|
1547 | const char *slash; |
|
27484
9bbc40783bbb
Factor the per-resource IQs out into their own function.
Paul Aurich <darkrain42@pidgin.im>
parents:
27418
diff
changeset
|
1548 | gboolean is_bare_jid; |
| 13794 | 1549 | |
| 1550 | jb = jabber_buddy_find(js, jid, TRUE); | |
| 1551 | ||
| 1552 | /* invalid JID */ | |
| 1553 | if(!jb) | |
| 1554 | return; | |
| 1555 | ||
|
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
|
1556 | 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
|
1557 | 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
|
1558 | |
| 13794 | 1559 | jbi = g_new0(JabberBuddyInfo, 1); |
| 1560 | jbi->jid = g_strdup(jid); | |
| 1561 | jbi->js = js; | |
| 1562 | 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
|
1563 | 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
|
1564 | jbi->user_info = purple_notify_user_info_new(); |
| 7014 | 1565 | |
| 1566 | iq = jabber_iq_new(js, JABBER_IQ_GET); | |
| 1567 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1568 | 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
|
1569 | 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
|
1570 | purple_xmlnode_set_namespace(vcard, "vcard-temp"); |
| 7014 | 1571 | |
| 13794 | 1572 | jabber_iq_set_callback(iq, jabber_vcard_parse, jbi); |
| 1573 | jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); | |
| 7014 | 1574 | |
| 1575 | jabber_iq_send(iq); | |
| 13794 | 1576 | |
|
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
|
1577 | 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
|
1578 | if (jb->resources) { |
|
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1579 | 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
|
1580 | 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
|
1581 | 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
|
1582 | } |
|
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1583 | } else { |
|
22b6cd68c156
jabber: Fix getting info on your own JID, under some circumstances.
Paul Aurich <darkrain42@pidgin.im>
parents:
29184
diff
changeset
|
1584 | /* 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
|
1585 | 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
|
1586 | 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
|
1587 | 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
|
1588 | 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
|
1589 | 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
|
1590 | } |
|
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
|
1591 | } 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
|
1592 | 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
|
1593 | 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
|
1594 | 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
|
1595 | 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
|
1596 | 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
|
1597 | "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
|
1598 | "JabberBuddyResource!\n", jid); |
| 13794 | 1599 | } |
| 1600 | ||
|
15363
f6b9d1e3d0cb
[gaim-migrate @ 18092]
Evan Schoenberg <evands@pidgin.im>
parents:
15273
diff
changeset
|
1601 | 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
|
1602 | jbi->timeout_handle = g_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi); |
| 7014 | 1603 | } |
| 1604 | ||
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
1605 | void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
1606 | jabber_buddy_get_info(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40634
diff
changeset
|
1607 | PurpleConnection *gc, const char *who) |
| 10189 | 1608 | { |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1609 | 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
|
1610 | 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
|
1611 | |
|
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
|
1612 | 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
|
1613 | return; |
| 10189 | 1614 | |
|
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
|
1615 | 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
|
1616 | /* 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
|
1617 | 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
|
1618 | } 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
|
1619 | char *bare_jid = jabber_get_bare_jid(who); |
| 10189 | 1620 | jabber_buddy_get_info_for_jid(js, bare_jid); |
| 1621 | g_free(bare_jid); | |
| 1622 | } | |
|
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
|
1623 | |
|
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
|
1624 | jabber_id_free(jid); |
| 10189 | 1625 | } |
| 1626 | ||
| 7014 | 1627 | static void jabber_buddy_set_invisibility(JabberStream *js, const char *who, |
| 1628 | gboolean invisible) | |
| 1629 | { | |
| 15884 | 1630 | PurplePresence *gpresence; |
| 1631 | PurpleAccount *account; | |
| 1632 | PurpleStatus *status; | |
| 7014 | 1633 | 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
|
1634 | PurpleXmlNode *presence; |
| 9954 | 1635 | JabberBuddyState state; |
| 14525 | 1636 | char *msg; |
| 9954 | 1637 | int priority; |
| 7014 | 1638 | |
| 15884 | 1639 | account = purple_connection_get_account(js->gc); |
| 1640 | gpresence = purple_account_get_presence(account); | |
| 1641 | status = purple_presence_get_active_status(gpresence); | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9797
diff
changeset
|
1642 | |
| 15884 | 1643 | 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
|
1644 | presence = jabber_presence_create_js(js, state, msg, priority); |
| 9954 | 1645 | |
| 14525 | 1646 | g_free(msg); |
| 1647 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1648 | purple_xmlnode_set_attrib(presence, "to", who); |
| 7014 | 1649 | if(invisible) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1650 | purple_xmlnode_set_attrib(presence, "type", "invisible"); |
| 7014 | 1651 | jb->invisible |= JABBER_INVIS_BUDDY; |
| 1652 | } else { | |
| 1653 | jb->invisible &= ~JABBER_INVIS_BUDDY; | |
| 1654 | } | |
| 1655 | ||
| 1656 | 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
|
1657 | purple_xmlnode_free(presence); |
| 7014 | 1658 | } |
| 1659 | ||
| 15884 | 1660 | static void jabber_buddy_make_invisible(PurpleBlistNode *node, gpointer data) |
| 7014 | 1661 | { |
| 15884 | 1662 | PurpleBuddy *buddy; |
| 1663 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1664 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1665 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1666 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1667 | |
| 15884 | 1668 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1669 | 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
|
1670 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1671 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1672 | jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), TRUE); |
| 7014 | 1673 | } |
| 1674 | ||
| 15884 | 1675 | static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data) |
| 7014 | 1676 | { |
| 15884 | 1677 | PurpleBuddy *buddy; |
| 1678 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1679 | JabberStream *js; |
| 7014 | 1680 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1681 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 7014 | 1682 | |
| 15884 | 1683 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1684 | 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
|
1685 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1686 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1687 | jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), FALSE); |
| 7014 | 1688 | } |
| 1689 | ||
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1690 | static void cancel_presence_notification(gpointer data) |
| 7014 | 1691 | { |
| 15884 | 1692 | PurpleBuddy *buddy; |
| 1693 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1694 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1695 | |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1696 | buddy = data; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1697 | 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
|
1698 | 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
|
1699 | |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1700 | 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
|
1701 | } |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1702 | |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1703 | static void |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1704 | 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
|
1705 | gpointer data) |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1706 | { |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1707 | PurpleBuddy *buddy; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1708 | PurpleAccount *account; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1709 | PurpleConnection *gc; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1710 | const gchar *name; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1711 | char *msg; |
|
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1712 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1713 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 7014 | 1714 | |
| 15884 | 1715 | buddy = (PurpleBuddy *) node; |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1716 | 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
|
1717 | 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
|
1718 | gc = purple_account_get_connection(account); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1719 | |
|
28058
52eb7bf6e375
jabber: Prompt before cancelling presence notification to a buddy.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1720 | 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
|
1721 | "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
|
1722 | 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
|
1723 | 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
|
1724 | 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
|
1725 | g_free(msg); |
| 7014 | 1726 | } |
| 1727 | ||
| 15884 | 1728 | static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data) |
| 7250 | 1729 | { |
| 15884 | 1730 | PurpleBuddy *buddy; |
| 1731 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1732 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1733 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1734 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
| 7250 | 1735 | |
| 15884 | 1736 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1737 | 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
|
1738 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1739 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1740 | jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "subscribe"); |
| 7250 | 1741 | } |
| 1742 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1743 | |
| 15884 | 1744 | static void jabber_buddy_unsubscribe(PurpleBlistNode *node, gpointer data) |
| 7014 | 1745 | { |
| 15884 | 1746 | PurpleBuddy *buddy; |
| 1747 | PurpleConnection *gc; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1748 | JabberStream *js; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1749 | |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1750 | g_return_if_fail(PURPLE_IS_BUDDY(node)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1751 | |
| 15884 | 1752 | buddy = (PurpleBuddy *) node; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1753 | 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
|
1754 | js = purple_connection_get_protocol_data(gc); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1755 | |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24251
diff
changeset
|
1756 | 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
|
1757 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1758 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1759 | 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
|
1760 | 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
|
1761 | /* 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
|
1762 | PurpleBuddy *buddy = (PurpleBuddy *) node; |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1763 | 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
|
1764 | 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
|
1765 | 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
|
1766 | 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
|
1767 | 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
|
1768 | PurpleXmlNode *presence; |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1769 | JabberBuddyState state; |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1770 | char *msg; |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1771 | 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
|
1772 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1773 | 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
|
1774 | 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
|
1775 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1776 | 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
|
1777 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1778 | 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
|
1779 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1780 | 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
|
1781 | 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
|
1782 | } |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1783 | } |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1784 | |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1785 | 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
|
1786 | 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
|
1787 | /* 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
|
1788 | PurpleBuddy *buddy = (PurpleBuddy *) node; |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1789 | 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
|
1790 | 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
|
1791 | 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
|
1792 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1793 | 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
|
1794 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1795 | 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
|
1796 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1797 | 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
|
1798 | 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
|
1799 | } |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1800 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1801 | |
| 15884 | 1802 | static GList *jabber_buddy_menu(PurpleBuddy *buddy) |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1803 | { |
|
24942
ec72b773a9da
More struct hiding work
Richard Laager <rlaager@pidgin.im>
parents:
24251
diff
changeset
|
1804 | 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
|
1805 | 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
|
1806 | 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
|
1807 | 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
|
1808 | GList *jbrs; |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1809 | |
| 7014 | 1810 | GList *m = NULL; |
|
39481
4db28449567d
Rename PurpleMenuAction to PurpleActionMenu
Gary Kramlich <grim@reaperworld.com>
parents:
39479
diff
changeset
|
1811 | PurpleActionMenu *act; |
| 7395 | 1812 | |
| 1813 | if(!jb) | |
| 1814 | return m; | |
| 1815 | ||
|
29849
d7b910200dc5
jabber: Treat the version properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
29811
diff
changeset
|
1816 | 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
|
1817 | jb != js->user_jb) { |
| 8166 | 1818 | if(jb->invisible & JABBER_INVIS_BUDDY) { |
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
1819 | act = purple_action_menu_new(_("Un-hide From"), |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41311
diff
changeset
|
1820 | G_CALLBACK(jabber_buddy_make_visible), |
| 12919 | 1821 | NULL, NULL); |
| 8166 | 1822 | } else { |
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
1823 | act = purple_action_menu_new(_("Temporarily Hide From"), |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41311
diff
changeset
|
1824 | G_CALLBACK(jabber_buddy_make_invisible), |
| 13019 | 1825 | NULL, NULL); |
| 8166 | 1826 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1827 | m = g_list_append(m, act); |
| 7014 | 1828 | } |
| 1829 | ||
|
28071
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1830 | if(jb->subscription & JABBER_SUB_FROM && jb != js->user_jb) { |
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
1831 | act = purple_action_menu_new(_("Cancel Presence Notification"), |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41311
diff
changeset
|
1832 | G_CALLBACK(jabber_buddy_cancel_presence_notification), |
| 12919 | 1833 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1834 | m = g_list_append(m, act); |
| 7014 | 1835 | } |
| 1836 | ||
| 1837 | if(!(jb->subscription & JABBER_SUB_TO)) { | |
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
1838 | act = purple_action_menu_new(_("(Re-)Request authorization"), |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41311
diff
changeset
|
1839 | G_CALLBACK(jabber_buddy_rerequest_auth), |
| 12919 | 1840 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1841 | m = g_list_append(m, act); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1842 | |
|
28071
a0706162fefd
jabber: Store the "own JabberBuddy" in the JabberStream* struct.
Paul Aurich <darkrain42@pidgin.im>
parents:
28046
diff
changeset
|
1843 | } else if (jb != js->user_jb) { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1844 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1845 | /* shouldn't this just happen automatically when the buddy is |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1846 | removed? */ |
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
1847 | act = purple_action_menu_new(_("Unsubscribe"), |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41311
diff
changeset
|
1848 | G_CALLBACK(jabber_buddy_unsubscribe), |
| 12919 | 1849 | NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1850 | m = g_list_append(m, act); |
| 7014 | 1851 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1852 | |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1853 | /* |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1854 | * 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
|
1855 | * |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1856 | * 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
|
1857 | * 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
|
1858 | * 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
|
1859 | * 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
|
1860 | * |
|
8225f2507058
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
1861 | * 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
|
1862 | */ |
|
29059
8225f2507058
strchr() is safe when searching for an ASCII character in UTF8 strings.
Paul Aurich <darkrain42@pidgin.im>
parents:
28984
diff
changeset
|
1863 | if (strchr(name, '@') == NULL) { |
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
1864 | act = purple_action_menu_new(_("Log In"), |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41311
diff
changeset
|
1865 | G_CALLBACK(jabber_buddy_login), |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1866 | NULL, NULL); |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1867 | m = g_list_append(m, act); |
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
1868 | act = purple_action_menu_new(_("Log Out"), |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41311
diff
changeset
|
1869 | G_CALLBACK(jabber_buddy_logout), |
|
17808
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1870 | NULL, NULL); |
|
9b9a78bf9a03
Implemented logging in/out of gateways, as explained in XEP-0100.
Andreas Monitzer <am@adiumx.com>
parents:
17807
diff
changeset
|
1871 | 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
|
1872 | } |
|
26042
4dabdb5fe213
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
1873 | |
|
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
|
1874 | /* 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
|
1875 | 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
|
1876 | 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
|
1877 | 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
|
1878 | 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
|
1879 | 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
|
1880 | 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
|
1881 | JabberAdHocCommands *cmd = commands->data; |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41311
diff
changeset
|
1882 | act = purple_action_menu_new(cmd->name, G_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
|
1883 | 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
|
1884 | } |
|
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
|
1885 | } |
| 7014 | 1886 | |
| 1887 | return m; | |
| 1888 | } | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1889 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1890 | GList * |
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40551
diff
changeset
|
1891 | jabber_blist_node_menu(PurpleProtocolClient *client, PurpleBlistNode *node) |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1892 | { |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
33661
diff
changeset
|
1893 | if(PURPLE_IS_BUDDY(node)) { |
| 15884 | 1894 | return jabber_buddy_menu((PurpleBuddy *) node); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1895 | } else { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1896 | return NULL; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1897 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1898 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
1899 | |
| 12683 | 1900 | |
| 15884 | 1901 | static void user_search_result_add_buddy_cb(PurpleConnection *gc, GList *row, void *user_data) |
| 11675 | 1902 | { |
| 1903 | /* XXX find out the jid */ | |
| 15884 | 1904 | purple_blist_request_add_buddy(purple_connection_get_account(gc), |
| 11675 | 1905 | g_list_nth_data(row, 0), NULL, NULL); |
| 1906 | } | |
| 1907 | ||
|
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
|
1908 | 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
|
1909 | 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
|
1910 | PurpleXmlNode *packet, gpointer data) |
| 11675 | 1911 | { |
| 15884 | 1912 | PurpleNotifySearchResults *results; |
| 1913 | PurpleNotifySearchColumn *column; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1914 | PurpleXmlNode *x, *query, *item, *field; |
| 11675 | 1915 | |
| 1916 | /* 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
|
1917 | if(!(query = purple_xmlnode_get_child(packet, "query"))) |
| 11675 | 1918 | return; |
| 1919 | ||
| 15884 | 1920 | 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
|
1921 | 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
|
1922 | 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
|
1923 | 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
|
1924 | |
| 15884 | 1925 | 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
|
1926 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1927 | 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
|
1928 | PurpleXmlNode *field = purple_xmlnode_get_child(reported, "field"); |
| 11675 | 1929 | while(field) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1930 | 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
|
1931 | const char *label = purple_xmlnode_get_attrib(field, "label"); |
| 11675 | 1932 | if(var) { |
| 15884 | 1933 | column = purple_notify_searchresults_column_new(label ? label : var); |
| 1934 | 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
|
1935 | column_vars = g_slist_append(column_vars, (char *)var); |
| 11675 | 1936 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1937 | field = purple_xmlnode_get_next_twin(field); |
| 11675 | 1938 | } |
| 1939 | } | |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1940 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1941 | item = purple_xmlnode_get_child(x, "item"); |
| 11675 | 1942 | while(item) { |
| 1943 | 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
|
1944 | GSList *l; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1945 | 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
|
1946 | 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
|
1947 | |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1948 | 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
|
1949 | /* |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1950 | * 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
|
1951 | * 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
|
1952 | */ |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1953 | 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
|
1954 | field != NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1955 | 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
|
1956 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1957 | if ((var = purple_xmlnode_get_attrib(field, "var")) && |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
1958 | 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
|
1959 | (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
|
1960 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1961 | 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
|
1962 | 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
|
1963 | break; |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1964 | } |
| 11675 | 1965 | } |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1966 | 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
|
1967 | /* 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
|
1968 | row = g_list_append(row, NULL); |
| 11675 | 1969 | } |
| 15884 | 1970 | 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
|
1971 | item = purple_xmlnode_get_next_twin(item); |
| 11675 | 1972 | } |
|
19963
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1973 | |
|
46f23859d166
Fix the bug reported to the devel mailing list by Georgi Kirilov.
Mark Doliner <markdoliner@pidgin.im>
parents:
19931
diff
changeset
|
1974 | g_slist_free(column_vars); |
| 11675 | 1975 | } else { |
| 1976 | /* old skool */ | |
| 15884 | 1977 | purple_debug_info("jabber", "old-skool\n"); |
| 11675 | 1978 | |
| 15884 | 1979 | column = purple_notify_searchresults_column_new(_("JID")); |
| 1980 | purple_notify_searchresults_column_add(results, column); | |
| 1981 | column = purple_notify_searchresults_column_new(_("First Name")); | |
| 1982 | purple_notify_searchresults_column_add(results, column); | |
| 1983 | column = purple_notify_searchresults_column_new(_("Last Name")); | |
| 1984 | purple_notify_searchresults_column_add(results, column); | |
| 1985 | column = purple_notify_searchresults_column_new(_("Nickname")); | |
| 1986 | 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
|
1987 | column = purple_notify_searchresults_column_new(_("Email")); |
| 15884 | 1988 | purple_notify_searchresults_column_add(results, column); |
| 11675 | 1989 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1990 | for(item = purple_xmlnode_get_child(query, "item"); item; item = purple_xmlnode_get_next_twin(item)) { |
| 11675 | 1991 | 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
|
1992 | PurpleXmlNode *node; |
| 11675 | 1993 | GList *row = NULL; |
| 1994 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1995 | if(!(jid = purple_xmlnode_get_attrib(item, "jid"))) |
| 11675 | 1996 | continue; |
| 1997 | ||
| 1998 | 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
|
1999 | 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
|
2000 | 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
|
2001 | 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
|
2002 | 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
|
2003 | 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
|
2004 | 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
|
2005 | 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
|
2006 | 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
|
2007 | purple_debug_info("jabber", "row=%p\n", row); |
| 15884 | 2008 | purple_notify_searchresults_row_add(results, row); |
| 11675 | 2009 | } |
| 2010 | } | |
| 2011 | ||
| 15884 | 2012 | purple_notify_searchresults_button_add(results, PURPLE_NOTIFY_BUTTON_ADD, |
| 11675 | 2013 | user_search_result_add_buddy_cb); |
| 2014 | ||
| 15884 | 2015 | purple_notify_searchresults(js->gc, NULL, NULL, _("The following are the results of your search"), results, NULL, NULL); |
| 11675 | 2016 | } |
| 2017 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2018 | static void user_search_x_data_cb(JabberStream *js, PurpleXmlNode *result, gpointer data) |
| 11675 | 2019 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2020 | PurpleXmlNode *query; |
| 11675 | 2021 | JabberIq *iq; |
| 13345 | 2022 | char *dir_server = data; |
|
21388
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2023 | const char *type; |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2024 | |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2025 | /* 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
|
2026 | * 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
|
2027 | * 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
|
2028 | type = purple_xmlnode_get_attrib(result, "type"); |
| 38260 | 2029 | if(purple_strequal(type, "cancel")) { |
|
21388
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2030 | g_free(dir_server); |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2031 | return; |
|
108195e86aa3
don't send a canceled user query
Nathan Walp <nwalp@pidgin.im>
parents:
21381
diff
changeset
|
2032 | } |
| 11675 | 2033 | |
| 2034 | 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
|
2035 | query = purple_xmlnode_get_child(iq->node, "query"); |
| 11675 | 2036 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2037 | purple_xmlnode_insert_child(query, result); |
| 11675 | 2038 | |
| 2039 | 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
|
2040 | purple_xmlnode_set_attrib(iq->node, "to", dir_server); |
| 11675 | 2041 | jabber_iq_send(iq); |
| 13345 | 2042 | g_free(dir_server); |
| 11675 | 2043 | } |
| 2044 | ||
| 2045 | struct user_search_info { | |
| 2046 | JabberStream *js; | |
| 2047 | char *directory_server; | |
| 2048 | }; | |
| 2049 | ||
| 15884 | 2050 | static void user_search_cancel_cb(struct user_search_info *usi, PurpleRequestFields *fields) |
| 11675 | 2051 | { |
| 2052 | g_free(usi->directory_server); | |
| 2053 | g_free(usi); | |
| 2054 | } | |
| 2055 | ||
| 15884 | 2056 | static void user_search_cb(struct user_search_info *usi, PurpleRequestFields *fields) |
| 11675 | 2057 | { |
| 2058 | JabberStream *js = usi->js; | |
| 2059 | JabberIq *iq; | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2060 | PurpleXmlNode *query; |
| 11675 | 2061 | GList *groups, *flds; |
| 2062 | ||
| 2063 | 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
|
2064 | query = purple_xmlnode_get_child(iq->node, "query"); |
| 11675 | 2065 | |
| 15884 | 2066 | for(groups = purple_request_fields_get_groups(fields); groups; groups = groups->next) { |
| 2067 | for(flds = purple_request_field_group_get_fields(groups->data); | |
| 11675 | 2068 | flds; flds = flds->next) { |
| 15884 | 2069 | PurpleRequestField *field = flds->data; |
| 2070 | const char *id = purple_request_field_get_id(field); | |
| 2071 | const char *value = purple_request_field_string_get_value(field); | |
| 11675 | 2072 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
2073 | 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
|
2074 | 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
|
2075 | purple_xmlnode_insert_data(y, value, -1); |
| 11675 | 2076 | } |
| 2077 | } | |
| 2078 | } | |
| 2079 | ||
| 2080 | 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
|
2081 | purple_xmlnode_set_attrib(iq->node, "to", usi->directory_server); |
| 11675 | 2082 | jabber_iq_send(iq); |
| 2083 | ||
| 2084 | g_free(usi->directory_server); | |
| 2085 | g_free(usi); | |
| 2086 | } | |
| 2087 | ||
|
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
|
2088 | 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
|
2089 | 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
|
2090 | PurpleXmlNode *packet, gpointer data) |
| 11675 | 2091 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2092 | PurpleXmlNode *query, *x; |
| 11675 | 2093 | |
|
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
|
2094 | if (!from) |
| 11675 | 2095 | return; |
| 2096 | ||
|
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
|
2097 | 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
|
2098 | char *msg = jabber_parse_error(js, packet, NULL); |
| 13794 | 2099 | |
|
13634
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2100 | if(!msg) |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2101 | msg = g_strdup(_("Unknown error")); |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2102 | |
| 15884 | 2103 | 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
|
2104 | _("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
|
2105 | purple_request_cpar_from_connection(js->gc)); |
|
13634
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2106 | g_free(msg); |
|
e9f9cef982d7
[gaim-migrate @ 16031]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13619
diff
changeset
|
2107 | |
| 13345 | 2108 | return; |
| 2109 | } | |
| 2110 | ||
| 11675 | 2111 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2112 | if(!(query = purple_xmlnode_get_child(packet, "query"))) |
| 11675 | 2113 | return; |
| 2114 | ||
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2115 | if((x = purple_xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) { |
| 13345 | 2116 | jabber_x_data_request(js, x, user_search_x_data_cb, g_strdup(from)); |
| 11675 | 2117 | return; |
| 2118 | } else { | |
| 2119 | 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
|
2120 | PurpleXmlNode *instnode; |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2121 | char *instructions = NULL; |
| 15884 | 2122 | PurpleRequestFields *fields; |
| 2123 | PurpleRequestFieldGroup *group; | |
| 2124 | PurpleRequestField *field; | |
| 11675 | 2125 | |
| 2126 | /* old skool */ | |
| 15884 | 2127 | fields = purple_request_fields_new(); |
| 2128 | group = purple_request_field_group_new(NULL); | |
| 2129 | purple_request_fields_add_group(fields, group); | |
| 11675 | 2130 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2131 | if((instnode = purple_xmlnode_get_child(query, "instructions"))) |
|
13574
433001d94e3e
[gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents:
13572
diff
changeset
|
2132 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2133 | char *tmp = purple_xmlnode_get_data(instnode); |
| 13794 | 2134 | |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2135 | if(tmp) |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2136 | { |
| 13794 | 2137 | /* 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
|
2138 | list in jabber_user_dir_comments[]) */ |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2139 | instructions = g_strdup_printf(_("Server Instructions: %s"), _(tmp)); |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2140 | g_free(tmp); |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2141 | } |
|
13574
433001d94e3e
[gaim-migrate @ 15952]
Richard Laager <rlaager@pidgin.im>
parents:
13572
diff
changeset
|
2142 | } |
| 13794 | 2143 | |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2144 | if(!instructions) |
|
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2145 | { |
| 11675 | 2146 | 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
|
2147 | "for any matching XMPP users.")); |
|
13617
983b0c58fcae
[gaim-migrate @ 16002]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
13574
diff
changeset
|
2148 | } |
| 11675 | 2149 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2150 | if(purple_xmlnode_get_child(query, "first")) { |
| 15884 | 2151 | field = purple_request_field_string_new("first", _("First Name"), |
| 11675 | 2152 | NULL, FALSE); |
| 15884 | 2153 | purple_request_field_group_add_field(group, field); |
| 11675 | 2154 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2155 | if(purple_xmlnode_get_child(query, "last")) { |
| 15884 | 2156 | field = purple_request_field_string_new("last", _("Last Name"), |
| 11675 | 2157 | NULL, FALSE); |
| 15884 | 2158 | purple_request_field_group_add_field(group, field); |
| 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 | if(purple_xmlnode_get_child(query, "nick")) { |
| 15884 | 2161 | field = purple_request_field_string_new("nick", _("Nickname"), |
| 11675 | 2162 | NULL, FALSE); |
| 15884 | 2163 | purple_request_field_group_add_field(group, field); |
| 11675 | 2164 | } |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
2165 | 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
|
2166 | field = purple_request_field_string_new("email", _("Email Address"), |
| 11675 | 2167 | NULL, FALSE); |
| 15884 | 2168 | purple_request_field_group_add_field(group, field); |
| 11675 | 2169 | } |
| 2170 | ||
| 2171 | usi = g_new0(struct user_search_info, 1); | |
| 2172 | usi->js = js; | |
| 2173 | usi->directory_server = g_strdup(from); | |
| 2174 | ||
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
2175 | 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
|
2176 | _("Search for XMPP users"), instructions, fields, |
| 11675 | 2177 | _("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
|
2178 | _("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
|
2179 | purple_request_cpar_from_connection(js->gc), |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
2180 | usi); |
| 11675 | 2181 | |
| 2182 | g_free(instructions); | |
| 2183 | } | |
| 2184 | } | |
| 2185 | ||
|
41791
3bf884522663
xmpp: Remove unused prototypes and code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41789
diff
changeset
|
2186 | static void |
|
3bf884522663
xmpp: Remove unused prototypes and code
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41789
diff
changeset
|
2187 | jabber_user_search(JabberStream *js, const char *directory) |
| 11675 | 2188 | { |
| 2189 | JabberIq *iq; | |
| 2190 | ||
| 2191 | /* XXX: should probably better validate the directory we're given */ | |
| 2192 | if(!directory || !*directory) { | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
2193 | 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
|
2194 | _("Invalid Directory"), NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34332
diff
changeset
|
2195 | purple_request_cpar_from_connection(js->gc)); |
| 11675 | 2196 | return; |
| 2197 | } | |
| 2198 | ||
|
31660
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2199 | /* 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
|
2200 | 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
|
2201 | if(js->user_directories && js->user_directories->data && |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38256
diff
changeset
|
2202 | 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
|
2203 | 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
|
2204 | } |
|
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2205 | else { |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32277
diff
changeset
|
2206 | 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
|
2207 | } |
|
fd970a73f5ff
jabber: Remember the last-used user directory. Closes #12451
Keith Moyer <pidgin@keithmoyer.com>
parents:
31318
diff
changeset
|
2208 | |
| 11675 | 2209 | 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
|
2210 | purple_xmlnode_set_attrib(iq->node, "to", directory); |
| 11675 | 2211 | |
| 2212 | jabber_iq_set_callback(iq, user_search_fields_result_cb, NULL); | |
| 2213 | ||
| 2214 | jabber_iq_send(iq); | |
| 2215 | } | |
| 2216 | ||
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2217 | void |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2218 | jabber_user_search_begin(G_GNUC_UNUSED GSimpleAction *action, |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2219 | GVariant *parameter, G_GNUC_UNUSED gpointer data) |
| 11675 | 2220 | { |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2221 | const char *account_id = NULL; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2222 | PurpleAccountManager *manager = NULL; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2223 | PurpleAccount *account = NULL; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2224 | PurpleConnection *connection = NULL; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2225 | JabberStream *js = NULL; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2226 | const char *def_val = NULL; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2227 | |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2228 | if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2229 | g_critical("XMPP User Search action parameter is of incorrect type %s", |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2230 | g_variant_get_type_string(parameter)); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2231 | } |
| 11675 | 2232 | |
|
41789
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2233 | account_id = g_variant_get_string(parameter, NULL); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2234 | manager = purple_account_manager_get_default(); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2235 | account = purple_account_manager_find_by_id(manager, account_id); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2236 | connection = purple_account_get_connection(account); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2237 | |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2238 | js = purple_connection_get_protocol_data(connection); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2239 | def_val = purple_account_get_string(account, "user_directory", ""); |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2240 | if(*def_val == '\0' && js->user_directories) { |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2241 | def_val = js->user_directories->data; |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2242 | } |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2243 | |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2244 | purple_request_input(connection, _("Enter a User Directory"), |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2245 | _("Enter a User Directory"), |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2246 | _("Select a user directory to search"), |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2247 | def_val, FALSE, FALSE, NULL, |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2248 | _("Search Directory"), G_CALLBACK(jabber_user_search), |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2249 | _("Cancel"), NULL, |
|
7e73a8cc44e2
xmpp: Port static actions to PurpleProtocolActionsInterface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41784
diff
changeset
|
2250 | NULL, js); |
| 11675 | 2251 | } |
| 13794 | 2252 | |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2253 | 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
|
2254 | 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
|
2255 | { |
|
41784
f864fee87775
Remove support for XEP 0115 Legacy Format
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41764
diff
changeset
|
2256 | return jbr->caps != NULL; |
|
28879
27cc8217e86e
jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents:
28828
diff
changeset
|
2257 | } |
|
27cc8217e86e
jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents:
28828
diff
changeset
|
2258 | |
|
27cc8217e86e
jabber: Determine if a buddy can receive a file transfer (when we have
Marcus Lundblad <malu@pidgin.im>
parents:
28828
diff
changeset
|
2259 | gboolean |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2260 | 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
|
2261 | { |
|
24802
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24732
diff
changeset
|
2262 | const GList *node = NULL; |
| 13794 | 2263 | |
|
41784
f864fee87775
Remove support for XEP 0115 Legacy Format
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41764
diff
changeset
|
2264 | if (jbr->caps == NULL) { |
|
27696
2cd9b9331f06
Lower the severity of this message.
Paul Aurich <darkrain42@pidgin.im>
parents:
27619
diff
changeset
|
2265 | 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
|
2266 | "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
|
2267 | return FALSE; |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2268 | } |
| 13794 | 2269 | |
|
41784
f864fee87775
Remove support for XEP 0115 Legacy Format
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41764
diff
changeset
|
2270 | node = g_list_find_custom(jbr->caps->features, cap, (GCompareFunc)strcmp); |
|
24802
eb481e98ac6a
Sprinkle jabber_resource_has_capability in places
Paul Aurich <darkrain42@pidgin.im>
parents:
24732
diff
changeset
|
2271 | return (node != NULL); |
|
23626
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2272 | } |
|
e21afec2f485
Custom smileys for XMPP according to XEP 0231. Refs #5627.
Marcus Lundblad <malu@pidgin.im>
parents:
23393
diff
changeset
|
2273 | |
|
25577
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2274 | const gchar * |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2275 | 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
|
2276 | const gchar *category) |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2277 | { |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2278 | const GList *iter = NULL; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2279 | |
|
41784
f864fee87775
Remove support for XEP 0115 Legacy Format
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41764
diff
changeset
|
2280 | if (jbr->caps != NULL) { |
|
f864fee87775
Remove support for XEP 0115 Legacy Format
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41764
diff
changeset
|
2281 | for (iter = jbr->caps->identities ; iter ; iter = g_list_next(iter)) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2282 | const JabberIdentity *identity = |
|
27286
f637c4c27815
Fixup after propagating new caps stuff
Marcus Lundblad <malu@pidgin.im>
parents:
27285
diff
changeset
|
2283 | (JabberIdentity *) iter->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2284 | |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
2285 | 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
|
2286 | return identity->type; |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2287 | } |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2288 | } |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2289 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30014
diff
changeset
|
2290 | |
|
25577
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2291 | return NULL; |
|
ca0b40451bbc
Set a value "type" in the ui_info hash table
Marcus Lundblad <malu@pidgin.im>
parents:
25575
diff
changeset
|
2292 | } |