Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet. soc.2007.xmpp

Fri, 15 Jun 2007 07:44:05 +0000

author
Andreas Monitzer <am@adiumx.com>
date
Fri, 15 Jun 2007 07:44:05 +0000
branch
soc.2007.xmpp
changeset 17784
6aab6554431e
parent 17783
2687df1ca202
child 17785
213644eb049c

Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.

libpurple/protocols/jabber/usermood.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/usermood.h file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/jabber/usermood.c	Fri Jun 15 07:13:41 2007 +0000
+++ b/libpurple/protocols/jabber/usermood.c	Fri Jun 15 07:44:05 2007 +0000
@@ -24,6 +24,7 @@
 #include <assert.h>
 #include <string.h>
 #include "internal.h"
+#include "request.h"
 
 static char *moodstrings[] = {
 	"afraid",
@@ -134,7 +135,6 @@
 }
 
 static gboolean is_mood_supported(JabberStream *js, const gchar *shortname, const gchar *namespace) {
-	purple_debug_info("jabber", "is_mood_supported: have pep: %s\n", js->pep?"YES":"NO");
 	return js->pep;
 }
 
@@ -143,7 +143,46 @@
 	jabber_pep_register_handler("moodn", "http://jabber.org/protocol/mood", jabber_mood_cb);
 }
 
+static void do_mood_set_from_fields(PurpleConnection *gc, PurpleRequestFields *fields) {
+	JabberStream *js = gc->proto_data;
+	
+	jabber_mood_set(js, moodstrings[purple_request_fields_get_choice(fields, "mood")], purple_request_fields_get_string(fields, "text"));
+}
+
 static void do_mood_set_mood(PurplePluginAction *action) {
+	PurpleConnection *gc = (PurpleConnection *) action->context;
+
+	PurpleRequestFields *fields;
+	PurpleRequestFieldGroup *group;
+	PurpleRequestField *field;
+	int i;
+
+	fields = purple_request_fields_new();
+	group = purple_request_field_group_new(NULL);
+	purple_request_fields_add_group(fields, group);
+
+	field = purple_request_field_choice_new("mood",
+											_("Mood"), 0);
+	
+	for(i = 0; moodstrings[i]; ++i)
+		purple_request_field_choice_add(field, _(moodstrings[i]));
+	
+	purple_request_field_set_required(field, TRUE);
+	purple_request_field_group_add_field(group, field);
+
+	field = purple_request_field_string_new("text",
+											_("Description"), NULL,
+											FALSE);
+	purple_request_field_group_add_field(group, field);
+	
+	purple_request_fields(gc, _("Edit User Mood"),
+						  _("Edit User Mood"),
+						  _("Please select your mood from the list."),
+						  fields,
+						  _("Set"), G_CALLBACK(do_mood_set_from_fields),
+						  _("Cancel"), NULL,
+						  purple_connection_get_account(gc), NULL, NULL,
+						  gc);
 	
 }
 
@@ -152,7 +191,7 @@
 	*m = g_list_append(*m, act);
 }
 
-void jabber_set_mood(JabberStream *js, const char *mood, const char *text) {
+void jabber_mood_set(JabberStream *js, const char *mood, const char *text) {
 	xmlnode *publish, *moodnode;
 	
 	assert(mood != NULL);
--- a/libpurple/protocols/jabber/usermood.h	Fri Jun 15 07:13:41 2007 +0000
+++ b/libpurple/protocols/jabber/usermood.h	Fri Jun 15 07:44:05 2007 +0000
@@ -30,7 +30,7 @@
 
 void jabber_mood_init_action(GList **m);
 
-void jabber_set_mood(JabberStream *js,
+void jabber_mood_set(JabberStream *js,
 		     const char *mood, /* must be one of the valid strings defined in the XEP */
 		     const char *text /* might be NULL */);
 

mercurial