changeset 19730:46ed3f3f780e

merge of '04b85a7dd6d2bd21a0cbb8a6022eb500b53efddc' and '2edfe77b8357318304b79826b3440a0ab528215c'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 11 Sep 2007 07:13:05 +0000
parents 1b8af105614d (diff) 44b070f6a3f8 (current diff)
children 97559afd70e4 96d4a3238029
files
diffstat 15 files changed, 194 insertions(+), 269 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/dbus-analyze-functions.py	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/dbus-analyze-functions.py	Tue Sep 11 07:13:05 2007 +0000
@@ -26,6 +26,11 @@
     "purple_conv_placement_get_current_func",
     "purple_conv_placement_set_current_func",
 
+    # Similar to the above:
+    "purple_account_set_register_callback",
+    "purple_account_unregister",
+    "purple_connection_new_unregister",
+
     # This is excluded because this script treats PurpleLogReadFlags*
     # as pointer to a struct, instead of a pointer to an enum.  This
     # causes a compilation error. Someone should fix this script.
--- a/libpurple/protocols/jabber/buddy.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Tue Sep 11 07:13:05 2007 +0000
@@ -799,6 +799,12 @@
 				purple_notify_user_info_add_pair(user_info, _("Operating System"), jbr->client.os);
 			}
 		}
+#if 0 
+		/* #if 0 this for now; I think this would be far more useful if we limited this to a particular set of features
+ 		 * of particular interest (-vv jumps out as one). As it is now, I don't picture people getting all excited: "Oh sweet crap!
+ 		 * So-and-so supports 'jabber:x:data' AND 'Collaborative Data Objects'!"
+ 		 */
+
 		if(jbr && jbr->caps) {
 			GString *tmp = g_string_new("");
 			GList *iter;
@@ -907,15 +913,16 @@
 					feature = _("Hop Check");
 				else if(g_str_has_suffix(feature, "+notify"))
 					feature = NULL;
-				
 				if(feature)
-					g_string_append_printf(tmp, "%s\n", feature);
+					g_string_append_printf(tmp, "%s<br/>", feature);
 			}
+
 			if(strlen(tmp->str) > 0)
 				purple_notify_user_info_add_pair(user_info, _("Capabilities"), tmp->str);
 			
 			g_string_free(tmp, TRUE);
 		}
+#endif
 	} else {
 		for(resources = jbi->jb->resources; resources; resources = resources->next) {
 			char *purdy = NULL;
@@ -957,6 +964,7 @@
 					purple_notify_user_info_add_pair(user_info, _("Operating System"), jbr->client.os);
 				}
 			}
+#if 0
 			if(jbr && jbr->caps) {
 				GString *tmp = g_string_new("");
 				GList *iter;
@@ -1074,6 +1082,7 @@
 				
 				g_string_free(tmp, TRUE);
 			}
+#endif
 		}
 	}
 
@@ -1151,6 +1160,17 @@
 	jabber_iq_send(iq);
 }
 
