pidgin: f1d7f3b7: Allow unsetting mood in mood selector, w...

malu at pidgin.im malu at pidgin.im
Thu Feb 25 17:50:45 EST 2010


-----------------------------------------------------------------
Revision: f1d7f3b74c2997f762afd2462863cb722a46379e
Ancestor: 6ae2ee7ca04528e4eb11713c825f26abf8a24680
Author: malu at pidgin.im
Date: 2010-02-25T22:47:28
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f1d7f3b74c2997f762afd2462863cb722a46379e

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

ChangeLog: 

Allow unsetting mood in mood selector, works with XMPP... Oscar is not yet
updated, so it might break there...

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/usermood.c	f50cf8289310fa378b227b6e1132e096d16f549f
+++ libpurple/protocols/jabber/usermood.c	4317c37d99c76294fe16ecdedf98355ff32fa504
@@ -239,13 +239,14 @@ void jabber_mood_set(JabberStream *js, c
 void jabber_mood_set(JabberStream *js, const char *mood, const char *text) {
 	xmlnode *publish, *moodnode;
 
-	g_return_if_fail(mood != NULL);
-
 	publish = xmlnode_new("publish");
 	xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/mood");
 	moodnode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "mood");
 	xmlnode_set_namespace(moodnode, "http://jabber.org/protocol/mood");
-	xmlnode_new_child(moodnode, mood);
+	if (mood) {
+		/* if mood is NULL, set an empty mood node, meaning: unset mood */
+	    xmlnode_new_child(moodnode, mood);
+	}
 
 	if (text && text[0] != '\0') {
 		xmlnode *textnode = xmlnode_new_child(moodnode, "text");
============================================================
--- pidgin/gtkblist.c	75e12a867528816bbea127ed66339a66fefee05b
+++ pidgin/gtkblist.c	d6255e32318fdbd82bc2caac538d104e644b9efd
@@ -7828,7 +7828,7 @@ edit_mood_cb(PurpleConnection *gc, Purpl
 		const char *mood = purple_request_field_list_get_data(f, l->data);
 		PurpleAccount *account = purple_connection_get_account(gc);
 
-		if (mood != NULL) {
+		if (mood != NULL && !purple_strequal(mood, "")) {
 			purple_account_set_status(account, "mood", TRUE,
 			                          PURPLE_MOOD_NAME, mood,
 			                          NULL);
@@ -7851,7 +7851,7 @@ set_mood_cb(GtkWidget *widget, PurpleAcc
 	PurpleConnection *gc = purple_account_get_connection(account);
 	PurplePluginProtocolInfo *prpl_info;
 	PurpleMood *mood;
-
+	
 	g_return_if_fail(gc->prpl != NULL);
 	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
 
@@ -7869,6 +7869,11 @@ set_mood_cb(GtkWidget *widget, PurpleAcc
 
 	g_free(na_fn);
 
+	/* first item is an empty one for unsetting the mood */
+	purple_request_field_list_add(f, "", "");
+	if (purple_strequal(current_mood, ""))
+		purple_request_field_list_add_selected(f, "");
+	
 	/* TODO: rlaager wants this sorted. */
 	for (mood = prpl_info->get_moods(account);
 	     mood->mood != NULL ; mood++) {


More information about the Commits mailing list