annotate libpurple/protocols/jabber/usermood.c @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents 3b1070cb4f29
children
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 *
28048
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 28047
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: 28047
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: 28047
diff changeset
6 * source distribution.
17842
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
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17842
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
28047
8c991e09efcb Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents: 25985
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17842
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
19698
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
17842
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>
17846
2f067d8fb19a Fixed a few small mistakes I discovered while testing user mood in Adium.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17845
diff changeset
29 #include "internal.h"
17850
2e41e74dabd0 Implemented setting the User Mood. Currently untested since it requires the fields request API, which isn't implemented in Adium yet.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17849
diff changeset
30 #include "request.h"
20334
58a57a0ca807 applied changes from 1095e0c294d15e95c8909d270748c5253226bfe6
Luke Schierer <lschiere@pidgin.im>
parents: 20000
diff changeset
31 #include "debug.h"
17842
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
32
29441
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
33 static PurpleMood moods[] = {
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
34 {"afraid", N_("Afraid"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
35 {"amazed", N_("Amazed"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
36 {"amorous", N_("Amorous"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
37 {"angry", N_("Angry"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
38 {"annoyed", N_("Annoyed"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
39 {"anxious", N_("Anxious"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
40 {"aroused", N_("Aroused"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
41 {"ashamed", N_("Ashamed"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
42 {"bored", N_("Bored"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
43 {"brave", N_("Brave"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
44 {"calm", N_("Calm"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
45 {"cautious", N_("Cautious"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
46 {"cold", N_("Cold"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
47 {"confident", N_("Confident"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
48 {"confused", N_("Confused"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
49 {"contemplative", N_("Contemplative"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
50 {"contented", N_("Contented"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
51 {"cranky", N_("Cranky"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
52 {"crazy", N_("Crazy"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
53 {"creative", N_("Creative"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
54 {"curious", N_("Curious"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
55 {"dejected", N_("Dejected"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
56 {"depressed", N_("Depressed"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
57 {"disappointed", N_("Disappointed"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
58 {"disgusted", N_("Disgusted"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
59 {"dismayed", N_("Dismayed"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
60 {"distracted", N_("Distracted"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
61 {"embarrassed", N_("Embarrassed"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
62 {"envious", N_("Envious"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
63 {"excited", N_("Excited"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
64 {"flirtatious", N_("Flirtatious"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
65 {"frustrated", N_("Frustrated"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
66 {"grateful", N_("Grateful"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
67 {"grieving", N_("Grieving"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
68 {"grumpy", N_("Grumpy"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
69 {"guilty", N_("Guilty"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
70 {"happy", N_("Happy"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
71 {"hopeful", N_("Hopeful"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
72 {"hot", N_("Hot"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
73 {"humbled", N_("Humbled"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
74 {"humiliated", N_("Humiliated"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
75 {"hungry", N_("Hungry"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
76 {"hurt", N_("Hurt"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
77 {"impressed", N_("Impressed"), NULL},
29489
7e150a194aef jabber: Remove a couple of underscores that slipped in in the textual
Marcus Lundblad <ml@update.uu.se>
parents: 29467
diff changeset
78 {"in_awe", N_("In awe"), NULL},
7e150a194aef jabber: Remove a couple of underscores that slipped in in the textual
Marcus Lundblad <ml@update.uu.se>
parents: 29467
diff changeset
79 {"in_love", N_("In love"), NULL},
29441
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
80 {"indignant", N_("Indignant"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
81 {"interested", N_("Interested"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
82 {"intoxicated", N_("Intoxicated"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
83 {"invincible", N_("Invincible"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
84 {"jealous", N_("Jealous"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
85 {"lonely", N_("Lonely"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
86 {"lost", N_("Lost"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
87 {"lucky", N_("Lucky"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
88 {"mean", N_("Mean"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
89 {"moody", N_("Moody"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
90 {"nervous", N_("Nervous"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
91 {"neutral", N_("Neutral"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
92 {"offended", N_("Offended"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
93 {"outraged", N_("Outraged"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
94 {"playful", N_("Playful"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
95 {"proud", N_("Proud"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
96 {"relaxed", N_("Relaxed"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
97 {"relieved", N_("Relieved"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
98 {"remorseful", N_("Remorseful"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
99 {"restless", N_("Restless"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
100 {"sad", N_("Sad"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
101 {"sarcastic", N_("Sarcastic"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
102 {"satisfied", N_("Satisfied"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
103 {"serious", N_("Serious"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
104 {"shocked", N_("Shocked"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
105 {"shy", N_("Shy"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
106 {"sick", N_("Sick"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
107 {"sleepy", N_("Sleepy"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
108 {"spontaneous", N_("Spontaneous"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
109 {"stressed", N_("Stressed"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
110 {"strong", N_("Strong"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
111 {"surprised", N_("Surprised"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
112 {"thankful", N_("Thankful"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
113 {"thirsty", N_("Thirsty"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
114 {"tired", N_("Tired"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
115 {"undefined", N_("Undefined"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
116 {"weak", N_("Weak"), NULL},
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
117 {"worried", N_("Worried"), NULL},
32777
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
118 /* Mar last record. */
29441
086b26f60913 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@wiktel.com>
parents: 29440
diff changeset
119 {NULL, NULL, NULL}
17842
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
120 };
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
121
32777
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
122 static const PurpleMood*
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
123 find_mood_by_name(const gchar *name)
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
124 {
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
125 int i;
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
126
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
127 g_return_val_if_fail(name && *name, NULL);
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
128
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
129 for (i = 0; moods[i].mood != NULL; ++i) {
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
130 if (g_str_equal(name, moods[i].mood)) {
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
131 return &moods[i];
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
132 }
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
133 }
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
134
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
135 return NULL;
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
136 }
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
137
17842
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
138 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
139 /* 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
140 xmlnode *item = xmlnode_get_child(items, "item");
19279
39779b201e7c Initialize newmood to NULL, as there are codepaths by which we can check against whether it is NULL or not before setting it, and that's bad.
Evan Schoenberg <evan.s@dreskin.net>
parents: 17869
diff changeset
141 const char *newmood = NULL;
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
142 char *moodtext = NULL;
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
143 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
144 xmlnode *moodinfo, *mood;
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
145 /* 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
146 if (!buddy || !item)
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
147 return;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22795
diff changeset
148
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
149 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
150 if (!mood)
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
151 return;
17856
f108b91e2fee Fixed a minor mistake which could leave the usermood to be parsed incompletely.
Andreas Monitzer <pidgin@monitzer.com>
parents: 17853
diff changeset
152 for (moodinfo = mood->child; moodinfo; moodinfo = moodinfo->next) {
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
153 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
154 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
155 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
156 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
157 } else {
32777
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
158 const PurpleMood *target_mood;
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
159
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
160 /* verify that the mood is known (valid) */
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
161 target_mood = find_mood_by_name(moodinfo->name);
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
162 newmood = target_mood ? target_mood->mood : NULL;
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
163 }
32777
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
164
17847
267f614152c4 Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents: 17846
diff changeset
165 if (newmood != NULL && moodtext != NULL)
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
166 break;
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
167 }
28594
ecca39fe50d7 jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
168 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: 28048
diff changeset
169 break;
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
170 }
17847
267f614152c4 Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <pidgin@monitzer.com>
parents: 17846
diff changeset
171 if (newmood != NULL) {
32305
2ec94166be43 On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents: 31720
diff changeset
172 purple_prpl_got_user_status(purple_connection_get_account(js->gc), from, "mood",
29467
65004796201d Actually set the mood when creating a presence update when receiving mood PEP.
Marcus Lundblad <ml@update.uu.se>
parents: 29463
diff changeset
173 PURPLE_MOOD_NAME, newmood,
29440
1fb503adb2ae Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents: 29430
diff changeset
174 PURPLE_MOOD_COMMENT, moodtext,
1fb503adb2ae Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents: 29430
diff changeset
175 NULL);
1fb503adb2ae Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@wiktel.com>
parents: 29430
diff changeset
176 } else {
32305
2ec94166be43 On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents: 31720
diff changeset
177 purple_prpl_got_user_status_deactive(purple_connection_get_account(js->gc), from, "mood");
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
178 }
19699
680a3aea5eb6 Various warning fixes for the xmpp prpl.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19698
diff changeset
179 g_free(moodtext);
17842
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
180 }
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
181
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
182 void jabber_mood_init(void) {
25017
26eabe8e739b Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 22795
diff changeset
183 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: 22795
diff changeset
184 jabber_pep_register_handler("http://jabber.org/protocol/mood", jabber_mood_cb);
17842
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
185 }
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
186
32777
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
187 gboolean
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
188 jabber_mood_set(JabberStream *js, const char *mood, const char *text)
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
189 {
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
190 const PurpleMood *target_mood = NULL;
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
191 xmlnode *publish, *moodnode;
20000
ab38146f8f78 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 19699
diff changeset
192
32777
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
193 if (mood && *mood) {
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
194 target_mood = find_mood_by_name(mood);
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
195 /* Mood specified, but is invalid --
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
196 * fail so that the command can handle this.
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
197 */
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
198 if (!target_mood)
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
199 return FALSE;
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
200 }
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
201
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
202 publish = xmlnode_new("publish");
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
203 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
204 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
205 xmlnode_set_namespace(moodnode, "http://jabber.org/protocol/mood");
32777
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
206
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
207 if (target_mood) {
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
208 /* If target_mood is not NULL, then
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
209 * target_mood->mood == mood, and is a valid element name.
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
210 */
29490
1c6c2f5ecf53 Allow unsetting mood in mood selector, works with XMPP... Oscar is not yet
Marcus Lundblad <ml@update.uu.se>
parents: 29489
diff changeset
211 xmlnode_new_child(moodnode, mood);
17842
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
212
32777
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
213 /* Only set text when setting a mood */
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
214 if (text && *text) {
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
215 xmlnode *textnode = xmlnode_new_child(moodnode, "text");
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
216 xmlnode_insert_data(textnode, text, -1);
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
217 }
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
218 }
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22795
diff changeset
219
17845
2e0799b916b9 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <pidgin@monitzer.com>
parents: 17844
diff changeset
220 jabber_pep_publish(js, publish);
32777
3b1070cb4f29 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <paul@darkrain42.org>
parents: 32305
diff changeset
221 return TRUE;
17842
a0cd74d7b51e forgot to add usermood.[hc]
Andreas Monitzer <pidgin@monitzer.com>
parents:
diff changeset
222 }
29463
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
223
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
224 PurpleMood *jabber_get_moods(PurpleAccount *account)
f3654983e1da Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <ml@update.uu.se>
parents: 29458
diff changeset
225 {
29530
9f6a657af957 Allow showing moods for buddies when signed on using an XMPP account not
Marcus Lundblad <ml@update.uu.se>
parents: 29517
diff changeset
226 return moods;
31720
979bab4c3bca jabber: Check for empty string when setting mood.
Paul Aurich <paul@darkrain42.org>
parents: 29545
diff changeset
227 }