+static void
+jabber_string_escape_and_append(GString *string, const char *name, const char *value, gboolean indent)
+{
+	gchar *escaped;
+
+	escaped = g_markup_escape_text(value, -1);
+	g_string_append_printf(string, "%s<b>%s:</b> %s<br/>",
+			indent ? "&nbsp;&nbsp;" : "", name, escaped);
+	g_free(escaped);
+}
+
 static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
 {
 	const char *id, *from;
@@ -1195,8 +1215,8 @@
 
 			text = xmlnode_get_data(child);
 			if(text && !strcmp(child->name, "FN")) {
-				g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
-						_("Full Name"), text);
+				jabber_string_escape_and_append(info_text,
+						_("Full Name"), text, FALSE);
 			} else if(!strcmp(child->name, "N")) {
 				for(child2 = child->child; child2; child2 = child2->next)
 				{
@@ -1207,17 +1227,14 @@
 
 					text2 = xmlnode_get_data(child2);
 					if(text2 && !strcmp(child2->name, "FAMILY")) {
-						g_string_append_printf(info_text,
-								"<b>%s:</b> %s<br/>",
-								_("Family Name"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Family Name"), text2, FALSE);
 					} else if(text2 && !strcmp(child2->name, "GIVEN")) {
-						g_string_append_printf(info_text,
-								"<b>%s:</b> %s<br/>",
-								_("Given Name"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Given Name"), text2, FALSE);
 					} else if(text2 && !strcmp(child2->name, "MIDDLE")) {
-						g_string_append_printf(info_text,
-								"<b>%s:</b> %s<br/>",
-								_("Middle Name"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Middle Name"), text2, FALSE);
 					}
 					g_free(text2);
 				}
@@ -1226,11 +1243,11 @@
 				if(b) {
 					purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", text);
 				}
-				g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
-						_("Nickname"), text);
+				jabber_string_escape_and_append(info_text,
+						_("Nickname"), text, FALSE);
 			} else if(text && !strcmp(child->name, "BDAY")) {
-				g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
-						_("Birthday"), text);
+				jabber_string_escape_and_append(info_text,
+						_("Birthday"), text, FALSE);
 			} else if(!strcmp(child->name, "ADR")) {
 				gboolean address_line_added = FALSE;
 
@@ -1255,34 +1272,27 @@
 					}
 
 					if(!strcmp(child2->name, "POBOX")) {
-						g_string_append_printf(info_text,
-								"&nbsp;<b>%s:</b> %s<br/>",
-								_("P.O. Box"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("P.O. Box"), text2, TRUE);
 					} else if(!strcmp(child2->name, "EXTADR")) {
-						g_string_append_printf(info_text,
-								"&nbsp;<b>%s:</b> %s<br/>",
-								_("Extended Address"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Extended Address"), text2, TRUE);
 					} else if(!strcmp(child2->name, "STREET")) {
-						g_string_append_printf(info_text,
-								"&nbsp;<b>%s:</b> %s<br/>",
-								_("Street Address"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Street Address"), text2, TRUE);
 					} else if(!strcmp(child2->name, "LOCALITY")) {
-						g_string_append_printf(info_text,
-								"&nbsp;<b>%s:</b> %s<br/>",
-								_("Locality"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Locality"), text2, TRUE);
 					} else if(!strcmp(child2->name, "REGION")) {
-						g_string_append_printf(info_text,
-								"&nbsp;<b>%s:</b> %s<br/>",
-								_("Region"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Region"), text2, TRUE);
 					} else if(!strcmp(child2->name, "PCODE")) {
-						g_string_append_printf(info_text,
-								"&nbsp;<b>%s:</b> %s<br/>",
-								_("Postal Code"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Postal Code"), text2, TRUE);
 					} else if(!strcmp(child2->name, "CTRY")
 								|| !strcmp(child2->name, "COUNTRY")) {
-						g_string_append_printf(info_text,
-								"&nbsp;<b>%s:</b> %s<br/>",
-								_("Country"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Country"), text2, TRUE);
 					}
 					g_free(text2);
 				}
@@ -1292,34 +1302,38 @@
 					/* show what kind of number it is */
 					number = xmlnode_get_data(child2);
 					if(number) {
-						g_string_append_printf(info_text,
-								"<b>%s:</b> %s<br/>", _("Telephone"), number);
+						jabber_string_escape_and_append(info_text,
+								_("Telephone"), number, FALSE);
 						g_free(number);
 					}
 				} else if((number = xmlnode_get_data(child))) {
 					/* lots of clients (including purple) do this, but it's
 					 * out of spec */
-					g_string_append_printf(info_text,
-							"<b>%s:</b> %s<br/>", _("Telephone"), number);
+					jabber_string_escape_and_append(info_text,
+							_("Telephone"), number, FALSE);
 					g_free(number);
 				}
 			} else if(!strcmp(child->name, "EMAIL")) {
-				char *userid;
+				char *userid, *escaped;
 				if((child2 = xmlnode_get_child(child, "USERID"))) {
 					/* show what kind of email it is */
 					userid = xmlnode_get_data(child2);
 					if(userid) {
+						escaped = g_markup_escape_text(userid, -1);
 						g_string_append_printf(info_text,
-								"<b>%s:</b> <a href='mailto:%s'>%s</a><br/>",
-								_("E-Mail"), userid, userid);
+								"<b>%s:</b> <a href=\"mailto:%s\">%s</a><br/>",
+								_("E-Mail"), escaped, escaped);
+						g_free(escaped);
 						g_free(userid);
 					}
 				} else if((userid = xmlnode_get_data(child))) {
 					/* lots of clients (including purple) do this, but it's
 					 * out of spec */
-						g_string_append_printf(info_text,
-								"<b>%s:</b> <a href='mailto:%s'>%s</a><br/>",
-								_("E-Mail"), userid, userid);
+					escaped = g_markup_escape_text(userid, -1);
+					g_string_append_printf(info_text,
+							"<b>%s:</b> <a href=\"mailto:%s\">%s</a><br/>",
+							_("E-Mail"), escaped, escaped);
+					g_free(escaped);
 					g_free(userid);
 				}
 			} else if(!strcmp(child->name, "ORG")) {
@@ -1332,25 +1346,23 @@
 
 					text2 = xmlnode_get_data(child2);
 					if(text2 && !strcmp(child2->name, "ORGNAME")) {
-						g_string_append_printf(info_text,
-								"<b>%s:</b> %s<br/>",
-								_("Organization Name"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Organization Name"), text2, FALSE);
 					} else if(text2 && !strcmp(child2->name, "ORGUNIT")) {
-						g_string_append_printf(info_text,
-								"<b>%s:</b> %s<br/>",
-								_("Organization Unit"), text2);
+						jabber_string_escape_and_append(info_text,
+								_("Organization Unit"), text2, FALSE);
 					}
 					g_free(text2);
 				}
 			} else if(text && !strcmp(child->name, "TITLE")) {
-				g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
-						_("Title"), text);
+				jabber_string_escape_and_append(info_text,
+						_("Title"), text, FALSE);
 			} else if(text && !strcmp(child->name, "ROLE")) {
-				g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
-						_("Role"), text);
+				jabber_string_escape_and_append(info_text,
+						_("Role"), text, FALSE);
 			} else if(text && !strcmp(child->name, "DESC")) {
-				g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
-						_("Description"), text);
+				jabber_string_escape_and_append(info_text,
+						_("Description"), text, FALSE);
 			} else if(!strcmp(child->name, "PHOTO") ||
 					!strcmp(child->name, "LOGO")) {
 				char *bintext = NULL;
--- a/libpurple/protocols/jabber/caps.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/jabber/caps.c	Tue Sep 11 07:13:05 2007 +0000
@@ -116,8 +116,14 @@
 static void jabber_caps_load(void) {
 	xmlnode *capsdata = purple_util_read_xml_from_file(JABBER_CAPS_FILENAME, "XMPP capabilities cache");
 	xmlnode *client;
-	if(!capsdata || strcmp(capsdata->name, "capabilities"))
+
+	if(!capsdata)
 		return;
+
+	if (strcmp(capsdata->name, "capabilities") != 0) {
+		xmlnode_free(capsdata);
+		return;
+	}
 	
 	for(client = capsdata->child; client; client = client->next) {
 		if(client->type != XMLNODE_TYPE_TAG)
@@ -183,6 +189,7 @@
 			g_hash_table_replace(capstable, key, value);
 		}
 	}
+	xmlnode_free(capsdata);
 }
 
 static void jabber_caps_store_ext(gpointer key, gpointer value, gpointer user_data) {
@@ -191,17 +198,18 @@
 	xmlnode *root = user_data;
 	xmlnode *ext = xmlnode_new_child(root,"ext");
 	GList *iter;
-	
+
 	xmlnode_set_attrib(ext,"identifier",extname);
-	
+
 	for(iter = props->identities; iter; iter = g_list_next(iter)) {
 		JabberCapsIdentity *id = iter->data;
 		xmlnode *identity = xmlnode_new_child(ext, "identity");
 		xmlnode_set_attrib(identity, "category", id->category);
 		xmlnode_set_attrib(identity, "type", id->type);
-		xmlnode_set_attrib(identity, "name", id->name);
+		if (id->name)
+			xmlnode_set_attrib(identity, "name", id->name);
 	}
-	
+
 	for(iter = props->features; iter; iter = g_list_next(iter)) {
 		const char *feat = iter->data;
 		xmlnode *feature = xmlnode_new_child(ext, "feature");
@@ -237,9 +245,13 @@
 }
 
 static void jabber_caps_store(void) {
+	char *str;
 	xmlnode *root = xmlnode_new("capabilities");
 	g_hash_table_foreach(capstable, jabber_caps_store_client, root);
-	purple_util_write_data_to_file(JABBER_CAPS_FILENAME, xmlnode_to_formatted_str(root, NULL), -1);
+	str = xmlnode_to_formatted_str(root, NULL);
+	xmlnode_free(root);
+	purple_util_write_data_to_file(JABBER_CAPS_FILENAME, str, -1);
+	g_free(str);
 }
 
 /* this function assumes that all information is available locally */
@@ -249,13 +261,11 @@
 	JabberCapsValue *caps;
 	GList *iter;
 	
-	key->node = g_strdup(node);
-	key->ver = g_strdup(ver);
+	key->node = (char *)node;
+	key->ver = (char *)ver;
 	
 	caps = g_hash_table_lookup(capstable,key);
 	
-	g_free(key->node);
-	g_free(key->ver);
 	g_free(key);
 	
 	/* join all information */
@@ -334,6 +344,11 @@
 	unsigned extOutstanding;
 } jabber_caps_cbplususerdata;
 
+typedef struct jabber_ext_userdata {
+	jabber_caps_cbplususerdata *userdata;
+	char *node;
+} jabber_ext_userdata;
+
 static void jabber_caps_get_info_check_completion(jabber_caps_cbplususerdata *userdata) {
 	if(userdata->extOutstanding == 0) {
 		userdata->cb(jabber_caps_collect_info(userdata->node, userdata->ver, userdata->ext), userdata->user_data);
@@ -352,25 +367,25 @@
 	/* collect data and fetch all exts */
 	xmlnode *query = xmlnode_get_child_with_namespace(packet,"query","http://jabber.org/protocol/disco#info");
 	xmlnode *child;
-	jabber_caps_cbplususerdata *userdata = data;
-	JabberCapsKey *clientkey = g_new0(JabberCapsKey, 1);
+	jabber_ext_userdata *extuserdata = data;
+	jabber_caps_cbplususerdata *userdata = extuserdata->userdata;
 	JabberCapsValue *client;
-	JabberCapsValueExt *value = g_new0(JabberCapsValueExt, 1);
-	const char *node = xmlnode_get_attrib(query, "node");
+	const char *node = extuserdata->node;
 	const char *key;
 	
 	--userdata->extOutstanding;
 	
 	if(node) {
-		clientkey->node = g_strdup(userdata->node);
-		clientkey->ver = g_strdup(userdata->ver);
-		
+		JabberCapsValueExt *value = g_new0(JabberCapsValueExt, 1);
+
+		JabberCapsKey *clientkey = g_new0(JabberCapsKey, 1);
+		clientkey->node = userdata->node;
+		clientkey->ver = userdata->ver;
+
 		client = g_hash_table_lookup(capstable,clientkey);
-		
-		g_free(clientkey->node);
-		g_free(clientkey->ver);
+
 		g_free(clientkey);
-		
+
 		/* split node by #, key either points to \0 or the correct ext afterwards */
 		for(key = node; key[0] != '\0'; ++key) {
 			if(key[0] == '#') {
@@ -404,7 +419,8 @@
 		
 		jabber_caps_store();
 	}
-	
+	g_free(extuserdata->node);
+	g_free(extuserdata);
 	jabber_caps_get_info_check_completion(userdata);
 }
 
@@ -449,11 +465,14 @@
 		JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#info");
 		xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#info");
 		char *node = g_strdup_printf("%s#%s", userdata->node, (const char*)iter->data);
+		jabber_ext_userdata *ext_data = g_new0(jabber_ext_userdata, 1);	
+		ext_data->node = node;
+		ext_data->userdata = userdata;
+
 		xmlnode_set_attrib(query, "node", node);
-		g_free(node);
 		xmlnode_set_attrib(iq->node, "to", userdata->who);
 
-		jabber_iq_set_callback(iq,jabber_caps_ext_iqcb,userdata);
+		jabber_iq_set_callback(iq,jabber_caps_ext_iqcb,ext_data);
 		jabber_iq_send(iq);
 	}
 	
@@ -474,25 +493,23 @@
 	userdata->ver = g_strdup(ver);
 
 	if(originalext) {
-		gchar **tmp;
+		int i;
 		gchar **splat = g_strsplit(originalext, " ", 0);
-		for(tmp = splat; *tmp; tmp++) {
-			userdata->ext = g_list_append(userdata->ext, tmp);
+		for(i =0; splat[i]; i++) {
+			userdata->ext = g_list_append(userdata->ext, splat[i]);
 			++userdata->extOutstanding;
 		}
 		g_free(splat);
 	}
 	g_free(originalext);
-	
-	key->node = g_strdup(node);
-	key->ver = g_strdup(ver);
-	
+
+	key->node = (char *)node;
+	key->ver = (char *)ver;
+
 	client = g_hash_table_lookup(capstable, key);
-	
-	g_free(key->node);
-	g_free(key->ver);
+
 	g_free(key);
-	
+
 	if(!client) {
 		JabberIq *iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#info");
 		xmlnode *query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#info");
@@ -500,32 +517,37 @@
 		xmlnode_set_attrib(query, "node", nodever);
 		g_free(nodever);
 		xmlnode_set_attrib(iq->node, "to", who);
-		
+
 		jabber_iq_set_callback(iq,jabber_caps_client_iqcb,userdata);
 		jabber_iq_send(iq);
 	} else {
-		GList *iter; 
+		GList *iter;
 		/* fetch unknown exts only */
 		for(iter = userdata->ext; iter; iter = g_list_next(iter)) {
 			JabberCapsValueExt *extvalue = g_hash_table_lookup(client->ext, (const char*)iter->data);
 			JabberIq *iq;
 			xmlnode *query;
 			char *nodever;
-			
+			jabber_ext_userdata *ext_data;
+
 			if(extvalue) {
 				/* we already have this ext, don't bother with it */
 				--userdata->extOutstanding;
 				continue;
 			}
-			
+
+			ext_data = g_new0(jabber_ext_userdata, 1);
+
 			iq = jabber_iq_new_query(js,JABBER_IQ_GET,"http://jabber.org/protocol/disco#info");
 			query = xmlnode_get_child_with_namespace(iq->node,"query","http://jabber.org/protocol/disco#info");
 			nodever = g_strdup_printf("%s#%s", node, (const char*)iter->data);
 			xmlnode_set_attrib(query, "node", nodever);
-			g_free(nodever);
 			xmlnode_set_attrib(iq->node, "to", who);
-			
-			jabber_iq_set_callback(iq,jabber_caps_ext_iqcb,userdata);
+
+			ext_data->node = nodever;
+			ext_data->userdata = userdata;
+
+			jabber_iq_set_callback(iq, jabber_caps_ext_iqcb, ext_data);
 			jabber_iq_send(iq);
 		}
 		/* maybe we have all data available anyways? This is the ideal case where no network traffic is necessary */
--- a/libpurple/protocols/jabber/jabber.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Tue Sep 11 07:13:05 2007 +0000
@@ -1427,6 +1427,7 @@
 		JabberBuddyResource *jbr = NULL;
 		const char *sub;
 		GList *l;
+		const char *mood;
 
 		if (full) {
 			PurpleStatus *status;
@@ -1452,8 +1453,7 @@
 			
 			status = purple_presence_get_active_status(purple_buddy_get_presence(b));
 			value = purple_status_get_attr_value(status, "mood");
-			if(value && purple_value_get_type(value) == PURPLE_TYPE_STRING) {
-				const char *mood = purple_value_get_string(value);
+			if (value && purple_value_get_type(value) == PURPLE_TYPE_STRING && (mood = purple_value_get_string(value))) {
 				
 				value = purple_status_get_attr_value(status, "moodtext");
 				if(value && purple_value_get_type(value) == PURPLE_TYPE_STRING) {
--- a/libpurple/protocols/jabber/message.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/jabber/message.c	Tue Sep 11 07:13:05 2007 +0000
@@ -301,7 +301,7 @@
 
 	c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, jm->from);
 
-	str = g_strdup_printf(_("%s just sent you a Buzz!"), username);
+	str = g_strdup_printf(_("%s has buzzed you!"), username);
 	
 	purple_conversation_write(c, NULL, str, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, time(NULL));
 	g_free(username);
--- a/libpurple/protocols/msn/msn.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/msn/msn.c	Tue Sep 11 07:13:05 2007 +0000
@@ -119,7 +119,6 @@
 	return TRUE;
 }
 
-#ifdef MSN_USE_ATTENTION_API
 static GList *
 msn_attention_types(PurpleAccount *account)
 {
@@ -128,15 +127,14 @@
 
 	if (!list) {
 		attn = g_new0(PurpleAttentionType, 1);
-		attn->name = _("nudge");
-		attn->incoming_description = _("nudged");
-		attn->outgoing_description = _("Nudging");
+		attn->name = _("Nudge");
+		attn->incoming_description = _("%s has nudged you!");
+		attn->outgoing_description = _("Nudging %s...");
 		list = g_list_append(list, attn);
 	}
 
 	return list;
 }
-#endif
 
 
 static PurpleCmdRet
@@ -148,14 +146,7 @@
 
 	username = purple_conversation_get_name(conv);
 
-#ifdef MSN_USE_ATTENTION_API
 	serv_send_attention(gc, username, MSN_NUDGE);
-#else
-	if (!msn_send_attention(gc, username, MSN_NUDGE))
-		return PURPLE_CMD_RET_FAILED;
-
-	purple_conversation_write(conv, NULL, _("You have just sent a Nudge!"), PURPLE_MESSAGE_SYSTEM, time(NULL));
-#endif
 
 	return PURPLE_CMD_RET_OK;
 }
@@ -2139,15 +2130,10 @@
 	NULL,					/* send_raw */
 	NULL,					/* roomlist_room_serialize */
 	NULL,					/* unregister_user */
-
-#ifdef MSN_USE_ATTENTION_API
 	msn_send_attention,                     /* send_attention */
 	msn_attention_types,                    /* attention_types */
-#else
+
 	/* padding */
-	NULL,
-	NULL,
-#endif
 	NULL
 };
 
--- a/libpurple/protocols/msn/msn.h	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/msn/msn.h	Tue Sep 11 07:13:05 2007 +0000
@@ -82,8 +82,6 @@
 /* Index into attention_types */
 #define MSN_NUDGE 0
 
-#define MSN_USE_ATTENTION_API
-
 typedef enum
 {
 	MSN_LIST_FL_OP = 0x01,
--- a/libpurple/protocols/msn/switchboard.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/msn/switchboard.c	Tue Sep 11 07:13:05 2007 +0000
@@ -963,12 +963,7 @@
 	else
 		username = g_markup_escape_text(user, -1);
 
-#ifdef MSN_USE_ATTENTION_API
 	serv_got_attention(account->gc, buddy->name, MSN_NUDGE);
-#else
-	str = g_strdup_printf(_("%s just sent you a Nudge!"), username);
-	msn_switchboard_report_user(swboard, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, str);
-#endif
 	g_free(username);
 	g_free(str);
 }
--- a/libpurple/protocols/myspace/myspace.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Tue Sep 11 07:13:05 2007 +0000
@@ -2924,21 +2924,16 @@
 	NULL,              /* whiteboard_prpl_ops */
 	msim_send_really_raw,  /* send_raw */
 	NULL,                  /* roomlist_room_serialize */
-#ifdef MSIM_USE_ATTENTION_API
+	NULL,                  /* unregister_user */
 	msim_send_attention,   /* send_attention */
 	msim_attention_types,  /* attention_types */
-#else
-	NULL,               /* _purple_reserved1 */
-	NULL,               /* _purple_reserved2 */
-#endif
-	NULL,               /* _purple_reserved3 */
 	NULL                /* _purple_reserved4 */
 };
 
 
 
 /** Based on MSN's plugin info comments. */
-PurplePluginInfo info = {
+static PurplePluginInfo info = {
 	PURPLE_PLUGIN_MAGIC,                                
 	PURPLE_MAJOR_VERSION,
 	PURPLE_MINOR_VERSION,
--- a/libpurple/protocols/myspace/myspace.h	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.h	Tue Sep 11 07:13:05 2007 +0000
@@ -73,10 +73,6 @@
  * you want to actually use the plugin! */
 /*#define MSIM_SELF_TEST            */
 
-/* Use the attention API for zaps? */
-/* Can't have until >=2.2.0, since is a new API. */
-#define MSIM_USE_ATTENTION_API
-
 /* Constants */
 
 /* Maximum length of a password that is acceptable. This is the limit
@@ -180,22 +176,7 @@
 #define MSIM_CONTACT_LIST_IMPORT_ALL_FRIENDS	1
 #define MSIM_CONTACT_LIST_IMPORT_TOP_FRIENDS	2
 
-#ifdef MSIM_USE_ATTENTION_API
 #define MsimAttentionType PurpleAttentionType
-#else
-/* Different kinds of attention alerts. Not yet in libpurple, so define 
- * our own structure here. */
-typedef struct _MsimAttentionType MsimAttentionType;
-
-/** A type of "attention" message (zap, nudge, buzz, etc. depending on the
- * protocol) that can be sent and received. */
-struct _MsimAttentionType {
-	const gchar *name;	 	        /**< Shown before sending. */
-	const gchar *incoming_description;	/**< Shown when sent. */
-	const gchar *outgoing_description;	/**< Shown when received. */
-	const gchar *icon_name;
-};
-#endif
 
 /* Functions */
 gboolean msim_load(PurplePlugin *plugin);
--- a/libpurple/protocols/myspace/zap.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/myspace/zap.c	Tue Sep 11 07:13:05 2007 +0000
@@ -41,16 +41,16 @@
 		types = g_list_append(types, attn);
 
 		/* TODO: icons for each zap */
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("zap"), _("zapped"), _("Zapping"));
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("whack"), _("whacked"), _("Whacking"));
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("torch"), _("torched"), _("Torching"));
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("smooch"), _("smooched"), _("Smooching"));
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("hug"), _("hugged"), _("Hugging"));
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("bslap"), _("bslapped"), _("Bslapping"));
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("goose"), _("goosed"), _("Goosing"));
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("hi-five"), _("hi-fived"), _("Hi-fiving"));
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("punk"), _("punk'd"), _("Punking"));
-		_MSIM_ADD_NEW_ATTENTION(NULL, _("raspberry"), _("raspberried"), _("Raspberry'ing"));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("Zap"), _("%s has zapped you!"), _("Zapping %s..."));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("Whack"), _("%s has whacked you!"), _("Whacking %s..."));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("Torch"), _("%s has torched you!"), _("Torching %s..."));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("Smooch"), _("%s has smooched you!"), _("Smooching %s..."));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("Hug"), _("%s has hugged you!"), _("Hugging %s..."));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("Slap"), _("%s has slapped you!"), _("Slapping %s..."));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("Goose"), _("%s has goosed you!"), _("Goosing %s..."));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("High-five"), _("%s has high-fived you!"), _("High-fiving %s..."));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("Punk"), _("%s has punk'd you!"), _("Punking %s..."));
+		_MSIM_ADD_NEW_ATTENTION(NULL, _("Raspberry"), _("%s has raspberried you!"), _("Raspberrying %s..."));
 	}
 
 	return types;
