Mercurial > pidgin
comparison libpurple/protocols/jabber/roster.c @ 28760:0f7025534fc5
jabber: Roster Versioning support.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 06 Dec 2009 00:52:10 +0000 |
parents | 05867b153f03 |
children | 9ab75ab032b4 |
comparison
equal
deleted
inserted
replaced
28759:f267c1608102 | 28760:0f7025534fc5 |
---|---|
45 } | 45 } |
46 | 46 |
47 return g_string_free(out, FALSE); | 47 return g_string_free(out, FALSE); |
48 } | 48 } |
49 | 49 |
50 static void roster_request_cb(JabberStream *js, const char *from, | |
51 JabberIqType type, const char *id, | |
52 xmlnode *packet, gpointer data) | |
53 { | |
54 xmlnode *query; | |
55 | |
56 if (type == JABBER_IQ_ERROR) { | |
57 /* | |
58 * This shouldn't happen in any real circumstances and | |
59 * likely constitutes a server-side misconfiguration (i.e. | |
60 * explicitly not loading mod_roster...) | |
61 */ | |
62 purple_debug_error("jabber", "Error retrieving roster!?\n"); | |
63 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
64 return; | |
65 } | |
66 | |
67 query = xmlnode_get_child(packet, "query"); | |
68 if (query == NULL) { | |
69 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
70 return; | |
71 } | |
72 | |
73 jabber_roster_parse(js, from, type, id, query); | |
74 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
75 } | |
76 | |
50 void jabber_roster_request(JabberStream *js) | 77 void jabber_roster_request(JabberStream *js) |
51 { | 78 { |
79 PurpleAccount *account; | |
80 const char *ver; | |
52 JabberIq *iq; | 81 JabberIq *iq; |
82 xmlnode *query; | |
83 | |
84 account = purple_connection_get_account(js->gc); | |
85 ver = purple_account_get_string(account, "roster_ver", ""); | |
53 | 86 |
54 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster"); | 87 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:roster"); |
88 query = xmlnode_get_child(iq->node, "query"); | |
89 xmlnode_set_attrib(query, "ver", ver); | |
90 jabber_iq_set_callback(iq, roster_request_cb, NULL); | |
55 | 91 |
56 jabber_iq_send(iq); | 92 jabber_iq_send(iq); |
57 } | 93 } |
58 | 94 |
59 static void remove_purple_buddies(JabberStream *js, const char *jid) | 95 static void remove_purple_buddies(JabberStream *js, const char *jid) |
153 | 189 |
154 void jabber_roster_parse(JabberStream *js, const char *from, | 190 void jabber_roster_parse(JabberStream *js, const char *from, |
155 JabberIqType type, const char *id, xmlnode *query) | 191 JabberIqType type, const char *id, xmlnode *query) |
156 { | 192 { |
157 xmlnode *item, *group; | 193 xmlnode *item, *group; |
194 const char *ver; | |
158 | 195 |
159 if (!jabber_is_own_account(js, from)) { | 196 if (!jabber_is_own_account(js, from)) { |
160 purple_debug_warning("jabber", "Received bogon roster push from %s\n", | 197 purple_debug_warning("jabber", "Received bogon roster push from %s\n", |
161 from); | 198 from); |
162 return; | 199 return; |
225 if (jb == js->user_jb) | 262 if (jb == js->user_jb) |
226 jabber_presence_fake_to_self(js, NULL); | 263 jabber_presence_fake_to_self(js, NULL); |
227 } | 264 } |
228 } | 265 } |
229 | 266 |
267 ver = xmlnode_get_attrib(query, "ver"); | |
268 if (ver) { | |
269 PurpleAccount *account = purple_connection_get_account(js->gc); | |
270 purple_account_set_string(account, "roster_ver", ver); | |
271 } | |
272 | |
230 js->currently_parsing_roster_push = FALSE; | 273 js->currently_parsing_roster_push = FALSE; |
231 | |
232 /* if we're just now parsing the roster for the first time, | |
233 * then now would be the time to declare ourselves connected. | |
234 */ | |
235 if (js->state != JABBER_STREAM_CONNECTED) | |
236 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
237 } | 274 } |
238 | 275 |
239 /* jabber_roster_update frees the GSList* passed in */ | 276 /* jabber_roster_update frees the GSList* passed in */ |
240 static void jabber_roster_update(JabberStream *js, const char *name, | 277 static void jabber_roster_update(JabberStream *js, const char *name, |
241 GSList *groups) | 278 GSList *groups) |