Mercurial > pidgin
annotate libpurple/protocols/jabber/usermood.c @ 29440:1fb503adb2ae
Move the mood UI for ICQ into Pidgin. It still uses the new request API
stuff, which needs to be replaced. Then it needs to replace the XMPP UI.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 17 Nov 2008 07:30:43 +0000 |
parents | 432d9176d054 |
children | 086b26f60913 |
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 |
19698
d32ed28cf645
Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19279
diff
changeset
|
22 #include "internal.h" |
d32ed28cf645
Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19279
diff
changeset
|
23 |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
24 #include "usermood.h" |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
25 #include "pep.h" |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
26 #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
|
27 #include "internal.h" |
17850
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
28 #include "request.h" |
20334
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
29 #include "debug.h" |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
30 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
20334
diff
changeset
|
31 static const char * const moodstrings[] = { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
32 "afraid", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
33 "amazed", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
34 "amorous", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
35 "angry", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
36 "annoyed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
37 "anxious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
38 "aroused", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
39 "ashamed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
40 "bored", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
41 "brave", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
42 "calm", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
43 "cautious", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
44 "cold", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
45 "confident", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
46 "confused", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
47 "contemplative", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
48 "contented", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
49 "cranky", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
50 "crazy", |
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
51 "creative", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
52 "curious", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
53 "dejected", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
54 "depressed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
55 "disappointed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
56 "disgusted", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
57 "dismayed", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
58 "distracted", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
59 "embarrassed", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
60 "envious", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
61 "excited", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
62 "flirtatious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
63 "frustrated", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
64 "grateful", |
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
65 "grieving", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
66 "grumpy", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
67 "guilty", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
68 "happy", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
69 "hopeful", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
70 "hot", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
71 "humbled", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
72 "humiliated", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
73 "hungry", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
74 "hurt", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
75 "impressed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
76 "in_awe", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
77 "in_love", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
78 "indignant", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
79 "interested", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
80 "intoxicated", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
81 "invincible", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
82 "jealous", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
83 "lonely", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
84 "lost", |
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
85 "lucky", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
86 "mean", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
87 "moody", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
88 "nervous", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
89 "neutral", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
90 "offended", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
91 "outraged", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
92 "playful", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
93 "proud", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
94 "relaxed", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
95 "relieved", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
96 "remorseful", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
97 "restless", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
98 "sad", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
99 "sarcastic", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
100 "satisfied", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
101 "serious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
102 "shocked", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
103 "shy", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
104 "sick", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
105 "sleepy", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
106 "spontaneous", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
107 "stressed", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
108 "strong", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
109 "surprised", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
110 "thankful", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
111 "thirsty", |
29430
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
112 "tired", |
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
113 "undefined", |
432d9176d054
Added the additional moods defined in XEP-0107 version 1.2 (2008-10-29):
Richard Laager <rlaager@wiktel.com>
parents:
22795
diff
changeset
|
114 "weak", |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
115 "worried", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
116 NULL |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
117 }; |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
118 |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
119 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
|
120 /* 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
|
121 xmlnode *item = xmlnode_get_child(items, "item"); |
19279
39779b201e7c
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 <evan.s@dreskin.net>
parents:
17869
diff
changeset
|
122 const char *newmood = NULL; |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
123 char *moodtext = NULL; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
124 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
|
125 xmlnode *moodinfo, *mood; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
126 /* 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
|
127 if (!buddy || !item) |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
128 return; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
129 |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
130 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
|
131 if (!mood) |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
132 return; |
17856
f108b91e2fee
Fixed a minor mistake which could leave the usermood to be parsed incompletely.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17853
diff
changeset
|
133 for (moodinfo = mood->child; moodinfo; moodinfo = moodinfo->next) { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
134 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
|
135 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
|
136 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
|
137 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
|
138 } else { |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
139 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
|
140 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
|
141 /* 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
|
142 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
|
143 newmood = moodstrings[i]; |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
144 break; |
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 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
147 } |
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
|
148 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
|
149 break; |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
150 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
151 } |
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
|
152 if (newmood != NULL) { |
29440
1fb503adb2ae
Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents:
29430
diff
changeset
|
153 purple_prpl_got_user_status(js->gc->account, from, "mood", |
1fb503adb2ae
Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents:
29430
diff
changeset
|
154 PURPLE_MOOD_NAME, mood, |
1fb503adb2ae
Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents:
29430
diff
changeset
|
155 PURPLE_MOOD_COMMENT, moodtext, |
1fb503adb2ae
Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents:
29430
diff
changeset
|
156 NULL); |
1fb503adb2ae
Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents:
29430
diff
changeset
|
157 } else { |
1fb503adb2ae
Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents:
29430
diff
changeset
|
158 purple_prpl_got_user_status_deactive(js->gc->account, from, "mood"); |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
159 } |
19699
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
160 g_free(moodtext); |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
161 } |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
162 |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
163 void jabber_mood_init(void) { |
17853
7754d39d70c5
Added support for setting the avatar via XEP-0084. Receiving other people's avatar is up next.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17852
diff
changeset
|
164 jabber_add_feature("mood", "http://jabber.org/protocol/mood", jabber_pep_namespace_only_when_pep_enabled_cb); |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
165 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
|
166 } |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
167 |
17850
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
168 static void do_mood_set_from_fields(PurpleConnection *gc, PurpleRequestFields *fields) { |
20334
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
169 JabberStream *js; |
22795
5954c65ae4f4
Don't count the size of an array at runtime if it's known at compile time.
Ethan Blanton <elb@pidgin.im>
parents:
21560
diff
changeset
|
170 const int max_mood_idx = sizeof(moodstrings) / sizeof(moodstrings[0]) - 1; |
20334
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
171 int selected_mood = purple_request_fields_get_choice(fields, "mood"); |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
172 |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
173 if (!PURPLE_CONNECTION_IS_VALID(gc)) { |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
174 purple_debug_error("jabber", "Unable to set mood; account offline.\n"); |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
175 return; |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
176 } |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
177 |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
178 js = gc->proto_data; |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
179 |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
180 if (selected_mood < 0 || selected_mood >= max_mood_idx) { |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
181 purple_debug_error("jabber", "Invalid mood index (%d) selected.\n", selected_mood); |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
182 return; |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
183 } |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
184 |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
185 jabber_mood_set(js, moodstrings[selected_mood], purple_request_fields_get_string(fields, "text")); |
17850
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
186 } |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
187 |
17848
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17847
diff
changeset
|
188 static void do_mood_set_mood(PurplePluginAction *action) { |
17850
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
189 PurpleConnection *gc = (PurpleConnection *) action->context; |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
190 |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
191 PurpleRequestFields *fields; |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
192 PurpleRequestFieldGroup *group; |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
193 PurpleRequestField *field; |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
194 int i; |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
195 |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
196 fields = purple_request_fields_new(); |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
197 group = purple_request_field_group_new(NULL); |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
198 purple_request_fields_add_group(fields, group); |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
199 |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
200 field = purple_request_field_choice_new("mood", |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
201 _("Mood"), 0); |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
202 |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
203 for(i = 0; moodstrings[i]; ++i) |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
204 purple_request_field_choice_add(field, _(moodstrings[i])); |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
205 |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
206 purple_request_field_set_required(field, TRUE); |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
207 purple_request_field_group_add_field(group, field); |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
208 |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
209 field = purple_request_field_string_new("text", |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
210 _("Description"), NULL, |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
211 FALSE); |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
212 purple_request_field_group_add_field(group, field); |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
213 |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
214 purple_request_fields(gc, _("Edit User Mood"), |
17850
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
215 _("Edit User Mood"), |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
216 _("Please select your mood from the list."), |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
217 fields, |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
218 _("Set"), G_CALLBACK(do_mood_set_from_fields), |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
219 _("Cancel"), NULL, |
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
220 purple_connection_get_account(gc), NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
221 gc); |
17848
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17847
diff
changeset
|
222 |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17847
diff
changeset
|
223 } |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17847
diff
changeset
|
224 |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17847
diff
changeset
|
225 void jabber_mood_init_action(GList **m) { |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17847
diff
changeset
|
226 PurplePluginAction *act = purple_plugin_action_new(_("Set Mood..."), do_mood_set_mood); |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17847
diff
changeset
|
227 *m = g_list_append(*m, act); |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17847
diff
changeset
|
228 } |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17847
diff
changeset
|
229 |
17850
2e41e74dabd0
Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17849
diff
changeset
|
230 void jabber_mood_set(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
|
231 xmlnode *publish, *moodnode; |
20000
ab38146f8f78
There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19699
diff
changeset
|
232 |
ab38146f8f78
There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19699
diff
changeset
|
233 g_return_if_fail(mood != NULL); |
ab38146f8f78
There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19699
diff
changeset
|
234 |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
235 publish = xmlnode_new("publish"); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 xmlnode_new_child(moodnode, mood); |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
240 |
17852
af833a3204bb
Fixed usermood memory management and removed publishing empty <text/>s.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17851
diff
changeset
|
241 if (text && text[0] != '\0') { |
17845
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
242 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
|
243 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
|
244 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
245 |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17844
diff
changeset
|
246 jabber_pep_publish(js, publish); |
17852
af833a3204bb
Fixed usermood memory management and removed publishing empty <text/>s.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17851
diff
changeset
|
247 /* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free |
af833a3204bb
Fixed usermood memory management and removed publishing empty <text/>s.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17851
diff
changeset
|
248 (yay for well-defined memory management rules) */ |
17842
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
249 } |