diff options
Diffstat (limited to 'libpurple/protocols')
-rw-r--r-- | libpurple/protocols/jabber/disco.c | 5 | ||||
-rw-r--r-- | libpurple/protocols/jabber/jabber.c | 102 | ||||
-rw-r--r-- | libpurple/protocols/jabber/meson.build | 2 | ||||
-rw-r--r-- | libpurple/protocols/jabber/pep.c | 2 | ||||
-rw-r--r-- | libpurple/protocols/jabber/presence.c | 11 | ||||
-rw-r--r-- | libpurple/protocols/jabber/tests/test_jabber_caps.c | 4 | ||||
-rw-r--r-- | libpurple/protocols/jabber/usermood.c | 226 | ||||
-rw-r--r-- | libpurple/protocols/jabber/usermood.h | 50 |
8 files changed, 3 insertions, 399 deletions
diff --git a/libpurple/protocols/jabber/disco.c b/libpurple/protocols/jabber/disco.c index e722186062..dbeffcb02d 100644 --- a/libpurple/protocols/jabber/disco.c +++ b/libpurple/protocols/jabber/disco.c @@ -413,12 +413,7 @@ jabber_disco_server_info_result_cb(JabberStream *js, const char *from, category = purple_xmlnode_get_attrib(child, "category"); type = purple_xmlnode_get_attrib(child, "type"); if(purple_strequal(category, "pubsub") && purple_strequal(type, "pep")) { - PurpleConnection *gc = js->gc; js->pep = TRUE; - purple_connection_set_flags(gc, - purple_connection_get_flags(gc) - | PURPLE_CONNECTION_FLAG_SUPPORT_MOODS - | PURPLE_CONNECTION_FLAG_SUPPORT_MOOD_MESSAGES); } if (!purple_strequal(category, "server")) continue; diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c index 7e25c33243..1b5d016901 100644 --- a/libpurple/protocols/jabber/jabber.c +++ b/libpurple/protocols/jabber/jabber.c @@ -49,7 +49,6 @@ #include "oob.h" #include "ping.h" #include "si.h" -#include "usermood.h" #include "xdata.h" #include "pep.h" #include "adhoccommands.h" @@ -1560,7 +1559,7 @@ jabber_tooltip_add_resource_text(JabberBuddyResource *jbr, } static void -jabber_tooltip_text(PurpleProtocolClient *client, PurpleBuddy *b, +jabber_tooltip_text(G_GNUC_UNUSED PurpleProtocolClient *client, PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { JabberBuddy *jb; @@ -1586,7 +1585,6 @@ jabber_tooltip_text(PurpleProtocolClient *client, PurpleBuddy *b, PurplePresence *presence = purple_buddy_get_presence(b); const char *sub; GList *l; - const char *mood; gboolean multiple_resources = jb->resources && g_list_next(jb->resources); JabberBuddyResource *top_jbr = jabber_buddy_find_resource(jb, NULL); @@ -1607,34 +1605,6 @@ jabber_tooltip_text(PurpleProtocolClient *client, PurpleBuddy *b, } if (full) { - PurpleStatus *status; - - status = purple_presence_get_status(presence, "mood"); - mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME); - if(mood && *mood) { - const char *moodtext; - /* find the mood */ - PurpleMood *moods = jabber_get_moods(client, account); - const char *description = NULL; - - for (; moods->mood ; moods++) { - if (purple_strequal(moods->mood, mood)) { - description = moods->description; - break; - } - } - - moodtext = purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT); - if(moodtext && *moodtext) { - char *moodplustext = - g_strdup_printf("%s (%s)", description ? _(description) : mood, moodtext); - - purple_notify_user_info_add_pair_html(user_info, _("Mood"), moodplustext); - g_free(moodplustext); - } else - purple_notify_user_info_add_pair_html(user_info, _("Mood"), - description ? _(description) : mood); - } if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { PurpleStatus *tune = purple_presence_get_status(presence, "tune"); const char *title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); @@ -1691,21 +1661,11 @@ jabber_status_types(G_GNUC_UNUSED PurpleProtocol *protocol, NULL, TRUE, TRUE, FALSE, "priority", _("Priority"), priority_value, "message", _("Message"), purple_value_new(G_TYPE_STRING), - "mood", _("Mood"), purple_value_new(G_TYPE_STRING), - "moodtext", _("Mood Text"), purple_value_new(G_TYPE_STRING), "nick", _("Nickname"), purple_value_new(G_TYPE_STRING), "buzz", _("Allow Buzz"), buzz_enabled, 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(G_TYPE_STRING), - PURPLE_MOOD_COMMENT, _("Mood Comment"), purple_value_new(G_TYPE_STRING), - NULL); - types = g_list_prepend(types, type); - priority_value = purple_value_new(G_TYPE_INT); g_value_set_int(priority_value, 1); buzz_enabled = purple_value_new(G_TYPE_BOOLEAN); @@ -1715,8 +1675,6 @@ jabber_status_types(G_GNUC_UNUSED PurpleProtocol *protocol, _("Chatty"), TRUE, TRUE, FALSE, "priority", _("Priority"), priority_value, "message", _("Message"), purple_value_new(G_TYPE_STRING), - "mood", _("Mood"), purple_value_new(G_TYPE_STRING), - "moodtext", _("Mood Text"), purple_value_new(G_TYPE_STRING), "nick", _("Nickname"), purple_value_new(G_TYPE_STRING), "buzz", _("Allow Buzz"), buzz_enabled, NULL); @@ -1731,8 +1689,6 @@ jabber_status_types(G_GNUC_UNUSED PurpleProtocol *protocol, NULL, TRUE, TRUE, FALSE, "priority", _("Priority"), priority_value, "message", _("Message"), purple_value_new(G_TYPE_STRING), - "mood", _("Mood"), purple_value_new(G_TYPE_STRING), - "moodtext", _("Mood Text"), purple_value_new(G_TYPE_STRING), "nick", _("Nickname"), purple_value_new(G_TYPE_STRING), "buzz", _("Allow Buzz"), buzz_enabled, NULL); @@ -1747,8 +1703,6 @@ jabber_status_types(G_GNUC_UNUSED PurpleProtocol *protocol, NULL, TRUE, TRUE, FALSE, "priority", _("Priority"), priority_value, "message", _("Message"), purple_value_new(G_TYPE_STRING), - "mood", _("Mood"), purple_value_new(G_TYPE_STRING), - "moodtext", _("Mood Text"), purple_value_new(G_TYPE_STRING), "nick", _("Nickname"), purple_value_new(G_TYPE_STRING), "buzz", _("Allow Buzz"), buzz_enabled, NULL); @@ -1761,8 +1715,6 @@ jabber_status_types(G_GNUC_UNUSED PurpleProtocol *protocol, _("Do Not Disturb"), TRUE, TRUE, FALSE, "priority", _("Priority"), priority_value, "message", _("Message"), purple_value_new(G_TYPE_STRING), - "mood", _("Mood"), purple_value_new(G_TYPE_STRING), - "moodtext", _("Mood Text"), purple_value_new(G_TYPE_STRING), "nick", _("Nickname"), purple_value_new(G_TYPE_STRING), NULL); types = g_list_prepend(types, type); @@ -2875,50 +2827,6 @@ jabber_can_receive_file(G_GNUC_UNUSED PurpleProtocolXfer *prplxfer, } } -static PurpleCmdRet -jabber_cmd_mood(PurpleConversation *conv, G_GNUC_UNUSED const char *cmd, - char **args, G_GNUC_UNUSED char **error, - G_GNUC_UNUSED gpointer data) -{ - PurpleAccount *account = purple_conversation_get_account(conv); - JabberStream *js = purple_connection_get_protocol_data(purple_account_get_connection(account)); - - if (js->pep) { - gboolean ret; - - if (!args || !args[0]) { - /* No arguments; unset mood */ - ret = jabber_mood_set(js, NULL, NULL); - } else { - /* At least one argument. Relying on the list of arguments - * being NULL-terminated. - */ - ret = jabber_mood_set(js, args[0], args[1]); - if (!ret) { - /* Let's try again */ - char *tmp = g_strjoin(" ", args[0], args[1], NULL); - ret = jabber_mood_set(js, "undefined", tmp); - g_free(tmp); - } - } - - if (ret) { - return PURPLE_CMD_RET_OK; - } else { - purple_conversation_write_system_message(conv, - _("Failed to specify mood"), - PURPLE_MESSAGE_ERROR); - return PURPLE_CMD_RET_FAILED; - } - } else { - /* account does not support PEP, can't set a mood */ - purple_conversation_write_system_message(conv, - _("Account does not support PEP, can't set mood"), - PURPLE_MESSAGE_ERROR); - return PURPLE_CMD_RET_FAILED; - } -} - static void jabber_register_commands(PurpleProtocol *protocol) { @@ -3020,13 +2928,6 @@ jabber_register_commands(PurpleProtocol *protocol) _("ping <jid>: Ping a user/component/server."), NULL); commands = g_slist_prepend(commands, GUINT_TO_POINTER(id)); - id = purple_cmd_register("mood", "ws", PURPLE_CMD_P_PROTOCOL, - PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | - PURPLE_CMD_FLAG_PROTOCOL_ONLY | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, - proto_id, jabber_cmd_mood, - _("mood <mood> [text]: Set current user mood"), NULL); - commands = g_slist_prepend(commands, GUINT_TO_POINTER(id)); - g_hash_table_insert(jabber_cmds, protocol, commands); } @@ -3382,7 +3283,6 @@ jabber_protocol_client_iface_init(PurpleProtocolClientInterface *client_iface) client_iface->normalize = jabber_client_normalize; client_iface->find_blist_chat = jabber_find_blist_chat; client_iface->offline_message = jabber_offline_message; - client_iface->get_moods = jabber_get_moods; } static void diff --git a/libpurple/protocols/jabber/meson.build b/libpurple/protocols/jabber/meson.build index f115ee9738..3579f14fc6 100644 --- a/libpurple/protocols/jabber/meson.build +++ b/libpurple/protocols/jabber/meson.build @@ -66,8 +66,6 @@ JABBER_SOURCES = [ 'si.h', 'useravatar.c', 'useravatar.h', - 'usermood.c', - 'usermood.h', 'usernick.c', 'usernick.h', 'usertune.c', diff --git a/libpurple/protocols/jabber/pep.c b/libpurple/protocols/jabber/pep.c index 24b972899a..28fcba2320 100644 --- a/libpurple/protocols/jabber/pep.c +++ b/libpurple/protocols/jabber/pep.c @@ -27,7 +27,6 @@ #include "iq.h" #include <string.h> #include "useravatar.h" -#include "usermood.h" #include "usernick.h" #include "usertune.h" @@ -39,7 +38,6 @@ void jabber_pep_init(void) { /* register PEP handlers */ jabber_avatar_init(); - jabber_mood_init(); jabber_tune_init(); jabber_nick_init(); } diff --git a/libpurple/protocols/jabber/presence.c b/libpurple/protocols/jabber/presence.c index cc75ac5ef1..4baf4f3e16 100644 --- a/libpurple/protocols/jabber/presence.c +++ b/libpurple/protocols/jabber/presence.c @@ -31,7 +31,6 @@ #include "jutil.h" #include "adhoccommands.h" -#include "usermood.h" #include "usertune.h" static GHashTable *presence_handlers = NULL; @@ -169,16 +168,6 @@ jabber_set_status(G_GNUC_UNUSED PurpleProtocolServer *protocol_server, gc = purple_account_get_connection(account); js = purple_connection_get_protocol_data(gc); - /* it's a mood update */ - if (purple_status_type_get_primitive(purple_status_get_status_type(status)) == PURPLE_STATUS_MOOD) { - const char *mood = - purple_status_get_attr_string(status, PURPLE_MOOD_NAME); - const char *mood_text = - purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT); - jabber_mood_set(js, mood, mood_text); - return; - } - jabber_presence_send(js, FALSE); } diff --git a/libpurple/protocols/jabber/tests/test_jabber_caps.c b/libpurple/protocols/jabber/tests/test_jabber_caps.c index c3fc6ceccf..8e07e8463f 100644 --- a/libpurple/protocols/jabber/tests/test_jabber_caps.c +++ b/libpurple/protocols/jabber/tests/test_jabber_caps.c @@ -41,8 +41,8 @@ static void test_jabber_caps_calculate_from_xmlnode(void) { _test_jabber_caps_match( G_CHECKSUM_SHA1, - "<query xmlns='http://jabber.org/protocol/disco#info' node='http://tkabber.jabber.ru/#GNjxthSckUNvAIoCCJFttjl6VL8='><identity category='client' type='pc' name='Tkabber'/><x xmlns='jabber:x:data' type='result'><field var='FORM_TYPE' type='hidden'><value>urn:xmpp:dataforms:softwareinfo</value></field><field var='software'><value>Tkabber</value></field><field var='software_version'><value> ( 8.5.5 )</value></field><field var='os'><value>ATmega640-16AU</value></field><field var='os_version'><value/></field></x><feature var='games:board'/><feature var='http://jabber.org/protocol/activity'/><feature var='http://jabber.org/protocol/bytestreams'/><feature var='http://jabber.org/protocol/chatstates'/><feature var='http://jabber.org/protocol/commands'/><feature var='http://jabber.org/protocol/commands'/><feature var='http://jabber.org/protocol/disco#info'/><feature var='http://jabber.org/protocol/disco#items'/><feature var='http://jabber.org/protocol/feature-neg'/><feature var='http://jabber.org/protocol/geoloc'/><feature var='http://jabber.org/protocol/ibb'/><feature var='http://jabber.org/protocol/iqibb'/><feature var='http://jabber.org/protocol/mood'/><feature var='http://jabber.org/protocol/muc'/><feature var='http://jabber.org/protocol/mute#ancestor'/><feature var='http://jabber.org/protocol/mute#editor'/><feature var='http://jabber.org/protocol/rosterx'/><feature var='http://jabber.org/protocol/si'/><feature var='http://jabber.org/protocol/si/profile/file-transfer'/><feature var='http://jabber.org/protocol/tune'/><feature var='jabber:iq:avatar'/><feature var='jabber:iq:browse'/><feature var='jabber:iq:dtcp'/><feature var='jabber:iq:filexfer'/><feature var='jabber:iq:ibb'/><feature var='jabber:iq:inband'/><feature var='jabber:iq:jidlink'/><feature var='jabber:iq:last'/><feature var='jabber:iq:oob'/><feature var='jabber:iq:privacy'/><feature var='jabber:iq:time'/><feature var='jabber:iq:version'/><feature var='jabber:x:data'/><feature var='jabber:x:event'/><feature var='jabber:x:oob'/><feature var='urn:xmpp:ping'/><feature var='urn:xmpp:receipts'/><feature var='urn:xmpp:time'/></query>", - "3V9tfR8fPykyks72jvg+bkUtQTM=" + "<query xmlns='http://jabber.org/protocol/disco#info' node='http://tkabber.jabber.ru/#GNjxthSckUNvAIoCCJFttjl6VL8='><identity category='client' type='pc' name='Tkabber'/><x xmlns='jabber:x:data' type='result'><field var='FORM_TYPE' type='hidden'><value>urn:xmpp:dataforms:softwareinfo</value></field><field var='software'><value>Tkabber</value></field><field var='software_version'><value> ( 8.5.5 )</value></field><field var='os'><value>ATmega640-16AU</value></field><field var='os_version'><value/></field></x><feature var='games:board'/><feature var='http://jabber.org/protocol/activity'/><feature var='http://jabber.org/protocol/bytestreams'/><feature var='http://jabber.org/protocol/chatstates'/><feature var='http://jabber.org/protocol/commands'/><feature var='http://jabber.org/protocol/commands'/><feature var='http://jabber.org/protocol/disco#info'/><feature var='http://jabber.org/protocol/disco#items'/><feature var='http://jabber.org/protocol/feature-neg'/><feature var='http://jabber.org/protocol/geoloc'/><feature var='http://jabber.org/protocol/ibb'/><feature var='http://jabber.org/protocol/iqibb'/><feature var='http://jabber.org/protocol/muc'/><feature var='http://jabber.org/protocol/mute#ancestor'/><feature var='http://jabber.org/protocol/mute#editor'/><feature var='http://jabber.org/protocol/rosterx'/><feature var='http://jabber.org/protocol/si'/><feature var='http://jabber.org/protocol/si/profile/file-transfer'/><feature var='http://jabber.org/protocol/tune'/><feature var='jabber:iq:avatar'/><feature var='jabber:iq:browse'/><feature var='jabber:iq:dtcp'/><feature var='jabber:iq:filexfer'/><feature var='jabber:iq:ibb'/><feature var='jabber:iq:inband'/><feature var='jabber:iq:jidlink'/><feature var='jabber:iq:last'/><feature var='jabber:iq:oob'/><feature var='jabber:iq:privacy'/><feature var='jabber:iq:time'/><feature var='jabber:iq:version'/><feature var='jabber:x:data'/><feature var='jabber:x:event'/><feature var='jabber:x:oob'/><feature var='urn:xmpp:ping'/><feature var='urn:xmpp:receipts'/><feature var='urn:xmpp:time'/></query>", + "MxSGNsM12KCe/2hYIySOX+CpY9U=" ); } diff --git a/libpurple/protocols/jabber/usermood.c b/libpurple/protocols/jabber/usermood.c deleted file mode 100644 index 10898085a5..0000000000 --- a/libpurple/protocols/jabber/usermood.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * purple - Jabber Protocol Plugin - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ - -#include <glib/gi18n-lib.h> - -#include <purple.h> - -#include "usermood.h" -#include "pep.h" -#include <string.h> - -static PurpleMood moods[] = { - { .mood = "afraid", .description = N_("Afraid"), }, - { .mood = "amazed", .description = N_("Amazed"), }, - { .mood = "amorous", .description = N_("Amorous"), }, - { .mood = "angry", .description = N_("Angry"), }, - { .mood = "annoyed", .description = N_("Annoyed"), }, - { .mood = "anxious", .description = N_("Anxious"), }, - { .mood = "aroused", .description = N_("Aroused"), }, - { .mood = "ashamed", .description = N_("Ashamed"), }, - { .mood = "bored", .description = N_("Bored"), }, - { .mood = "brave", .description = N_("Brave"), }, - { .mood = "calm", .description = N_("Calm"), }, - { .mood = "cautious", .description = N_("Cautious"), }, - { .mood = "cold", .description = N_("Cold"), }, - { .mood = "confident", .description = N_("Confident"), }, - { .mood = "confused", .description = N_("Confused"), }, - { .mood = "contemplative", .description = N_("Contemplative"), }, - { .mood = "contented", .description = N_("Contented"), }, - { .mood = "cranky", .description = N_("Cranky"), }, - { .mood = "crazy", .description = N_("Crazy"), }, - { .mood = "creative", .description = N_("Creative"), }, - { .mood = "curious", .description = N_("Curious"), }, - { .mood = "dejected", .description = N_("Dejected"), }, - { .mood = "depressed", .description = N_("Depressed"), }, - { .mood = "disappointed", .description = N_("Disappointed"), }, - { .mood = "disgusted", .description = N_("Disgusted"), }, - { .mood = "dismayed", .description = N_("Dismayed"), }, - { .mood = "distracted", .description = N_("Distracted"), }, - { .mood = "embarrassed", .description = N_("Embarrassed"), }, - { .mood = "envious", .description = N_("Envious"), }, - { .mood = "excited", .description = N_("Excited"), }, - { .mood = "flirtatious", .description = N_("Flirtatious"), }, - { .mood = "frustrated", .description = N_("Frustrated"), }, - { .mood = "grateful", .description = N_("Grateful"), }, - { .mood = "grieving", .description = N_("Grieving"), }, - { .mood = "grumpy", .description = N_("Grumpy"), }, - { .mood = "guilty", .description = N_("Guilty"), }, - { .mood = "happy", .description = N_("Happy"), }, - { .mood = "hopeful", .description = N_("Hopeful"), }, - { .mood = "hot", .description = N_("Hot"), }, - { .mood = "humbled", .description = N_("Humbled"), }, - { .mood = "humiliated", .description = N_("Humiliated"), }, - { .mood = "hungry", .description = N_("Hungry"), }, - { .mood = "hurt", .description = N_("Hurt"), }, - { .mood = "impressed", .description = N_("Impressed"), }, - { .mood = "in_awe", .description = N_("In awe"), }, - { .mood = "in_love", .description = N_("In love"), }, - { .mood = "indignant", .description = N_("Indignant"), }, - { .mood = "interested", .description = N_("Interested"), }, - { .mood = "intoxicated", .description = N_("Intoxicated"), }, - { .mood = "invincible", .description = N_("Invincible"), }, - { .mood = "jealous", .description = N_("Jealous"), }, - { .mood = "lonely", .description = N_("Lonely"), }, - { .mood = "lost", .description = N_("Lost"), }, - { .mood = "lucky", .description = N_("Lucky"), }, - { .mood = "mean", .description = N_("Mean"), }, - { .mood = "moody", .description = N_("Moody"), }, - { .mood = "nervous", .description = N_("Nervous"), }, - { .mood = "neutral", .description = N_("Neutral"), }, - { .mood = "offended", .description = N_("Offended"), }, - { .mood = "outraged", .description = N_("Outraged"), }, - { .mood = "playful", .description = N_("Playful"), }, - { .mood = "proud", .description = N_("Proud"), }, - { .mood = "relaxed", .description = N_("Relaxed"), }, - { .mood = "relieved", .description = N_("Relieved"), }, - { .mood = "remorseful", .description = N_("Remorseful"), }, - { .mood = "restless", .description = N_("Restless"), }, - { .mood = "sad", .description = N_("Sad"), }, - { .mood = "sarcastic", .description = N_("Sarcastic"), }, - { .mood = "satisfied", .description = N_("Satisfied"), }, - { .mood = "serious", .description = N_("Serious"), }, - { .mood = "shocked", .description = N_("Shocked"), }, - { .mood = "shy", .description = N_("Shy"), }, - { .mood = "sick", .description = N_("Sick"), }, - { .mood = "sleepy", .description = N_("Sleepy"), }, - { .mood = "spontaneous", .description = N_("Spontaneous"), }, - { .mood = "stressed", .description = N_("Stressed"), }, - { .mood = "strong", .description = N_("Strong"), }, - { .mood = "surprised", .description = N_("Surprised"), }, - { .mood = "thankful", .description = N_("Thankful"), }, - { .mood = "thirsty", .description = N_("Thirsty"), }, - { .mood = "tired", .description = N_("Tired"), }, - { .mood = "undefined", .description = N_("Undefined"), }, - { .mood = "weak", .description = N_("Weak"), }, - { .mood = "worried", .description = N_("Worried"), }, - /* Mark last record. */ - { .mood = NULL, .description = NULL, } -}; - -static const PurpleMood* -find_mood_by_name(const gchar *name) -{ - int i; - - g_return_val_if_fail(name && *name, NULL); - - for (i = 0; moods[i].mood != NULL; ++i) { - if (purple_strequal(name, moods[i].mood)) { - return &moods[i]; - } - } - - return NULL; -} - -static void jabber_mood_cb(JabberStream *js, const char *from, PurpleXmlNode *items) { - /* it doesn't make sense to have more than one item here, so let's just pick the first one */ - PurpleXmlNode *item = purple_xmlnode_get_child(items, "item"); - const char *newmood = NULL; - char *moodtext = NULL; - JabberBuddy *buddy = jabber_buddy_find(js, from, FALSE); - PurpleXmlNode *moodinfo, *mood; - /* ignore the mood of people not on our buddy list */ - if (!buddy || !item) - return; - - mood = purple_xmlnode_get_child_with_namespace(item, "mood", "http://jabber.org/protocol/mood"); - if (!mood) - return; - for (moodinfo = mood->child; moodinfo; moodinfo = moodinfo->next) { - if (moodinfo->type == PURPLE_XMLNODE_TYPE_TAG) { - if (purple_strequal(moodinfo->name, "text")) { - if (!moodtext) /* only pick the first one */ - moodtext = purple_xmlnode_get_data(moodinfo); - } else { - const PurpleMood *target_mood; - - /* verify that the mood is known (valid) */ - target_mood = find_mood_by_name(moodinfo->name); - newmood = target_mood ? target_mood->mood : NULL; - } - - } - if (newmood != NULL && moodtext != NULL) - break; - } - if (newmood != NULL) { - purple_protocol_got_user_status(purple_connection_get_account(js->gc), from, "mood", - PURPLE_MOOD_NAME, newmood, - PURPLE_MOOD_COMMENT, moodtext, - NULL); - } else { - purple_protocol_got_user_status_deactive(purple_connection_get_account(js->gc), from, "mood"); - } - g_free(moodtext); -} - -void jabber_mood_init(void) { - jabber_add_feature("http://jabber.org/protocol/mood", jabber_pep_namespace_only_when_pep_enabled_cb); - jabber_pep_register_handler("http://jabber.org/protocol/mood", jabber_mood_cb); -} - -gboolean -jabber_mood_set(JabberStream *js, const char *mood, const char *text) -{ - const PurpleMood *target_mood = NULL; - PurpleXmlNode *publish, *moodnode; - - if (mood && *mood) { - target_mood = find_mood_by_name(mood); - /* Mood specified, but is invalid -- - * fail so that the command can handle this. - */ - if (!target_mood) - return FALSE; - } - - publish = purple_xmlnode_new("publish"); - purple_xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/mood"); - moodnode = purple_xmlnode_new_child(purple_xmlnode_new_child(publish, "item"), "mood"); - purple_xmlnode_set_namespace(moodnode, "http://jabber.org/protocol/mood"); - - if (target_mood) { - /* If target_mood is not NULL, then - * target_mood->mood == mood, and is a valid element name. - */ - purple_xmlnode_new_child(moodnode, mood); - - /* Only set text when setting a mood */ - if (text && *text) { - PurpleXmlNode *textnode = purple_xmlnode_new_child(moodnode, "text"); - purple_xmlnode_insert_data(textnode, text, -1); - } - } - - jabber_pep_publish(js, publish); - return TRUE; -} - -PurpleMood * -jabber_get_moods(G_GNUC_UNUSED PurpleProtocolClient *client, - G_GNUC_UNUSED PurpleAccount *account) -{ - return moods; -} diff --git a/libpurple/protocols/jabber/usermood.h b/libpurple/protocols/jabber/usermood.h deleted file mode 100644 index a92f49c0be..0000000000 --- a/libpurple/protocols/jabber/usermood.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * purple - Jabber Protocol Plugin - * - * Purple is the legal property of its developers, whose names are too numerous - * to list here. Please refer to the COPYRIGHT file distributed with this - * source distribution. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA - * - */ - -#ifndef PURPLE_JABBER_USERMOOD_H -#define PURPLE_JABBER_USERMOOD_H - -#include "jabber.h" - -/* Implementation of XEP-0107 */ - -void jabber_mood_init(void); - -/** - * 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(PurpleProtocolClient *client, PurpleAccount *account); - -#endif /* PURPLE_JABBER_USERMOOD_H */ |