changeset 29835:086b26f60913

Convert XMPP to use an array of PurpleMoods internally.
author Richard Laager <rlaager@wiktel.com>
date Mon, 17 Nov 2008 08:00:25 +0000
parents 1fb503adb2ae
children 33945b987e15
files libpurple/protocols/jabber/usermood.c
diffstat 1 files changed, 94 insertions(+), 93 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/usermood.c	Mon Nov 17 07:30:43 2008 +0000
+++ b/libpurple/protocols/jabber/usermood.c	Mon Nov 17 08:00:25 2008 +0000
@@ -28,92 +28,93 @@
 #include "request.h"
 #include "debug.h"
 
-static const char * const moodstrings[] = {
-	"afraid",
-	"amazed",
-	"amorous",
-	"angry",
-	"annoyed",
-	"anxious",
-	"aroused",
-	"ashamed",
-	"bored",
-	"brave",
-	"calm",
-	"cautious",
-	"cold",
-	"confident",
-	"confused",
-	"contemplative",
-	"contented",
-	"cranky",
-	"crazy",
-	"creative",
-	"curious",
-	"dejected",
-	"depressed",
-	"disappointed",
-	"disgusted",
-	"dismayed",
-	"distracted",
-	"embarrassed",
-	"envious",
-	"excited",
-	"flirtatious",
-	"frustrated",
-	"grateful",
-	"grieving",
-	"grumpy",
-	"guilty",
-	"happy",
-	"hopeful",
-	"hot",
-	"humbled",
-	"humiliated",
-	"hungry",
-	"hurt",
-	"impressed",
-	"in_awe",
-	"in_love",
-	"indignant",
-	"interested",
-	"intoxicated",
-	"invincible",
-	"jealous",
-	"lonely",
-	"lost",
-	"lucky",
-	"mean",
-	"moody",
-	"nervous",
-	"neutral",
-	"offended",
-	"outraged",
-	"playful",
-	"proud",
-	"relaxed",
-	"relieved",
-	"remorseful",
-	"restless",
-	"sad",
-	"sarcastic",
-	"satisfied",
-	"serious",
-	"shocked",
-	"shy",
-	"sick",
-	"sleepy",
-	"spontaneous",
-	"stressed",
-	"strong",
-	"surprised",
-	"thankful",
-	"thirsty",
-	"tired",
-	"undefined",
-	"weak",
-	"worried",
-	NULL
+static PurpleMood moods[] = {
+	{"afraid", N_("Afraid"), NULL},
+	{"amazed", N_("Amazed"), NULL},
+	{"amorous", N_("Amorous"), NULL},
+	{"angry", N_("Angry"), NULL},
+	{"annoyed", N_("Annoyed"), NULL},
+	{"anxious", N_("Anxious"), NULL},
+	{"aroused", N_("Aroused"), NULL},
+	{"ashamed", N_("Ashamed"), NULL},
+	{"bored", N_("Bored"), NULL},
+	{"brave", N_("Brave"), NULL},
+	{"calm", N_("Calm"), NULL},
+	{"cautious", N_("Cautious"), NULL},
+	{"cold", N_("Cold"), NULL},
+	{"confident", N_("Confident"), NULL},
+	{"confused", N_("Confused"), NULL},
+	{"contemplative", N_("Contemplative"), NULL},
+	{"contented", N_("Contented"), NULL},
+	{"cranky", N_("Cranky"), NULL},
+	{"crazy", N_("Crazy"), NULL},
+	{"creative", N_("Creative"), NULL},
+	{"curious", N_("Curious"), NULL},
+	{"dejected", N_("Dejected"), NULL},
+	{"depressed", N_("Depressed"), NULL},
+	{"disappointed", N_("Disappointed"), NULL},
+	{"disgusted", N_("Disgusted"), NULL},
+	{"dismayed", N_("Dismayed"), NULL},
+	{"distracted", N_("Distracted"), NULL},
+	{"embarrassed", N_("Embarrassed"), NULL},
+	{"envious", N_("Envious"), NULL},
+	{"excited", N_("Excited"), NULL},
+	{"flirtatious", N_("Flirtatious"), NULL},
+	{"frustrated", N_("Frustrated"), NULL},
+	{"grateful", N_("Grateful"), NULL},
+	{"grieving", N_("Grieving"), NULL},
+	{"grumpy", N_("Grumpy"), NULL},
+	{"guilty", N_("Guilty"), NULL},
+	{"happy", N_("Happy"), NULL},
+	{"hopeful", N_("Hopeful"), NULL},
+	{"hot", N_("Hot"), NULL},
+	{"humbled", N_("Humbled"), NULL},
+	{"humiliated", N_("Humiliated"), NULL},
+	{"hungry", N_("Hungry"), NULL},
+	{"hurt", N_("Hurt"), NULL},
+	{"impressed", N_("Impressed"), NULL},
+	{"in_awe", N_("In_awe"), NULL},
+	{"in_love", N_("In_love"), NULL},
+	{"indignant", N_("Indignant"), NULL},
+	{"interested", N_("Interested"), NULL},
+	{"intoxicated", N_("Intoxicated"), NULL},
+	{"invincible", N_("Invincible"), NULL},
+	{"jealous", N_("Jealous"), NULL},
+	{"lonely", N_("Lonely"), NULL},
+	{"lost", N_("Lost"), NULL},
+	{"lucky", N_("Lucky"), NULL},
+	{"mean", N_("Mean"), NULL},
+	{"moody", N_("Moody"), NULL},
+	{"nervous", N_("Nervous"), NULL},
+	{"neutral", N_("Neutral"), NULL},
+	{"offended", N_("Offended"), NULL},
+	{"outraged", N_("Outraged"), NULL},
+	{"playful", N_("Playful"), NULL},
+	{"proud", N_("Proud"), NULL},
+	{"relaxed", N_("Relaxed"), NULL},
+	{"relieved", N_("Relieved"), NULL},
+	{"remorseful", N_("Remorseful"), NULL},
+	{"restless", N_("Restless"), NULL},
+	{"sad", N_("Sad"), NULL},
+	{"sarcastic", N_("Sarcastic"), NULL},
+	{"satisfied", N_("Satisfied"), NULL},
+	{"serious", N_("Serious"), NULL},
+	{"shocked", N_("Shocked"), NULL},
+	{"shy", N_("Shy"), NULL},
+	{"sick", N_("Sick"), NULL},
+	{"sleepy", N_("Sleepy"), NULL},
+	{"spontaneous", N_("Spontaneous"), NULL},
+	{"stressed", N_("Stressed"), NULL},
+	{"strong", N_("Strong"), NULL},
+	{"surprised", N_("Surprised"), NULL},
+	{"thankful", N_("Thankful"), NULL},
+	{"thirsty", N_("Thirsty"), NULL},
+	{"tired", N_("Tired"), NULL},
+	{"undefined", N_("Undefined"), NULL},
+	{"weak", N_("Weak"), NULL},
+	{"worried", N_("Worried"), NULL},
+	/* Mark the last record. */
+	{NULL, NULL, NULL}
 };
 
 static void jabber_mood_cb(JabberStream *js, const char *from, xmlnode *items) {
@@ -137,10 +138,10 @@
 					moodtext = xmlnode_get_data(moodinfo);
 			} else {
 				int i;
-				for (i = 0; moodstrings[i]; ++i) {
+				for (i = 0; moods[i].mood; ++i) {
 					/* verify that the mood is known (valid) */
-					if (!strcmp(moodinfo->name, moodstrings[i])) {
-						newmood = moodstrings[i];
+					if (!strcmp(moodinfo->name, moods[i].mood)) {
+						newmood = moods[i].mood;
 						break;
 					}
 				}
@@ -167,7 +168,7 @@
 
 static void do_mood_set_from_fields(PurpleConnection *gc, PurpleRequestFields *fields) {
 	JabberStream *js;
-	const int max_mood_idx = sizeof(moodstrings) / sizeof(moodstrings[0]) - 1;
+	const int max_mood_idx = sizeof(moods) / sizeof(moods[0]) - 1;
 	int selected_mood = purple_request_fields_get_choice(fields, "mood");
 
 	if (!PURPLE_CONNECTION_IS_VALID(gc)) {
@@ -182,7 +183,7 @@
 		return;
 	}
 
-	jabber_mood_set(js, moodstrings[selected_mood], purple_request_fields_get_string(fields, "text"));
+	jabber_mood_set(js, moods[selected_mood].mood, purple_request_fields_get_string(fields, "text"));
 }
 
 static void do_mood_set_mood(PurplePluginAction *action) {
@@ -200,8 +201,8 @@
 	field = purple_request_field_choice_new("mood",
 											_("Mood"), 0);
 	
-	for(i = 0; moodstrings[i]; ++i)
-		purple_request_field_choice_add(field, _(moodstrings[i]));
+	for(i = 0; moods[i].mood; ++i)
+		purple_request_field_choice_add(field, _(moods[i].description));
 	
 	purple_request_field_set_required(field, TRUE);
 	purple_request_field_group_add_field(group, field);