changeset 29463:f3654983e1da

Implemented the get_moods prpl function for XMPP. Enables the generic mood chooser. Doesn't actually work yet...
author Marcus Lundblad <ml@update.uu.se>
date Mon, 08 Feb 2010 21:38:26 +0000
parents 22938670285d
children 2cccb8588c12
files libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/libxmpp.c libpurple/protocols/jabber/usermood.c libpurple/protocols/jabber/usermood.h
diffstat 4 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jabber.c	Sun Feb 07 22:53:36 2010 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Mon Feb 08 21:38:26 2010 +0000
@@ -2132,6 +2132,14 @@
 			NULL);
 	types = g_list_prepend(types, type);
 
+	
+	type = purple_status_type_new_with_attrs(PURPLE_STATUS_MOOD,
+	    "mood", NULL, TRUE, TRUE, TRUE,
+			PURPLE_MOOD_NAME, _("Mood Name"), purple_value_new(PURPLE_TYPE_STRING),
+			PURPLE_MOOD_COMMENT, _("Mood Comment"), purple_value_new(PURPLE_TYPE_STRING),
+			NULL);
+	types = g_list_prepend(types, type);
+
 	priority_value = purple_value_new(PURPLE_TYPE_INT);
 	purple_value_set_int(priority_value, 1);
 	buzz_enabled = purple_value_new(PURPLE_TYPE_BOOLEAN);
--- a/libpurple/protocols/jabber/libxmpp.c	Sun Feb 07 22:53:36 2010 +0000
+++ b/libpurple/protocols/jabber/libxmpp.c	Mon Feb 08 21:38:26 2010 +0000
@@ -43,6 +43,7 @@
 #include "presence.h"
 #include "google.h"
 #include "pep.h"
+#include "usermood.h"
 #include "usertune.h"
 #include "caps.h"
 #include "data.h"
@@ -126,7 +127,7 @@
 	NULL, /* get_account_text_table */
 	jabber_initiate_media,          /* initiate_media */
 	jabber_get_media_caps,                  /* get_media_caps */
-	NULL  							/* get_moods */
+	jabber_get_moods  							/* get_moods */
 };
 
 static gboolean load_plugin(PurplePlugin *plugin)
--- a/libpurple/protocols/jabber/usermood.c	Sun Feb 07 22:53:36 2010 +0000
+++ b/libpurple/protocols/jabber/usermood.c	Mon Feb 08 21:38:26 2010 +0000
@@ -119,6 +119,10 @@
 	{NULL, NULL, NULL}
 };
 
+static PurpleMood empty_moods[] = {
+	{NULL, NULL, NULL}
+};
+
 static void jabber_mood_cb(JabberStream *js, const char *from, xmlnode *items) {
 	/* it doesn't make sense to have more than one item here, so let's just pick the first one */
 	xmlnode *item = xmlnode_get_child(items, "item");
@@ -252,3 +256,17 @@
 	/* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free
 	   (yay for well-defined memory management rules) */
 }
+
+PurpleMood *jabber_get_moods(PurpleAccount *account)
+{
+	PurpleConnection *gc = purple_account_get_connection(account);
+	JabberStream *js = (JabberStream *) gc->proto_data;
+
+	if (js->pep) {
+		purple_debug_info("jabber", "get_moods: account supports PEP\n");
+		return moods;
+	} else {
+		purple_debug_info("jabber", "get_moods: account doesn't support PEP\n");
+		return empty_moods;
+	}
+}
\ No newline at end of file
--- a/libpurple/protocols/jabber/usermood.h	Sun Feb 07 22:53:36 2010 +0000
+++ b/libpurple/protocols/jabber/usermood.h	Mon Feb 08 21:38:26 2010 +0000
@@ -36,4 +36,6 @@
 		     const char *mood, /* must be one of the valid strings defined in the XEP */
 		     const char *text /* might be NULL */);
 
+PurpleMood *jabber_get_moods(PurpleAccount *account);
+
 #endif /* PURPLE_JABBER_USERMOOD_H_ */