@@ -92,36 +92,10 @@
 {
 	gchar *zap_string;
 	gboolean rc;
-#ifndef MSIM_USE_ATTENTION_API
-	GList *types;
-	MsimAttentionType *attn;
-	gchar *zap_description;
-#endif
 
 	g_return_val_if_fail(session != NULL, FALSE);
 	g_return_val_if_fail(username != NULL, FALSE);
 
-
-#ifdef MSIM_USE_ATTENTION_API
-	/* serv_send_attention(session->gc, username, code); */
-#else
-	types = msim_attention_types(session->account);
-
-	attn = g_list_nth_data(types, code);
-	if (!attn) {
-		return FALSE;
-	}
-
-
-	zap_description = g_strdup_printf("*** Attention: %s %s ***", attn->outgoing_description,
-			username);
-
-	serv_got_im(session->gc, username, zap_description,
-			PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_SYSTEM, time(NULL));
-
-	g_free(zap_description);
-#endif
-
 	/* Construct and send the actual zap command. */
 	zap_string = g_strdup_printf("!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", code);
 
@@ -165,11 +139,7 @@
 
 	zap = GPOINTER_TO_INT(zap_num_ptr);
 
-#ifdef MSIM_USE_ATTENTION_API
 	serv_send_attention(session->gc, buddy->name, zap);
-#else
-	g_return_if_fail(msim_send_zap(session, buddy->name, zap));
-#endif
 }
 
 /** Return menu, if any, for a buddy list node. */
