Mercurial > pidgin
changeset 8185:3a229ad2fab0
[gaim-migrate @ 8906]
take 1 of UberUglyHack
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 30 Jan 2004 21:56:31 +0000 |
parents | f05d0a317f45 |
children | 8efff3aa4e39 |
files | src/protocols/jabber/buddy.c src/protocols/jabber/presence.c src/protocols/jabber/presence.h src/protocols/jabber/roster.c |
diffstat | 4 files changed, 47 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/jabber/buddy.c Thu Jan 29 17:39:32 2004 +0000 +++ b/src/protocols/jabber/buddy.c Fri Jan 30 21:56:31 2004 +0000 @@ -912,7 +912,9 @@ */ - if(js->protocol_version == JABBER_PROTO_0_9) { + /* XXX: fix the NOT ME below */ + + if(js->protocol_version == JABBER_PROTO_0_9 /* && NOT ME */) { pbm = g_new0(struct proto_buddy_menu, 1); if(jb->invisible & JABBER_INVIS_BUDDY) { pbm->label = _("Un-hide From"); @@ -925,7 +927,7 @@ m = g_list_append(m, pbm); } - if(jb->subscription & JABBER_SUB_FROM) { + if(jb->subscription & JABBER_SUB_FROM /* && NOT ME */) { pbm = g_new0(struct proto_buddy_menu, 1); pbm->label = _("Cancel Presence Notification"); pbm->callback = jabber_buddy_cancel_presence_notification; @@ -939,7 +941,7 @@ pbm->callback = jabber_buddy_rerequest_auth; pbm->gc = gc; m = g_list_append(m, pbm); - } else { + } else /* if(NOT ME) */{ pbm = g_new0(struct proto_buddy_menu, 1); pbm->label = _("Unsubscribe"); pbm->callback = jabber_buddy_unsubscribe;
--- a/src/protocols/jabber/presence.c Thu Jan 29 17:39:32 2004 +0000 +++ b/src/protocols/jabber/presence.c Fri Jan 30 21:56:31 2004 +0000 @@ -45,6 +45,35 @@ jabber_send(chat->js, presence); } +static int show_to_state(const char *show) { + if(!show) + return 0; + else if(!strcmp(show, "away") || !strcmp(show, _("Away"))) + return JABBER_STATE_AWAY; + else if(!strcmp(show, "chat") || !strcmp(show, _("Chatty"))) + return JABBER_STATE_CHAT; + else if(!strcmp(show, "xa") || !strcmp(show, _("Extended Away"))) + return JABBER_STATE_XA; + else if(!strcmp(show, "dnd") || !strcmp(show, _("Do Not Disturb"))) + return JABBER_STATE_DND; + return 0; +} + +void jabber_presence_fake_to_self(JabberStream *js, const char *show, const char *status) { + char *my_base_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); + if(gaim_find_buddy(js->gc->account, my_base_jid)) { + JabberBuddy *jb; + JabberBuddyResource *jbr; + if((jb = jabber_buddy_find(js, my_base_jid, TRUE))) { + jabber_buddy_track_resource(jb, js->user->resource, 0, + show_to_state(show), (status && *status) ? status : NULL); + if((jbr = jabber_buddy_find_resource(jb, NULL))) + serv_got_update(js->gc, my_base_jid, 1, 0, 0, 0, jbr->state); + } + } + g_free(my_base_jid); +} + void jabber_presence_send(GaimConnection *gc, const char *state, const char *msg) @@ -64,10 +93,12 @@ g_free(gc->away); gc->away = stripped; - presence = jabber_presence_create(state, msg); + presence = jabber_presence_create(state, stripped); jabber_send(js, presence); g_hash_table_foreach(js->chats, chats_send_presence_foreach, presence); xmlnode_free(presence); + + jabber_presence_fake_to_self(js, state, stripped); } xmlnode *jabber_presence_create(const char *state, const char *msg) @@ -199,17 +230,7 @@ } else { if((y = xmlnode_get_child(packet, "show"))) { char *show = xmlnode_get_data(y); - if(!show) { - state = 0; - } else if(!strcasecmp(show, "away")) { - state = JABBER_STATE_AWAY; - } else if(!strcasecmp(show, "chat")) { - state = JABBER_STATE_CHAT; - } else if(!strcasecmp(show, "xa")) { - state = JABBER_STATE_XA; - } else if(!strcasecmp(show, "dnd")) { - state = JABBER_STATE_DND; - } + state = show_to_state(show); g_free(show); } else { state = 0;
--- a/src/protocols/jabber/presence.h Thu Jan 29 17:39:32 2004 +0000 +++ b/src/protocols/jabber/presence.h Fri Jan 30 21:56:31 2004 +0000 @@ -37,5 +37,6 @@ void jabber_presence_parse(JabberStream *js, xmlnode *packet); void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type); +void jabber_presence_fake_to_self(JabberStream *js, const char *show, const char *status); #endif /* _GAIM_JABBER_PRESENCE_H_ */
--- a/src/protocols/jabber/roster.c Thu Jan 29 17:39:32 2004 +0000 +++ b/src/protocols/jabber/roster.c Fri Jan 30 21:56:31 2004 +0000 @@ -176,9 +176,6 @@ jb->subscription &= ~JABBER_SUB_PENDING; if(jb->subscription == JABBER_SUB_NONE) { - jb = jabber_buddy_find(js, jid, FALSE); - if(jb) - jb->subscription = JABBER_SUB_NONE; remove_gaim_buddies(js, jid); } else { GSList *groups = NULL; @@ -191,6 +188,14 @@ groups = g_slist_append(groups, group_name); } add_gaim_buddies_in_groups(js, jid, name, groups); + + if(jb->subscription == JABBER_SUB_BOTH) { + char *my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); + if(!strcmp(jid, my_bare_jid)) { + jabber_presence_fake_to_self(js, js->gc->away_state, js->gc->away); + } + g_free(my_bare_jid); + } } }