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