pidgin: 6b33e46b: Enable setting mood message with the glo...

malu at pidgin.im malu at pidgin.im
Thu Mar 4 18:05:36 EST 2010


-----------------------------------------------------------------
Revision: 6b33e46bc695fc04e8485597a95b6719c2fe4df4
Ancestor: 83d86f6bc540c71ddbea143ee7608d63ffccc3d1
Author: malu at pidgin.im
Date: 2010-03-04T23:02:56
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6b33e46bc695fc04e8485597a95b6719c2fe4df4

Modified files:
        libpurple/protocols/jabber/presence.c pidgin/gtkblist.c

ChangeLog: 

Enable setting mood message with the global mood selection UI, when the
connection supports it.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/presence.c	22452d5137a711a1b5092cd846b940b501120007
+++ libpurple/protocols/jabber/presence.c	58772e6c83182396c0b7a261d04041cc25686e76
@@ -137,7 +137,9 @@ void jabber_set_status(PurpleAccount *ac
 	if (purple_status_type_get_primitive(purple_status_get_type(status)) == PURPLE_STATUS_MOOD) {
 		const char *mood =
 			purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
-		jabber_mood_set(js, mood, NULL);
+		const char *mood_text =
+			purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT);
+		jabber_mood_set(js, mood, mood_text);
 		return;
 	}
 
============================================================
--- pidgin/gtkblist.c	d1add4c3d4bbbc4fe806b6a1f7d894015a48b8c1
+++ pidgin/gtkblist.c	8e325b1e83c95a5b46c11f1aecf21ae4589f05f6
@@ -7818,20 +7818,29 @@ edit_mood_cb(PurpleConnection *gc, Purpl
 static void
 edit_mood_cb(PurpleConnection *gc, PurpleRequestFields *fields)
 {
-	PurpleRequestField *f;
+	PurpleRequestField *mood_field, *text_field;
 	GList *l;
 
-	f = purple_request_fields_get_field(fields, "mood");
-	l = purple_request_field_list_get_selected(f);
+	mood_field = purple_request_fields_get_field(fields, "mood");
+	text_field = purple_request_fields_get_field(fields, "text");
+	l = purple_request_field_list_get_selected(mood_field);
 
 	if (l) {
-		const char *mood = purple_request_field_list_get_data(f, l->data);
+		const char *mood = purple_request_field_list_get_data(mood_field, l->data);
+		const char *text = purple_request_field_string_get_value(text_field);
 		PurpleAccount *account = purple_connection_get_account(gc);
 
 		if (mood != NULL && !purple_strequal(mood, "")) {
-			purple_account_set_status(account, "mood", TRUE,
-			                          PURPLE_MOOD_NAME, mood,
-			                          NULL);
+			if (text) {
+				purple_account_set_status(account, "mood", TRUE,
+			                          	PURPLE_MOOD_NAME, mood,
+				    				  	PURPLE_MOOD_COMMENT, text,
+			                          	NULL);
+			} else {
+				purple_account_set_status(account, "mood", TRUE,
+			                          	PURPLE_MOOD_NAME, mood,
+			                          	NULL);
+			}
 		} else {
 			purple_account_set_status(account, "mood", FALSE, NULL);
 		}
@@ -7884,6 +7893,15 @@ set_mood_cb(GtkWidget *widget, PurpleAcc
 
 	purple_request_fields_add_group(fields, g);
 
+	/* if the connection allows setting a mood message */
+	if (gc->flags & PURPLE_CONNECTION_SUPPORT_MOOD_MESSAGES) {
+		g = purple_request_field_group_new(NULL);
+		f = purple_request_field_string_new("text",
+		    _("Message (optional)"), NULL, FALSE);
+		purple_request_field_group_add_field(g, f);
+		purple_request_fields_add_group(fields, g);
+	}
+
 	purple_request_fields(gc, _("Edit User Mood"), _("Edit User Mood"),
                               NULL, fields,
                               _("OK"), G_CALLBACK(edit_mood_cb),


More information about the Commits mailing list