@@ -179,8 +149,6 @@
 	GList *menu, *zap_menu;
 	GList *types;
 	PurpleMenuAction *act;
-	/* Warning: hardcoded to match that in msim_attention_types. */
-	const gchar *zap_names[10];
 	guint i;
 
 	if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) {
@@ -188,7 +156,9 @@
 		return NULL;
 	}
 
-	/* Names from official client. */
+	zap_menu = NULL;
+
+	/* TODO: get rid of once is accessible directly in GUI */
 	types = msim_attention_types(NULL);
 	i = 0;
 	do
@@ -196,21 +166,16 @@
 		MsimAttentionType *attn;
 
 		attn = (MsimAttentionType *)types->data;
-		zap_names[i] = attn->name;
+
+		act = purple_menu_action_new(attn->name, PURPLE_CALLBACK(msim_send_zap_from_menu),
+				GUINT_TO_POINTER(i), NULL);
+		zap_menu = g_list_append(zap_menu, act);
+
 		++i;
 	} while ((types = g_list_next(types)));
 
-	menu = zap_menu = NULL;
-
-	/* TODO: get rid of once is accessible directly in GUI */
-	for (i = 0; i < sizeof(zap_names) / sizeof(zap_names[0]); ++i) {
-		act = purple_menu_action_new(zap_names[i], PURPLE_CALLBACK(msim_send_zap_from_menu),
-				GUINT_TO_POINTER(i), NULL);
-		zap_menu = g_list_append(zap_menu, act);
-	}
-
 	act = purple_menu_action_new(_("Zap"), NULL, NULL, zap_menu);
