im.pidgin.pidgin: 20236f54c97e87512b7eb716559a4bd86b73f833

bartosz at pidgin.im bartosz at pidgin.im
Sun Nov 4 17:21:03 EST 2007


-----------------------------------------------------------------
Revision: 20236f54c97e87512b7eb716559a4bd86b73f833
Ancestor: a9f75de97d6cdf8fe8bf091b95def6c648aac82f
Author: bartosz at pidgin.im
Date: 2007-11-04T22:17:45
Branch: im.pidgin.pidgin

Modified files:
        libpurple/protocols/gg/gg-utils.c
        libpurple/protocols/gg/gg-utils.h
        libpurple/protocols/gg/gg.c

ChangeLog: 

gg: Properly display your status in the buddylist.

-------------- next part --------------
============================================================
--- libpurple/protocols/gg/gg-utils.c	7ab798894625007c07c203a8e6bc3f47c3373fd6
+++ libpurple/protocols/gg/gg-utils.c	eb707940da9b935f2d757dbf03bf4c5f049464d6
@@ -112,5 +112,36 @@ char *ggp_buddy_get_name(PurpleConnectio
 }
 /* }}} */
 
+void ggp_status_fake_to_self(PurpleAccount *account)
+{
+	PurplePresence *presence;
+	PurpleStatus *status;
+	const char *status_id;
+	const char *msg;
 
+	if (! purple_find_buddy(account, purple_account_get_username(account)))
+		return;
+
+	presence = purple_account_get_presence(account);
+	status = purple_presence_get_active_status(presence);
+	msg = purple_status_get_attr_string(status, "message");
+	if (msg && !*msg)
+		msg = NULL;
+
+	status_id = purple_status_get_id(status);
+	if (strcmp(status_id, "invisible") == 0) {
+		status_id = "offline";
+	}
+
+	if (msg) {
+		if (strlen(msg) > GG_STATUS_DESCR_MAXSIZE) {
+			msg = purple_markup_slice(msg, 0, GG_STATUS_DESCR_MAXSIZE);
+		}
+	}
+	purple_prpl_got_user_status(account, purple_account_get_username(account),
+				    status_id,
+				    msg ? "message" : NULL, msg, NULL);
+}
+
+
 /* vim: set ts=8 sts=0 sw=8 noet: */
============================================================
--- libpurple/protocols/gg/gg-utils.h	2f61c7713d5f7a53bdd91894800b080154b859c6
+++ libpurple/protocols/gg/gg-utils.h	3c97606755256a643037fcd3f075f9819622b0df
@@ -92,6 +92,15 @@ ggp_buddy_get_name(PurpleConnection *gc,
 char *
 ggp_buddy_get_name(PurpleConnection *gc, const uin_t uin);
 
+/**
+ * Manages the display of account's status in the buddylist.
+ *
+ * @param account Current account.
+ */
+void
+ggp_status_fake_to_self(PurpleAccount *account);
+
+
 #endif /* _PURPLE_GG_UTILS_H */
 
 /* vim: set ts=8 sts=0 sw=8 noet: */
============================================================
--- libpurple/protocols/gg/gg.c	abbb6ef98a8f364cf55e326c73f4259b4a36f9d5
+++ libpurple/protocols/gg/gg.c	9dc97c0bc9c1f6db5b09f6eb2346fc46cb58e3e2
@@ -828,6 +828,7 @@ static void ggp_callback_add_to_chat_ok(
 {
 	GGPInfo *info = gc->proto_data;
 	PurpleRequestField *field;
+	/* TODO: sel may be null. */
 	GList *sel;
 
 	field = purple_request_fields_get_field(fields, "name");
@@ -1868,15 +1869,24 @@ static void ggp_set_status(PurpleAccount
 		gg_change_status_descr(info->session, new_status_descr, new_msg);
 		g_free(new_msg);
 	}
+
+	ggp_status_fake_to_self(account);
+
 }
 /* }}} */
 
 /* static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) {{{ */
 static void ggp_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
 {
+	PurpleAccount *account;
 	GGPInfo *info = gc->proto_data;
 
 	gg_add_notify(info->session, ggp_str_to_uin(buddy->name));
+
+	account = purple_connection_get_account(gc);
+	if (strcmp(purple_account_get_username(account), buddy->name) == 0) {
+		ggp_status_fake_to_self(account);
+	}
 }
 /* }}} */
 


More information about the Commits mailing list