changeset 8193:e0a70b763872

[gaim-migrate @ 8915] ok, this should all work now committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sat, 31 Jan 2004 22:30:29 +0000
parents 36f8dcea9648
children 22b3974dc1af
files src/protocols/jabber/jabber.c src/protocols/jabber/presence.c src/protocols/jabber/presence.h
diffstat 3 files changed, 30 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/jabber/jabber.c	Sat Jan 31 20:33:05 2004 +0000
+++ b/src/protocols/jabber/jabber.c	Sat Jan 31 22:30:29 2004 +0000
@@ -877,7 +877,7 @@
 				*se = "extendedaway";
 				break;
 			case JABBER_STATE_DND:
-				*se = "extendedaway";
+				*se = "dnd";
 				break;
 			case JABBER_STATE_ERROR:
 				*se = "error";
--- a/src/protocols/jabber/presence.c	Sat Jan 31 20:33:05 2004 +0000
+++ b/src/protocols/jabber/presence.c	Sat Jan 31 22:30:29 2004 +0000
@@ -45,28 +45,25 @@
 	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) {
+void jabber_presence_fake_to_self(JabberStream *js, const char *away_state, const char *msg) {
 	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);
+			int state = 0;
+			if(away_state) {
+				if(!strcmp(away_state, _("Away")) ||
+						(msg && *msg && !strcmp(away_state, GAIM_AWAY_CUSTOM)))
+					state = JABBER_STATE_AWAY;
+				else if(!strcmp(away_state, _("Chatty")))
+					state = JABBER_STATE_CHAT;
+				else if(!strcmp(away_state, _("Extended Away")))
+					state = JABBER_STATE_XA;
+				else if(!strcmp(away_state, _("Do Not Disturb")))
+					state = JABBER_STATE_DND;
+			}
+			jabber_buddy_track_resource(jb, js->user->resource, 0, state, (msg && *msg) ? msg : NULL);
 			if((jbr = jabber_buddy_find_resource(jb, NULL)))
 				serv_got_update(js->gc, my_base_jid, 1, 0, 0, 0, jbr->state);
 		}
@@ -167,6 +164,20 @@
 	g_free(jap);
 }
 
+static int show_to_state(const char *show) {
+	if(!show)
+		return 0;
+	else if(!strcmp(show, "away"))
+		return JABBER_STATE_AWAY;
+	else if(!strcmp(show, "chat"))
+		return JABBER_STATE_CHAT;
+	else if(!strcmp(show, "xa"))
+		return JABBER_STATE_XA;
+	else if(!strcmp(show, "dnd"))
+		return JABBER_STATE_DND;
+	return 0;
+}
+
 void jabber_presence_parse(JabberStream *js, xmlnode *packet)
 {
 	const char *from = xmlnode_get_attrib(packet, "from");
--- a/src/protocols/jabber/presence.h	Sat Jan 31 20:33:05 2004 +0000
+++ b/src/protocols/jabber/presence.h	Sat Jan 31 22:30:29 2004 +0000
@@ -37,6 +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);
+void jabber_presence_fake_to_self(JabberStream *js, const char *away_state, const char *msg);
 
 #endif /* _GAIM_JABBER_PRESENCE_H_ */