-	menu = g_list_append(menu, act);
+	menu = g_list_append(NULL, act);
 
 	return menu;
 }
@@ -221,21 +186,6 @@
 {
 	gchar *msg_text, *username;
 	gint zap;
-#ifndef MSIM_USE_ATTENTION_API
-	const gchar *zap_past_tense[10];
-	gchar *zap_text;
-
-	zap_past_tense[0] = _("zapped");
-	zap_past_tense[1] = _("whacked");
-	zap_past_tense[2] = _("torched");
-	zap_past_tense[3] = _("smooched");
-	zap_past_tense[4] = _("hugged");
-	zap_past_tense[5] = _("bslapped");
-	zap_past_tense[6] = _("goosed");
-	zap_past_tense[7] = _("hi-fived");
-	zap_past_tense[8] = _("punk'd");
-	zap_past_tense[9] = _("raspberried");
-#endif
 
 	msg_text = msim_msg_get_string(msg, "msg");
 	username = msim_msg_get_string(msg, "_username");
@@ -247,14 +197,7 @@
 
 	zap = CLAMP(zap, 0, 9);
 
-#ifdef MSIM_USE_ATTENTION_API
 	serv_got_attention(session->gc, username, zap);
-#else
-	zap_text = g_strdup_printf(_("*** You have been %s! ***"), zap_past_tense[zap]);
-	serv_got_im(session->gc, username, zap_text, 
-			PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, time(NULL));
-	g_free(zap_text);
-#endif
 
 	g_free(msg_text);
 	g_free(username);
--- a/libpurple/protocols/yahoo/yahoo.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Tue Sep 11 07:13:05 2007 +0000
@@ -909,13 +909,8 @@
 			else
 				username = g_markup_escape_text(im->from, -1);
 
-#ifdef YAHOO_USE_ATTENTION_API
 			serv_got_attention(gc, username, YAHOO_BUZZ);
-#else
-			str = g_strdup_printf(_("%s just sent you a Buzz!"), username);
-
-			purple_conversation_write(c, NULL, str, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, im->time);
-#endif
+
 			g_free(username);
 			g_free(str);
 			g_free(m);
@@ -4037,22 +4032,11 @@
 static PurpleCmdRet
 yahoopurple_cmd_buzz(PurpleConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data) {
 	PurpleAccount *account = purple_conversation_get_account(c);
-#ifndef YAHOO_USE_ATTENTION_API
-	const char *username = purple_account_get_username(account);
-#endif
 
 	if (*args && args[0])
 		return PURPLE_CMD_RET_FAILED;
 
-#ifdef YAHOO_USE_ATTENTION_API
 	serv_send_attention(account->gc, c->name, YAHOO_BUZZ);
-#else
-
-	purple_debug(PURPLE_DEBUG_INFO, "yahoo",
-	           "Sending <ding> on account %s to buddy %s.\n", username, c->name);
-	purple_conv_im_send(PURPLE_CONV_IM(c), "<ding>");
-	purple_conversation_write(c, NULL, _("You have just sent a Buzz!"), PURPLE_MESSAGE_SYSTEM, time(NULL));
-#endif
 
 	return PURPLE_CMD_RET_OK;
 }
@@ -4129,9 +4113,9 @@
 		/* Yahoo only supports one attention command: the 'buzz'. */
 		/* This is index number YAHOO_BUZZ. */
 		attn = g_new0(PurpleAttentionType, 1);
-		attn->name = _("buzz");
-		attn->incoming_description = _("buzzed");
-		attn->outgoing_description = _("Buzzing");
+		attn->name = _("Buzz");
+		attn->incoming_description = _("%s has buzzed you!");
+		attn->outgoing_description = _("Buzzing %s...");
 		list = g_list_append(list, attn);
 	} 
 
