annotate libpurple/protocols/jabber/usermood.c @ 17845:2e0799b916b9

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