diff libpurple/protocols/jabber/usermood.h @ 32777:3b1070cb4f29

jabber: Validate user moods, and make the /mood cmd behave flexibly. A user in Pidgin running "/mood ?" or "/mood -" would result in invalid XML being sent to the server (similar to #14342, except '<-/>' or '<?/>'). Prevent this by ensuring the user is specifying something from the list. The /mood command will also now try to treat its entire arguments as a single string, and set that as the mood -- I figure this is what a user would expect?
author Paul Aurich <paul@darkrain42.org>
date Wed, 23 May 2012 05:01:14 +0000
parents 5e7ff3ed7ad0
children
line wrap: on
line diff
--- a/libpurple/protocols/jabber/usermood.h	Wed May 23 03:25:01 2012 +0000
+++ b/libpurple/protocols/jabber/usermood.h	Wed May 23 05:01:14 2012 +0000
@@ -30,9 +30,20 @@
 
 void jabber_mood_init(void);
 
-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 */);
+/**
+ * Sets / unsets the mood for the specified account.  The mood passed in
+ * must either be NULL, "", or one of the moods returned by
+ * jabber_get_moods().
+ *
+ * @param js The JabberStream object.
+ * @param mood The mood to set, NULL, or ""
+ * @param text Optional text that goes along with a mood.  Only used when
+ *             setting a mood (not when unsetting a mood).
+ *
+ * @return FALSE if an invalid mood was specified, or TRUE otherwise.
+ */
+gboolean
+jabber_mood_set(JabberStream *js, const char *mood, const char *text);
 
 PurpleMood *jabber_get_moods(PurpleAccount *account);