@@ -4347,13 +4331,8 @@
 	NULL, /* roomlist_room_serialize */
 	NULL, /* unregister_user */
 
-#ifdef YAHOO_USE_ATTENTION_API
 	yahoo_send_attention,
 	yahoo_attention_types,
-#else
-	NULL,
-	NULL,
-#endif
 
 	/* padding */
 	NULL
--- a/libpurple/protocols/yahoo/yahoo.h	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/protocols/yahoo/yahoo.h	Tue Sep 11 07:13:05 2007 +0000
@@ -67,12 +67,8 @@
 #define YAHOO_STATUS_TYPE_INVISIBLE "invisible"
 #define YAHOO_STATUS_TYPE_MOBILE "mobile"
 
-#define YAHOO_USE_ATTENTION_API
-
-#ifdef YAHOO_USE_ATTENTION_API
 /* Index into attention types list. */
 #define YAHOO_BUZZ 0
-#endif
 
 enum yahoo_status {
 	YAHOO_STATUS_AVAILABLE = 0,
--- a/libpurple/prpl.h	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/prpl.h	Tue Sep 11 07:13:05 2007 +0000
@@ -355,9 +355,9 @@
 	
 	/* Attention API for sending & receiving zaps/nudges/buzzes etc. */
 	gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type);
