libpurple/protocols/jabber/usermood.c

Tue, 02 Nov 2021 00:30:07 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 02 Nov 2021 00:30:07 -0500
changeset 41157
f223b69f7da2
parent 40634
4d3018b00ad4
child 41967
025eee9e6f1d
permissions
-rw-r--r--

Fix some bugs with proxies for xmpp

Testing Done:
Compiled and ran, was unable to get it to actually use charles proxy though.

Reviewed at https://reviews.imfreedom.org/r/1118/

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 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 28321
diff changeset
6 * source distribution.
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
7 *
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * (at your option) any later version.
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
12 *
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
13 * 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
14 * 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
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
16 * GNU General Public License for more details.
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
17 *
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
18 * 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
19 * along with this program; if not, write to the Free Software
28321
c8d617c408ab Update various header copyrights thanks to licensecheck.
Paul Aurich <darkrain42@pidgin.im>
parents: 26072
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
17776
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 */
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
23
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
24 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40358
diff changeset
25
40358
e6fe6fc1f516 move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents: 38358
diff changeset
26 #include <purple.h>
19898
218e4bb04853 Fix mingw build of xmpp prpl
Daniel Atallah <datallah@pidgin.im>
parents: 19391
diff changeset
27
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
28 #include "usermood.h"
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
29 #include "pep.h"
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
30 #include <string.h>
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
31
24913
e26d9244ded9 Convert XMPP to use an array of PurpleMoods internally.
Richard Laager <rlaager@pidgin.im>
parents: 24912
diff changeset
32 static PurpleMood moods[] = {
40599
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
33 {"afraid", N_("Afraid"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
34 {"amazed", N_("Amazed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
35 {"amorous", N_("Amorous"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
36 {"angry", N_("Angry"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
37 {"annoyed", N_("Annoyed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
38 {"anxious", N_("Anxious"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
39 {"aroused", N_("Aroused"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
40 {"ashamed", N_("Ashamed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
41 {"bored", N_("Bored"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
42 {"brave", N_("Brave"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
43 {"calm", N_("Calm"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
44 {"cautious", N_("Cautious"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
45 {"cold", N_("Cold"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
46 {"confident", N_("Confident"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
47 {"confused", N_("Confused"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
48 {"contemplative", N_("Contemplative"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
49 {"contented", N_("Contented"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
50 {"cranky", N_("Cranky"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
51 {"crazy", N_("Crazy"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
52 {"creative", N_("Creative"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
53 {"curious", N_("Curious"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
54 {"dejected", N_("Dejected"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
55 {"depressed", N_("Depressed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
56 {"disappointed", N_("Disappointed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
57 {"disgusted", N_("Disgusted"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
58 {"dismayed", N_("Dismayed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
59 {"distracted", N_("Distracted"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
60 {"embarrassed", N_("Embarrassed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
61 {"envious", N_("Envious"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
62 {"excited", N_("Excited"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
63 {"flirtatious", N_("Flirtatious"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
64 {"frustrated", N_("Frustrated"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
65 {"grateful", N_("Grateful"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
66 {"grieving", N_("Grieving"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
67 {"grumpy", N_("Grumpy"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
68 {"guilty", N_("Guilty"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
69 {"happy", N_("Happy"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
70 {"hopeful", N_("Hopeful"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
71 {"hot", N_("Hot"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
72 {"humbled", N_("Humbled"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
73 {"humiliated", N_("Humiliated"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
74 {"hungry", N_("Hungry"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
75 {"hurt", N_("Hurt"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
76 {"impressed", N_("Impressed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
77 {"in_awe", N_("In awe"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
78 {"in_love", N_("In love"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
79 {"indignant", N_("Indignant"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
80 {"interested", N_("Interested"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
81 {"intoxicated", N_("Intoxicated"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
82 {"invincible", N_("Invincible"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
83 {"jealous", N_("Jealous"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
84 {"lonely", N_("Lonely"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
85 {"lost", N_("Lost"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
86 {"lucky", N_("Lucky"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
87 {"mean", N_("Mean"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
88 {"moody", N_("Moody"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
89 {"nervous", N_("Nervous"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
90 {"neutral", N_("Neutral"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
91 {"offended", N_("Offended"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
92 {"outraged", N_("Outraged"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
93 {"playful", N_("Playful"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
94 {"proud", N_("Proud"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
95 {"relaxed", N_("Relaxed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
96 {"relieved", N_("Relieved"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
97 {"remorseful", N_("Remorseful"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
98 {"restless", N_("Restless"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
99 {"sad", N_("Sad"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
100 {"sarcastic", N_("Sarcastic"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
101 {"satisfied", N_("Satisfied"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
102 {"serious", N_("Serious"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
103 {"shocked", N_("Shocked"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
104 {"shy", N_("Shy"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
105 {"sick", N_("Sick"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
106 {"sleepy", N_("Sleepy"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
107 {"spontaneous", N_("Spontaneous"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
108 {"stressed", N_("Stressed"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
109 {"strong", N_("Strong"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
110 {"surprised", N_("Surprised"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
111 {"thankful", N_("Thankful"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
112 {"thirsty", N_("Thirsty"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
113 {"tired", N_("Tired"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
114 {"undefined", N_("Undefined"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
115 {"weak", N_("Weak"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
116 {"worried", N_("Worried"), },
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
117 /* Mark last record. */
13b1e211d865 Fix missing braces around initializer warnings in jabber.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40439
diff changeset
118 {NULL, }
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
119 };
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
120
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
121 static const PurpleMood*
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
122 find_mood_by_name(const gchar *name)
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
123 {
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
124 int i;
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
125
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
126 g_return_val_if_fail(name && *name, NULL);
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
127
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
128 for (i = 0; moods[i].mood != NULL; ++i) {
38358
30ba44276e74 Merge release-2.x.y into default
dx <dx@dxzone.com.ar>
parents: 36692 38258
diff changeset
129 if (purple_strequal(name, moods[i].mood)) {
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
130 return &moods[i];
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
131 }
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
132 }
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
133
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
134 return NULL;
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
135 }
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
136
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
137 static void jabber_mood_cb(JabberStream *js, const char *from, PurpleXmlNode *items) {
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
138 /* it doesn't make sense to have more than one item here, so let's just pick the first one */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
139 PurpleXmlNode *item = purple_xmlnode_get_child(items, "item");
19391
e9a2be88e565 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 <evands@pidgin.im>
parents: 17803
diff changeset
140 const char *newmood = NULL;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
141 char *moodtext = NULL;
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
142 JabberBuddy *buddy = jabber_buddy_find(js, from, FALSE);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
143 PurpleXmlNode *moodinfo, *mood;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
144 /* 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
145 if (!buddy || !item)
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
146 return;
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22943
diff changeset
147
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
148 mood = purple_xmlnode_get_child_with_namespace(item, "mood", "http://jabber.org/protocol/mood");
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
149 if (!mood)
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
150 return;
17790
02519364ff3f Fixed a minor mistake which could leave the usermood to be parsed incompletely.
Andreas Monitzer <am@adiumx.com>
parents: 17787
diff changeset
151 for (moodinfo = mood->child; moodinfo; moodinfo = moodinfo->next) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
152 if (moodinfo->type == PURPLE_XMLNODE_TYPE_TAG) {
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 33801
diff changeset
153 if (purple_strequal(moodinfo->name, "text")) {
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
154 if (!moodtext) /* only pick the first one */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
155 moodtext = purple_xmlnode_get_data(moodinfo);
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
156 } else {
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
157 const PurpleMood *target_mood;
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
158
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
159 /* verify that the mood is known (valid) */
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
160 target_mood = find_mood_by_name(moodinfo->name);
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
161 newmood = target_mood ? target_mood->mood : NULL;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
162 }
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
163
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
164 }
28924
93102622d1c2 jabber: Update to v1.2 of the spec (adds a few more elements).
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
165 if (newmood != NULL && moodtext != NULL)
33801
6dbfcd72998e Fix a few cases of dead code
Daniel Atallah <datallah@pidgin.im>
parents: 31935
diff changeset
166 break;
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
167 }
17781
d11010274b7a Removed the huge enum for the user mood states, since it's now passed as localized strings anyways
Andreas Monitzer <am@adiumx.com>
parents: 17780
diff changeset
168 if (newmood != NULL) {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
169 purple_protocol_got_user_status(purple_connection_get_account(js->gc), from, "mood",
29411
97e8c7f56350 Actually set the mood when creating a presence update when receiving mood PEP.
Marcus Lundblad <malu@pidgin.im>
parents: 29407
diff changeset
170 PURPLE_MOOD_NAME, newmood,
24912
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24902
diff changeset
171 PURPLE_MOOD_COMMENT, moodtext,
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24902
diff changeset
172 NULL);
9ae8349f0353 Move the mood UI for ICQ into Pidgin. It still uses the new request API
Richard Laager <rlaager@pidgin.im>
parents: 24902
diff changeset
173 } else {
36545
23b59a16c808 Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
174 purple_protocol_got_user_status_deactive(purple_connection_get_account(js->gc), from, "mood");
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
175 }
19899
483c4f495a6c Various warning fixes for the xmpp prpl.
Daniel Atallah <datallah@pidgin.im>
parents: 19898
diff changeset
176 g_free(moodtext);
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
177 }
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
178
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
179 void jabber_mood_init(void) {
23586
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 22943
diff changeset
180 jabber_add_feature("http://jabber.org/protocol/mood", jabber_pep_namespace_only_when_pep_enabled_cb);
e495a4623f76 Removing short-names for features and calculating own caps hash.
Tobias Markmann <tfar@soc.pidgin.im>
parents: 22943
diff changeset
181 jabber_pep_register_handler("http://jabber.org/protocol/mood", jabber_mood_cb);
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
182 }
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
183
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
184 gboolean
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
185 jabber_mood_set(JabberStream *js, const char *mood, const char *text)
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
186 {
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
187 const PurpleMood *target_mood = NULL;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
188 PurpleXmlNode *publish, *moodnode;
19994
854d2a4c99b6 There shouldn't be assert()s in pretty much any libpurple code.
Daniel Atallah <datallah@pidgin.im>
parents: 19899
diff changeset
189
31935
77896a9a09c2 jabber: Check for empty string when setting mood.
Paul Aurich <darkrain42@pidgin.im>
parents: 29825
diff changeset
190 if (mood && *mood) {
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
191 target_mood = find_mood_by_name(mood);
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
192 /* Mood specified, but is invalid --
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
193 * fail so that the command can handle this.
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
194 */
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
195 if (!target_mood)
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
196 return FALSE;
29769
4a3daffabb1c Allow unsetting mood in mood selector, works with XMPP... Oscar is not yet
Marcus Lundblad <malu@pidgin.im>
parents: 29768
diff changeset
197 }
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
198
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
199 publish = purple_xmlnode_new("publish");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
200 purple_xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/mood");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
201 moodnode = purple_xmlnode_new_child(purple_xmlnode_new_child(publish, "item"), "mood");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
202 purple_xmlnode_set_namespace(moodnode, "http://jabber.org/protocol/mood");
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
203
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
204 if (target_mood) {
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
205 /* If target_mood is not NULL, then
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
206 * target_mood->mood == mood, and is a valid element name.
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
207 */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
208 purple_xmlnode_new_child(moodnode, mood);
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
209
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
210 /* Only set text when setting a mood */
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
211 if (text && *text) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
212 PurpleXmlNode *textnode = purple_xmlnode_new_child(moodnode, "text");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 33811
diff changeset
213 purple_xmlnode_insert_data(textnode, text, -1);
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
214 }
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
215 }
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22943
diff changeset
216
17779
773326802e26 Fixed whitespace to match the coding convention used in libpurple
Andreas Monitzer <am@adiumx.com>
parents: 17778
diff changeset
217 jabber_pep_publish(js, publish);
32984
de7298a1dbe8 jabber: Validate user moods, and make the /mood cmd behave flexibly.
Paul Aurich <darkrain42@pidgin.im>
parents: 32438
diff changeset
218 return TRUE;
17776
e5d36bb0093b forgot to add usermood.[hc]
Andreas Monitzer <am@adiumx.com>
parents:
diff changeset
219 }
29407
e4140d21900d Implemented the get_moods prpl function for XMPP. Enables the generic mood
Marcus Lundblad <malu@pidgin.im>
parents: 29304
diff changeset
220
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40599
diff changeset
221 PurpleMood *
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40599
diff changeset
222 jabber_get_moods(PurpleProtocolClient *client, PurpleAccount *account) {
29815
e75c3336b42a Allow showing moods for buddies when signed on using an XMPP account not
Marcus Lundblad <malu@pidgin.im>
parents: 29803
diff changeset
223 return moods;
31935
77896a9a09c2 jabber: Check for empty string when setting mood.
Paul Aurich <darkrain42@pidgin.im>
parents: 29825
diff changeset
224 }

mercurial