libpurple/protocols/jabber/usermood.c

Tue, 09 Mar 2010 19:09:37 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Tue, 09 Mar 2010 19:09:37 +0000
changeset 29845
5684cbe452f7
parent 29825
c1309b5a16a5
child 31935
77896a9a09c2
permissions
-rw-r--r--

jabber: And fix up the commands now to be per-plugin

17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
1 /*
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
2 * purple - Jabber Protocol Plugin
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
3 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
6 * source distribution.
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
7 *
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
11 * (at your option) any later version.
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
12 *
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
16 * GNU General Public License for more details.
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
17 *
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
28321
c8d617c408ab Update various header copyrights thanks to licensecheck.
Paul Aurich <darkrain42@pidgin.im>
parents: 26072
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
21 *
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
22 */
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
23
19898
218e4bb04853 Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents: 19391
diff changeset
24 #include "internal.h"
218e4bb04853 Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents: 19391
diff changeset
25
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
26 #include "usermood.h"
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
27 #include "pep.h"
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
28 #include <string.h>
17780
749862fd4a87 Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <am@adiumx.com>
parents: 17779
diff changeset
29 #include "internal.h"
17784
6aab6554431e Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
30 #include "request.h"
20226
282d0c1feb58 applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents: 19994
diff changeset
31 #include "debug.h"
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
32
24913
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
33 static PurpleMood moods[] = {
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
34 {"afraid", N_("Afraid"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
35 {"amazed", N_("Amazed"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
36 {"amorous", N_("Amorous"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
37 {"angry", N_("Angry"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
38 {"annoyed", N_("Annoyed"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
39 {"anxious", N_("Anxious"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
40 {"aroused", N_("Aroused"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
41 {"ashamed", N_("Ashamed"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
42 {"bored", N_("Bored"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
43 {"brave", N_("Brave"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
44 {"calm", N_("Calm"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
45 {"cautious", N_("Cautious"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
46 {"cold", N_("Cold"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
47 {"confident", N_("Confident"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
48 {"confused", N_("Confused"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
49 {"contemplative", N_("Contemplative"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
50 {"contented", N_("Contented"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
51 {"cranky", N_("Cranky"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
52 {"crazy", N_("Crazy"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
53 {"creative", N_("Creative"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
54 {"curious", N_("Curious"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
55 {"dejected", N_("Dejected"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
56 {"depressed", N_("Depressed"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
57 {"disappointed", N_("Disappointed"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
58 {"disgusted", N_("Disgusted"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
59 {"dismayed", N_("Dismayed"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
60 {"distracted", N_("Distracted"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
61 {"embarrassed", N_("Embarrassed"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
62 {"envious", N_("Envious"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
63 {"excited", N_("Excited"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
64 {"flirtatious", N_("Flirtatious"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
65 {"frustrated", N_("Frustrated"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
66 {"grateful", N_("Grateful"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
67 {"grieving", N_("Grieving"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
68 {"grumpy", N_("Grumpy"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
69 {"guilty", N_("Guilty"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
70 {"happy", N_("Happy"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
71 {"hopeful", N_("Hopeful"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
72 {"hot", N_("Hot"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
73 {"humbled", N_("Humbled"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
74 {"humiliated", N_("Humiliated"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
75 {"hungry", N_("Hungry"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
76 {"hurt", N_("Hurt"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
77 {"impressed", N_("Impressed"), NULL},
29768
0ad628b5ff37 jabber: Remove a couple of underscores that slipped in in the textual
Marcus Lundblad <malu@pidgin.im>
parents: 29411
diff changeset
78 {"in_awe", N_("In awe"), NULL},
0ad628b5ff37 jabber: Remove a couple of underscores that slipped in in the textual
Marcus Lundblad <malu@pidgin.im>
parents: 29411
diff changeset
79 {"in_love", N_("In love"), NULL},
24913
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
80 {"indignant", N_("Indignant"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
81 {"interested", N_("Interested"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
82 {"intoxicated", N_("Intoxicated"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
83 {"invincible", N_("Invincible"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
84 {"jealous", N_("Jealous"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
85 {"lonely", N_("Lonely"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
86 {"lost", N_("Lost"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
87 {"lucky", N_("Lucky"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
88 {"mean", N_("Mean"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
89 {"moody", N_("Moody"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
90 {"nervous", N_("Nervous"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
91 {"neutral", N_("Neutral"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
92 {"offended", N_("Offended"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
93 {"outraged", N_("Outraged"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
94 {"playful", N_("Playful"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
95 {"proud", N_("Proud"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
96 {"relaxed", N_("Relaxed"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
97 {"relieved", N_("Relieved"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
98 {"remorseful", N_("Remorseful"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
99 {"restless", N_("Restless"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
100 {"sad", N_("Sad"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
101 {"sarcastic", N_("Sarcastic"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
102 {"satisfied", N_("Satisfied"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
103 {"serious", N_("Serious"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
104 {"shocked", N_("Shocked"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
105 {"shy", N_("Shy"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
106 {"sick", N_("Sick"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
107 {"sleepy", N_("Sleepy"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
108 {"spontaneous", N_("Spontaneous"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
109 {"stressed", N_("Stressed"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
110 {"strong", N_("Strong"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
111 {"surprised", N_("Surprised"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
112 {"thankful", N_("Thankful"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
113 {"thirsty", N_("Thirsty"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
114 {"tired", N_("Tired"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
115 {"undefined", N_("Undefined"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
116 {"weak", N_("Weak"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
117 {"worried", N_("Worried"), NULL},
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
118 /* Mark the last record. */
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
119 {NULL, NULL, NULL}
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
120 };
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
121
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
122 static void jabber_mood_cb(JabberStream *js, const char *from, xmlnode *items) {
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
123 /* it doesn't make sense to have more than one item here, so let's just pick the first one */
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
124 xmlnode *item = xmlnode_get_child(items, "item");
19391
e9a2be88e565 Initialize newmood to NULL, as there are codepaths by which we can check against whether it is NULL or not before setting it, and that's bad.
Evan Schoenberg <evands@pidgin.im>
parents: 17803
diff changeset
125 const char *newmood = NULL;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
126 char *moodtext = NULL;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
127 JabberBuddy *buddy = jabber_buddy_find(js, from, FALSE);
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
128 xmlnode *moodinfo, *mood;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
129 /* ignore the mood of people not on our buddy list */
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
130 if (!buddy || !item)
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
131 return;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22943
diff changeset
132
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
133 mood = xmlnode_get_child_with_namespace(item, "mood", "http://jabber.org/protocol/mood");
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
134 if (!mood)
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
135 return;
17790
02519364ff3f Fixed a minor mistake which could leave the usermood to be parsed incompletely.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
136 for (moodinfo = mood->child; moodinfo; moodinfo = moodinfo->next) {
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
137 if (moodinfo->type == XMLNODE_TYPE_TAG) {
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
138 if (!strcmp(moodinfo->name, "text")) {
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
139 if (!moodtext) /* only pick the first one */
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
140 moodtext = xmlnode_get_data(moodinfo);
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
141 } else {
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
142 int i;
24913
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
143 for (i = 0; moods[i].mood; ++i) {
17781
d11010274b7a Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
144 /* verify that the mood is known (valid) */
24913
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
145 if (!strcmp(moodinfo->name, moods[i].mood)) {
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
146 newmood = moods[i].mood;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
147 break;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
148 }
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
149 }
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
150 }
17781
d11010274b7a Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
151 if (newmood != NULL && moodtext != NULL)
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
152 break;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
153 }
28924
93102622d1c2 jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
154 if (newmood != NULL && moodtext != NULL)
93102622d1c2 jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
155 break;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
156 }
17781
d11010274b7a Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
157 if (newmood != NULL) {
24912
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24902
diff changeset
158 purple_prpl_got_user_status(js->gc->account, from, "mood",
29411
97e8c7f56350 Actually set the mood when creating a presence update when receiving mood PEP.
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
159 PURPLE_MOOD_NAME, newmood,
24912
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24902
diff changeset
160 PURPLE_MOOD_COMMENT, moodtext,
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24902
diff changeset
161 NULL);
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24902
diff changeset
162 } else {
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24902
diff changeset
163 purple_prpl_got_user_status_deactive(js->gc->account, from, "mood");
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
164 }
19899
483c4f495a6c Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents: 19898
diff changeset
165 g_free(moodtext);
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
166 }
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
167
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
168 void jabber_mood_init(void) {
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 22943
diff changeset
169 jabber_add_feature("http://jabber.org/protocol/mood", jabber_pep_namespace_only_when_pep_enabled_cb);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 22943
diff changeset
170 jabber_pep_register_handler("http://jabber.org/protocol/mood", jabber_mood_cb);
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
171 }
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
172
17784
6aab6554431e Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <am@adiumx.com>
parents: 17783
diff changeset
173 void jabber_mood_set(JabberStream *js, const char *mood, const char *text) {
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
174 xmlnode *publish, *moodnode;
19994
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19899
diff changeset
175
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
176 publish = xmlnode_new("publish");
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
177 xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/mood");
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
178 moodnode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "mood");
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
179 xmlnode_set_namespace(moodnode, "http://jabber.org/protocol/mood");
29769
4a3daffabb1c Allow unsetting mood in mood selector, works with XMPP... Oscar is not yet
Marcus Lundblad <malu@pidgin.im>
parents: 29768
diff changeset
180 if (mood) {
4a3daffabb1c Allow unsetting mood in mood selector, works with XMPP... Oscar is not yet
Marcus Lundblad <malu@pidgin.im>
parents: 29768
diff changeset
181 /* if mood is NULL, set an empty mood node, meaning: unset mood */
4a3daffabb1c Allow unsetting mood in mood selector, works with XMPP... Oscar is not yet
Marcus Lundblad <malu@pidgin.im>
parents: 29768
diff changeset
182 xmlnode_new_child(moodnode, mood);
4a3daffabb1c Allow unsetting mood in mood selector, works with XMPP... Oscar is not yet
Marcus Lundblad <malu@pidgin.im>
parents: 29768
diff changeset
183 }
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
184
17786
23e2e1e131cc Fixed usermood memory management and removed publishing empty <text/>s.
Andreas Monitzer <am@adiumx.com>
parents: 17785
diff changeset
185 if (text && text[0] != '\0') {
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
186 xmlnode *textnode = xmlnode_new_child(moodnode, "text");
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
187 xmlnode_insert_data(textnode, text, -1);
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
188 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22943
diff changeset
189
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
190 jabber_pep_publish(js, publish);
17786
23e2e1e131cc Fixed usermood memory management and removed publishing empty <text/>s.
Andreas Monitzer <am@adiumx.com>
parents: 17785
diff changeset
191 /* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free
23e2e1e131cc Fixed usermood memory management and removed publishing empty <text/>s.
Andreas Monitzer <am@adiumx.com>
parents: 17785
diff changeset
192 (yay for well-defined memory management rules) */
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
193 }
29407
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
194
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
195 PurpleMood *jabber_get_moods(PurpleAccount *account)
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
196 {
29815
e75c3336b42a Allow showing moods for buddies when signed on using an XMPP account not
Marcus Lundblad <malu@pidgin.im>
parents: 29803
diff changeset
197 return moods;
29407
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
198 }

mercurial