-	GList *(*attention_types)(PurpleAccount *acct);
+	GList *(*get_attention_types)(PurpleAccount *acct);
 
-	void (*_purple_reserved1)(void);
+	void (*_purple_reserved4)(void);
 };
 
 #define PURPLE_IS_PROTOCOL_PLUGIN(plugin) \
--- a/libpurple/server.c	Tue Sep 11 07:10:52 2007 +0000
+++ b/libpurple/server.c	Tue Sep 11 07:13:05 2007 +0000
@@ -253,7 +253,7 @@
 	prpl = purple_find_prpl(purple_account_get_protocol_id(account));
 
 	/* Lookup the attention type in the protocol's attention_types list, if any. */
-	get_attention_types = PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->attention_types;
+	get_attention_types = PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->get_attention_types;
 	if (get_attention_types) {
 		GList *attention_types;
 
@@ -274,7 +274,8 @@
 	PurplePlugin *prpl;
 	PurpleConversation *conv;
 	gboolean (*send_attention)(PurpleConnection *, const char *, guint);
-	
+	PurpleBuddy *buddy;
+	const char *alias;	
 	gchar *description;
 	time_t mtime;
 
@@ -289,10 +290,15 @@
 
 	attn = purple_get_attention_type_from_code(gc->account, type_code);
 
+	if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
+		alias = purple_buddy_get_contact_alias(buddy);
+	else
+		alias = who;
+
 	if (attn && attn->outgoing_description) {
-		description = g_strdup_printf(_("Attention! %s %s."), attn->outgoing_description, who);
+		description = g_strdup_printf(attn->outgoing_description, alias);
 	} else {
-		description = g_strdup(_("Attention!"));
+		description = g_strdup_printf(_("Requesting %s's attention..."), alias);
 	}
 	
 	flags = PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM;
@@ -314,6 +320,8 @@
 {
 	PurpleMessageFlags flags;
 	PurpleAttentionType *attn;
+	PurpleBuddy *buddy;
+	const char *alias;
 	gchar *description;
 	time_t mtime;
 
@@ -327,10 +335,15 @@
 	/* TODO: if (attn->icon_name) is non-null, use it to lookup an emoticon and display
 	 * it next to the attention command. And if it is null, display a generic icon. */
 
+	if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
+		alias = purple_buddy_get_contact_alias(buddy);
+	else
+		alias = who;
+
 	if (attn && attn->incoming_description) {
-		description = g_strdup_printf(_("Attention! You have been %s."), attn->incoming_description);
+		description = g_strdup_printf(attn->incoming_description, alias);
 	} else {
-		description = g_strdup(_("Attention!"));
+		description = g_strdup_printf(_("%s has requested your attention!"), alias);
 	}
 
 	purple_debug_info("server", "serv_got_attention: got '%s' from %s\n",