libpurple/protocols/jabber/usermood.c

Tue, 12 Jun 2007 03:19:42 +0000

author
Andreas Monitzer <am@adiumx.com>
date
Tue, 12 Jun 2007 03:19:42 +0000
branch
soc.2007.xmpp
changeset 17780
749862fd4a87
parent 17779
773326802e26
child 17781
d11010274b7a
permissions
-rw-r--r--

Fixed a few small mistakes I discovered while testing user mood in Adium.

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

mercurial