Mercurial > pidgin
comparison libpurple/protocols/jabber/roster.c @ 27498:ff640fedbfde
Pass around a copy of our bare JID
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 10 Jun 2009 03:58:11 +0000 |
parents | 9a5a9a4e7626 |
children | efb40ca43589 |
comparison
equal
deleted
inserted
replaced
27497:9a5a9a4e7626 | 27498:ff640fedbfde |
---|---|
51 | 51 |
52 g_slist_free(buddies); | 52 g_slist_free(buddies); |
53 } | 53 } |
54 | 54 |
55 static void add_purple_buddy_to_groups(JabberStream *js, const char *jid, | 55 static void add_purple_buddy_to_groups(JabberStream *js, const char *jid, |
56 const char *alias, GSList *groups) | 56 const char *alias, GSList *groups, const char *own_jid) |
57 { | 57 { |
58 GSList *buddies, *l; | 58 GSList *buddies, *l; |
59 gchar *my_bare_jid; | |
60 GList *pool = NULL; | 59 GList *pool = NULL; |
61 | 60 |
62 buddies = purple_find_buddies(js->gc->account, jid); | 61 buddies = purple_find_buddies(js->gc->account, jid); |
63 | 62 |
64 if(!groups) { | 63 if(!groups) { |
72 g_slist_free(buddies); | 71 g_slist_free(buddies); |
73 return; | 72 return; |
74 } | 73 } |
75 } | 74 } |
76 | 75 |
77 my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); | |
78 | |
79 while(buddies) { | 76 while(buddies) { |
80 PurpleBuddy *b = buddies->data; | 77 PurpleBuddy *b = buddies->data; |
81 PurpleGroup *g = purple_buddy_get_group(b); | 78 PurpleGroup *g = purple_buddy_get_group(b); |
82 | 79 |
83 buddies = g_slist_delete_link(buddies, buddies); | 80 buddies = g_slist_delete_link(buddies, buddies); |
130 purple_blist_alias_buddy(b, alias); | 127 purple_blist_alias_buddy(b, alias); |
131 | 128 |
132 /* If we just learned about ourself, then fake our status, | 129 /* If we just learned about ourself, then fake our status, |
133 * because we won't be receiving a normal presence message | 130 * because we won't be receiving a normal presence message |
134 * about ourself. */ | 131 * about ourself. */ |
135 if(!strcmp(purple_buddy_get_name(b), my_bare_jid)) | 132 if(!strcmp(purple_buddy_get_name(b), own_jid)) |
136 jabber_presence_fake_to_self(js, NULL); | 133 jabber_presence_fake_to_self(js, NULL); |
137 | 134 |
138 g_free(groups->data); | 135 g_free(groups->data); |
139 groups = g_slist_delete_link(groups, groups); | 136 groups = g_slist_delete_link(groups, groups); |
140 } | 137 } |
145 PurpleBuddy *b = pool->data; | 142 PurpleBuddy *b = pool->data; |
146 purple_blist_remove_buddy(b); | 143 purple_blist_remove_buddy(b); |
147 pool = g_list_delete_link(pool, pool); | 144 pool = g_list_delete_link(pool, pool); |
148 } | 145 } |
149 | 146 |
150 g_free(my_bare_jid); | |
151 g_slist_free(buddies); | 147 g_slist_free(buddies); |
152 } | 148 } |
153 | 149 |
154 void jabber_roster_parse(JabberStream *js, const char *from, | 150 void jabber_roster_parse(JabberStream *js, const char *from, |
155 JabberIqType type, const char *id, xmlnode *query) | 151 JabberIqType type, const char *id, xmlnode *query) |
226 } | 222 } |
227 | 223 |
228 groups = g_slist_prepend(groups, group_name); | 224 groups = g_slist_prepend(groups, group_name); |
229 } | 225 } |
230 | 226 |
231 add_purple_buddy_to_groups(js, jid, name, groups); | 227 add_purple_buddy_to_groups(js, jid, name, groups, own_jid); |
232 } | 228 } |
233 } | 229 } |
234 | 230 |
235 g_free(own_jid); | 231 g_free(own_jid); |
236 js->currently_parsing_roster_push = FALSE; | 232 js->currently_parsing_roster_push = FALSE; |
326 { | 322 { |
327 JabberStream *js = gc->proto_data; | 323 JabberStream *js = gc->proto_data; |
328 char *who; | 324 char *who; |
329 JabberBuddy *jb; | 325 JabberBuddy *jb; |
330 JabberBuddyResource *jbr; | 326 JabberBuddyResource *jbr; |
331 char *my_bare_jid; | 327 char *own_jid; |
332 const char *name; | 328 const char *name; |
333 | 329 |
334 /* If we haven't received the roster yet, ignore any adds */ | 330 /* If we haven't received the roster yet, ignore any adds */ |
335 if (js->state != JABBER_STREAM_CONNECTED) | 331 if (js->state != JABBER_STREAM_CONNECTED) |
336 return; | 332 return; |
344 purple_debug_info("jabber", "jabber_roster_add_buddy(): Adding %s\n", | 340 purple_debug_info("jabber", "jabber_roster_add_buddy(): Adding %s\n", |
345 name); | 341 name); |
346 | 342 |
347 jabber_roster_update(js, who, NULL); | 343 jabber_roster_update(js, who, NULL); |
348 | 344 |
349 my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); | 345 own_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); |
350 if(!strcmp(who, my_bare_jid)) { | 346 if (g_str_equal(who, own_jid)) { |
351 jabber_presence_fake_to_self(js, NULL); | 347 jabber_presence_fake_to_self(js, NULL); |
352 } else if(!jb || !(jb->subscription & JABBER_SUB_TO)) { | 348 } else if(!jb || !(jb->subscription & JABBER_SUB_TO)) { |
353 jabber_presence_subscription_set(js, who, "subscribe"); | 349 jabber_presence_subscription_set(js, who, "subscribe"); |
354 } else if((jbr =jabber_buddy_find_resource(jb, NULL))) { | 350 } else if((jbr =jabber_buddy_find_resource(jb, NULL))) { |
355 purple_prpl_got_user_status(gc->account, who, | 351 purple_prpl_got_user_status(gc->account, who, |
356 jabber_buddy_state_get_status_id(jbr->state), | 352 jabber_buddy_state_get_status_id(jbr->state), |
357 "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL); | 353 "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL); |
358 } | 354 } |
359 | 355 |
360 g_free(my_bare_jid); | 356 g_free(own_jid); |
361 g_free(who); | 357 g_free(who); |
362 } | 358 } |
363 | 359 |
364 void jabber_roster_alias_change(PurpleConnection *gc, const char *name, const char *alias) | 360 void jabber_roster_alias_change(PurpleConnection *gc, const char *name, const char *alias) |
365 { | 361 { |