cpw.rekkanoryo.icqxstatus: 0dabd5ad: Convert XMPP to use an array of PurpleMo...

rlaager at pidgin.im rlaager at pidgin.im
Mon Nov 17 03:10:22 EST 2008


-----------------------------------------------------------------
Revision: 0dabd5ad9c81741e29dfb8b445d650ed0070e959
Ancestor: c9364e2e226121e87b4740bc926a4eb07623243e
Author: rlaager at pidgin.im
Date: 2008-11-17T08:00:25
Branch: im.pidgin.cpw.rekkanoryo.icqxstatus
URL: http://d.pidgin.im/viewmtn/revision/info/0dabd5ad9c81741e29dfb8b445d650ed0070e959

Modified files:
        libpurple/protocols/jabber/usermood.c

ChangeLog: 

Convert XMPP to use an array of PurpleMoods internally.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/usermood.c	537df9ef8fb7c1d4e959382fec51bfcb0fadc63c
+++ libpurple/protocols/jabber/usermood.c	f3f8db1bf6219078f27cc0cc8ec0957c67461f4b
@@ -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 @@ static void jabber_mood_cb(JabberStream 
 					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(Purp
 
 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 @@ static void do_mood_set_from_fields(Purp
 		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 @@ static void do_mood_set_mood(PurplePlugi
 	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);


More information about the Commits mailing list