pidgin: 9ac89b58: Extract converting a PurpleStatus to GG'...

resiak at pidgin.im resiak at pidgin.im
Thu May 29 08:31:26 EDT 2008


-----------------------------------------------------------------
Revision: 9ac89b58d826a67b07338eebd23f62cb561c05ab
Ancestor: 533516d96c5dacb5c6f0952c20047c34554570bf
Author: resiak at pidgin.im
Date: 2008-05-29T12:15:41
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/9ac89b58d826a67b07338eebd23f62cb561c05ab

Modified files:
        libpurple/protocols/gg/gg.c

ChangeLog: 

Extract converting a PurpleStatus to GG's format to its own function.
A modified version of part of a patch by Adam "OnO" Strzelecki;
references #5693.

-------------- next part --------------
============================================================
--- libpurple/protocols/gg/gg.c	df06ed813eddedeb59796e24c24a2013cf4c58ed
+++ libpurple/protocols/gg/gg.c	dcd4c66c47275ae06b670fb1b2dfa284814c9733
@@ -1827,22 +1827,15 @@ static void ggp_get_info(PurpleConnectio
 /* }}} */
 
 /* static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) {{{ */
-static void ggp_set_status(PurpleAccount *account, PurpleStatus *status)
+static int ggp_to_gg_status(PurpleStatus *status, char **msg)
 {
-	PurpleConnection *gc;
-	GGPInfo *info;
-	const char *status_id, *msg;
+	const char *status_id = purple_status_get_id(status);
 	int new_status, new_status_descr;
+	const char *new_msg;
 
-	if (!purple_status_is_active(status))
-		return;
+	g_return_val_if_fail(msg == NULL, 0);
 
-	gc = purple_account_get_connection(account);
-	info = gc->proto_data;
-
-	status_id = purple_status_get_id(status);
-
-	purple_debug_info("gg", "ggp_set_status: Requested status = %s\n",
+	purple_debug_info("gg", "ggp_to_gg_status: Requested status = %s\n",
 			status_id);
 
 	if (strcmp(status_id, "available") == 0) {
@@ -1861,22 +1854,45 @@ static void ggp_set_status(PurpleAccount
 		new_status = GG_STATUS_AVAIL;
 		new_status_descr = GG_STATUS_AVAIL_DESCR;
 		purple_debug_info("gg",
-			"ggp_set_status: uknown status requested (status_id=%s)\n",
+			"ggp_set_status: unknown status requested (status_id=%s)\n",
 			status_id);
 	}
 
-	msg = purple_status_get_attr_string(status, "message");
+	new_msg = purple_status_get_attr_string(status, "message");
 
-	if (msg == NULL) {
-		gg_change_status(info->session, new_status);
+	if(new_msg) {
+		char *tmp = purple_markup_strip_html(new_msg);
+		*msg = charset_convert(tmp, "UTF-8", "CP1250");
+		g_free(tmp);
+
+		return new_status_descr;
 	} else {
-		gchar *tmp, *new_msg;
+		*msg = NULL;
+		return new_status;
+	}
+}
+/* }}} */
 
-		tmp = charset_convert(msg, "UTF-8", "CP1250");
-		new_msg = purple_markup_strip_html(tmp);
-		g_free(tmp);
+/* static void ggp_set_status(PurpleAccount *account, PurpleStatus *status) {{{ */
+static void ggp_set_status(PurpleAccount *account, PurpleStatus *status)
+{
+	PurpleConnection *gc;
+	GGPInfo *info;
+	int new_status;
+	char *new_msg = NULL;
 
-		gg_change_status_descr(info->session, new_status_descr, new_msg);
+	if (!purple_status_is_active(status))
+		return;
+
+	gc = purple_account_get_connection(account);
+	info = gc->proto_data;
+
+	new_status = ggp_to_gg_status(status, &new_msg);
+
+	if (new_msg == NULL) {
+		gg_change_status(info->session, new_status);
+	} else {
+		gg_change_status_descr(info->session, new_status, new_msg);
 		g_free(new_msg);
 	}
 


More information about the Commits mailing list