Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/usermood.c @ 29031:9ae3e70a327b
jabber: More namespaces! This is a good stopping point for now.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 27 Nov 2009 17:07:19 +0000 |
parents | ecca39fe50d7 |
children | a538cb73f897 |
rev | line source |
---|---|
17569
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 * |
28398
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
28397
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
28397
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
28397
diff
changeset
|
6 * source distribution. |
17569
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
7 * |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
8 * 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
|
9 * 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
|
10 * 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
|
11 * (at your option) any later version. |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
12 * |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
13 * 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
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17569
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
17 * |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
18 * 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
|
19 * along with this program; if not, write to the Free Software |
28397
8c991e09efcb
Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents:
25987
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
17569
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 */ |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
23 |
19697
d32ed28cf645
Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19279
diff
changeset
|
24 #include "internal.h" |
d32ed28cf645
Fix mingw build of xmpp prpl
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19279
diff
changeset
|
25 |
17569
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
26 #include "usermood.h" |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
27 #include "pep.h" |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
28 #include <string.h> |
17573
2f067d8fb19a
Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17572
diff
changeset
|
29 #include "internal.h" |
17577
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:
17576
diff
changeset
|
30 #include "request.h" |
20334
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
31 #include "debug.h" |
17569
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
32 |
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
|
33 static const char * const moodstrings[] = { |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
34 "afraid", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
35 "amazed", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
36 "amorous", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
37 "angry", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
38 "annoyed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
39 "anxious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
40 "aroused", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
41 "ashamed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
42 "bored", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
43 "brave", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
44 "calm", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
45 "cautious", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
46 "cold", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
47 "confident", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
48 "confused", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
49 "contemplative", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
50 "contented", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
51 "cranky", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
52 "crazy", |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
53 "creative", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
54 "curious", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
55 "dejected", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
56 "depressed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
57 "disappointed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
58 "disgusted", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
59 "dismayed", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
60 "distracted", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
61 "embarrassed", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
62 "envious", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
63 "excited", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
64 "flirtatious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
65 "frustrated", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
66 "grumpy", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
67 "guilty", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
68 "happy", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
69 "hopeful", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
70 "hot", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
71 "humbled", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
72 "humiliated", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
73 "hungry", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
74 "hurt", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
75 "impressed", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
76 "in_awe", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
77 "in_love", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
78 "indignant", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
79 "interested", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
80 "intoxicated", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
81 "invincible", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
82 "jealous", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
83 "lonely", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
84 "lucky", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
85 "mean", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
86 "moody", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
87 "nervous", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
88 "neutral", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
89 "offended", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
90 "outraged", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
91 "playful", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
92 "proud", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
93 "relaxed", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
94 "relieved", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
95 "remorseful", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
96 "restless", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
97 "sad", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
98 "sarcastic", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
99 "serious", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
100 "shocked", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
101 "shy", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
102 "sick", |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
103 "sleepy", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
104 "spontaneous", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
105 "stressed", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
106 "strong", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
107 "surprised", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
108 "thankful", |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
109 "thirsty", |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
110 "tired", |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
111 "weak", |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
112 "worried" |
17569
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
113 }; |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
114 |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
115 static void |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
116 jabber_mood_cb(JabberStream *js, const char *from, xmlnode *items) |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
117 { |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
118 xmlnode *item; |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
119 JabberBuddy *buddy = jabber_buddy_find(js, from, FALSE); |
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:
17596
diff
changeset
|
120 const char *newmood = NULL; |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
121 char *moodtext = NULL; |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
122 xmlnode *child, *mood; |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
123 |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
124 /* it doesn't make sense to have more than one item here, so let's just pick the first one */ |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
125 item = xmlnode_get_child(items, "item"); |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
126 |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
127 /* 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:
17571
diff
changeset
|
128 if (!buddy || !item) |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
129 return; |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22771
diff
changeset
|
130 |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
131 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:
17571
diff
changeset
|
132 if (!mood) |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
133 return; |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
134 for (child = mood->child; child; child = child->next) { |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
135 if (child->type != XMLNODE_TYPE_TAG) |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
136 continue; |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
137 |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
138 if (g_str_equal("text", child->name) && moodtext == NULL) |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
139 moodtext = xmlnode_get_data(child); |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
140 else { |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
141 int i; |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
142 for (i = 0; i < G_N_ELEMENTS(moodstrings); ++i) { |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
143 /* verify that the mood is known (valid) */ |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
144 if (g_str_equal(child->name, moodstrings[i])) { |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
145 newmood = moodstrings[i]; |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
146 break; |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
147 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
148 } |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
149 } |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
150 if (newmood != NULL && moodtext != NULL) |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
151 break; |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
152 } |
17574
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:
17573
diff
changeset
|
153 if (newmood != NULL) { |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
154 PurpleAccount *account; |
19698
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19697
diff
changeset
|
155 const char *status_id; |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
156 JabberBuddyResource *resource = jabber_buddy_find_resource(buddy, NULL); |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
157 if (!resource) { /* huh? */ |
19698
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19697
diff
changeset
|
158 g_free(moodtext); |
17596
6842cc73b1b7
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17583
diff
changeset
|
159 return; |
6842cc73b1b7
Implemented XEP-0172: User Nickname, fixed some potential crashers in the other PEP callbacks.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17583
diff
changeset
|
160 } |
19698
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19697
diff
changeset
|
161 status_id = jabber_buddy_state_get_status_id(resource->state); |
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19697
diff
changeset
|
162 |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
163 account = purple_connection_get_account(js->gc); |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
164 purple_prpl_got_user_status(account, from, status_id, "mood", |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
165 _(newmood), "moodtext", |
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
166 moodtext ? moodtext : "", NULL); |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
167 } |
19698
680a3aea5eb6
Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19697
diff
changeset
|
168 g_free(moodtext); |
17569
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
169 } |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
170 |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
171 void jabber_mood_init(void) { |
25575
26eabe8e739b
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
22771
diff
changeset
|
172 jabber_add_feature("http://jabber.org/protocol/mood", jabber_pep_namespace_only_when_pep_enabled_cb); |
26eabe8e739b
Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents:
22771
diff
changeset
|
173 jabber_pep_register_handler("http://jabber.org/protocol/mood", jabber_mood_cb); |
17569
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
174 } |
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
175 |
17577
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:
17576
diff
changeset
|
176 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
|
177 JabberStream *js; |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
178 int selected_mood = purple_request_fields_get_choice(fields, "mood"); |
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 (!PURPLE_CONNECTION_IS_VALID(gc)) { |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
181 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
|
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 js = gc->proto_data; |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
186 |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
187 if (selected_mood < 0 || selected_mood >= G_N_ELEMENTS(moodstrings)) { |
20334
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
188 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
|
189 return; |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
190 } |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
191 |
58a57a0ca807
applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents:
20000
diff
changeset
|
192 jabber_mood_set(js, moodstrings[selected_mood], purple_request_fields_get_string(fields, "text")); |
17577
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:
17576
diff
changeset
|
193 } |
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:
17576
diff
changeset
|
194 |
17575
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17574
diff
changeset
|
195 static void do_mood_set_mood(PurplePluginAction *action) { |
17577
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:
17576
diff
changeset
|
196 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:
17576
diff
changeset
|
197 |
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:
17576
diff
changeset
|
198 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:
17576
diff
changeset
|
199 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:
17576
diff
changeset
|
200 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:
17576
diff
changeset
|
201 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:
17576
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:
17576
diff
changeset
|
203 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:
17576
diff
changeset
|
204 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:
17576
diff
changeset
|
205 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:
17576
diff
changeset
|
206 |
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:
17576
diff
changeset
|
207 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:
17576
diff
changeset
|
208 _("Mood"), 0); |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22771
diff
changeset
|
209 |
28973
ecca39fe50d7
jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents:
28398
diff
changeset
|
210 for(i = 0; i < G_N_ELEMENTS(moodstrings); ++i) |
17577
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:
17576
diff
changeset
|
211 purple_request_field_choice_add(field, _(moodstrings[i])); |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22771
diff
changeset
|
212 |
17577
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:
17576
diff
changeset
|
213 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:
17576
diff
changeset
|
214 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:
17576
diff
changeset
|
215 |
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:
17576
diff
changeset
|
216 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:
17576
diff
changeset
|
217 _("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:
17576
diff
changeset
|
218 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:
17576
diff
changeset
|
219 purple_request_field_group_add_field(group, field); |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22771
diff
changeset
|
220 |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
221 purple_request_fields(gc, _("Edit User Mood"), |
17577
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:
17576
diff
changeset
|
222 _("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:
17576
diff
changeset
|
223 _("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:
17576
diff
changeset
|
224 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:
17576
diff
changeset
|
225 _("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:
17576
diff
changeset
|
226 _("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:
17576
diff
changeset
|
227 purple_connection_get_account(gc), NULL, NULL, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
228 gc); |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22771
diff
changeset
|
229 |
17575
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17574
diff
changeset
|
230 } |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17574
diff
changeset
|
231 |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17574
diff
changeset
|
232 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:
17574
diff
changeset
|
233 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:
17574
diff
changeset
|
234 *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:
17574
diff
changeset
|
235 } |
5fc8a8a25008
Implemented a mood menu action (non-functional right now for some reason)
Andreas Monitzer <pidgin@monitzer.com>
parents:
17574
diff
changeset
|
236 |
17577
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:
17576
diff
changeset
|
237 void jabber_mood_set(JabberStream *js, const char *mood, const char *text) { |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
238 xmlnode *publish, *moodnode; |
20000
ab38146f8f78
There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
239 |
ab38146f8f78
There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19698
diff
changeset
|
240 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:
19698
diff
changeset
|
241 |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
242 publish = xmlnode_new("publish"); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
243 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:
17571
diff
changeset
|
244 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:
17571
diff
changeset
|
245 xmlnode_set_namespace(moodnode, "http://jabber.org/protocol/mood"); |
17574
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:
17573
diff
changeset
|
246 xmlnode_new_child(moodnode, mood); |
17569
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
247 |
17579
af833a3204bb
Fixed usermood memory management and removed publishing empty <text/>s.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17578
diff
changeset
|
248 if (text && text[0] != '\0') { |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
249 xmlnode *textnode = xmlnode_new_child(moodnode, "text"); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
250 xmlnode_insert_data(textnode, text, -1); |
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
251 } |
25443
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
22771
diff
changeset
|
252 |
17572
2e0799b916b9
Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents:
17571
diff
changeset
|
253 jabber_pep_publish(js, publish); |
17579
af833a3204bb
Fixed usermood memory management and removed publishing empty <text/>s.
Andreas Monitzer <pidgin@monitzer.com>
parents:
17578
diff
changeset
|
254 /* 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:
17578
diff
changeset
|
255 (yay for well-defined memory management rules) */ |
17569
a0cd74d7b51e
forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff
changeset
|
256 } |