Mercurial > pidgin
annotate libpurple/protocols/jabber/usermood.c @ 17847:267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
author | Andreas Monitzer <pidgin@monitzer.com> |
---|---|
date | Tue, 12 Jun 2007 23:43:06 +0000 |
parents | 2f067d8fb19a |
children | 5fc8a8a25008 |
rev | line source |
---|---|
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
1 /* |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
2 * purple - Jabber Protocol Plugin |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
3 * |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
4 * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com> |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
5 * |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
9 * (at your option) any later version. |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
10 * |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
15 * |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
19 * |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
20 */ |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
21 |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
22 #include "usermood.h" |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
23 #include "pep.h" |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
24 #include <assert.h> |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
25 #include <string.h> |
17846
2f067d8fb19a
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17845
diff
changeset
|
26 #include "internal.h" |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
27 |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
28 static char *moodstrings[] = { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
29 "afraid", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
30 "amazed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
31 "angry", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
32 "annoyed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
33 "anxious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
34 "aroused", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
35 "ashamed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
36 "bored", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
37 "brave", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
38 "calm", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
39 "cold", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
40 "confused", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
41 "contented", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
42 "cranky", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
43 "curious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
44 "depressed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
45 "disappointed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
46 "disgusted", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
47 "distracted", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
48 "embarrassed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
49 "excited", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
50 "flirtatious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
51 "frustrated", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
52 "grumpy", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
53 "guilty", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
54 "happy", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
55 "hot", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
56 "humbled", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
57 "humiliated", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
58 "hungry", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
59 "hurt", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
60 "impressed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
61 "in_awe", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
62 "in_love", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
63 "indignant", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
64 "interested", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
65 "intoxicated", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
66 "invincible", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
67 "jealous", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
68 "lonely", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
69 "mean", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
70 "moody", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
71 "nervous", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
72 "neutral", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
73 "offended", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
74 "playful", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
75 "proud", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
76 "relieved", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
77 "remorseful", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
78 "restless", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
79 "sad", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
80 "sarcastic", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
81 "serious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
82 "shocked", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
83 "shy", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
84 "sick", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
85 "sleepy", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
86 "stressed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
87 "surprised", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
88 "thirsty", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
89 "worried", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
90 NULL |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
91 }; |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
92 |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
93 static void jabber_mood_cb(JabberStream *js, const char *from, xmlnode *items) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
94 /* it doesn't make sense to have more than one item here, so let's just pick the first one */ |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
95 xmlnode *item = xmlnode_get_child(items, "item"); |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
96 char *newmood; |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
97 char *moodtext = NULL; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
98 JabberBuddy *buddy = jabber_buddy_find(js, from, FALSE); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
99 xmlnode *moodinfo, *mood; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
100 /* ignore the mood of people not on our buddy list */ |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
101 if (!buddy || !item) |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
102 return; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
103 |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
104 mood = xmlnode_get_child_with_namespace(item, "mood", "http://jabber.org/protocol/mood"); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
105 if (!mood) |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
106 return; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
107 for (moodinfo = mood->child; moodinfo != mood->lastchild; moodinfo = moodinfo->next) { |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
108 if (moodinfo->type == XMLNODE_TYPE_TAG) { |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
109 if (!strcmp(moodinfo->name, "text")) { |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
110 if (!moodtext) /* only pick the first one */ |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
111 moodtext = xmlnode_get_data(moodinfo); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
112 } else { |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
113 int i; |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
114 for (i = 0; moodstrings[i]; ++i) { |
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
115 /* verify that the mood is known (valid) */ |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
116 if (!strcmp(moodinfo->name, moodstrings[i])) { |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
117 newmood = moodstrings[i]; |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
118 break; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
119 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
120 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
121 } |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
122 if (newmood != NULL && moodtext != NULL) |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
123 break; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
124 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
125 } |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
126 if (newmood != NULL) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
127 JabberBuddyResource *resource = jabber_buddy_find_resource(buddy, NULL); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
128 const char *status_id = jabber_buddy_state_get_status_id(resource->state); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
129 |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
130 purple_prpl_got_user_status(js->gc->account, from, status_id, "mood", _(newmood), "moodtext", moodtext?moodtext:"", NULL); |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
131 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
132 if (moodtext) |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
133 g_free(moodtext); |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
134 } |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
135 |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
136 void jabber_mood_init(void) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
137 jabber_add_feature("mood", "http://jabber.org/protocol/mood"); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
138 jabber_pep_register_handler("moodn", "http://jabber.org/protocol/mood", jabber_mood_cb); |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
139 } |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
140 |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
141 void jabber_set_mood(JabberStream *js, const char *mood, const char *text) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
142 xmlnode *publish, *moodnode; |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
143 |
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
144 assert(mood != NULL); |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
145 |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
146 publish = xmlnode_new("publish"); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
147 xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/mood"); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
148 moodnode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "mood"); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
149 xmlnode_set_namespace(moodnode, "http://jabber.org/protocol/mood"); |
17847
267f614152c4
Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents:
17846
diff
changeset
|
150 xmlnode_new_child(moodnode, mood); |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
151 |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
152 if (text) { |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
153 xmlnode *textnode = xmlnode_new_child(moodnode, "text"); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
154 xmlnode_insert_data(textnode, text, -1); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
155 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
156 |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
157 jabber_pep_publish(js, publish); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
158 |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
159 xmlnode_free(publish); |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
160 } |