diff libpurple/protocols/myspace/zap.c @ 19461:1b5e786d137a

In the attention API, use the PURPLE_NOTIFY_MESSAGE flag to serv_got_im() instead of manually writing to the conversation window, as suggested by sadrul at http://pidgin.im/pipermail/devel/2007-August/002935.html. Yahoo and MSN already use this flag to indicate an attention/notify-type message. Also split off half of serv_got_attention() into serv_send_attention(), see http://pidgin.im/pipermail/devel/2007-August/002940.html. Now the attention API integrates well with the patch to add PURPLE_MESSAGE_NOTIFY at http://hiks.net/drop/adium/libgaim.diff. See also: https://sourceforge.net/tracker/?func=detail&atid=300235&aid=1672389&group_id=235
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Mon, 27 Aug 2007 01:36:21 +0000
parents 210f792efd7c
children 3f6f84d11ce2
line wrap: on
line diff
--- a/libpurple/protocols/myspace/zap.c	Mon Aug 27 00:09:17 2007 +0000
+++ b/libpurple/protocols/myspace/zap.c	Mon Aug 27 01:36:21 2007 +0000
@@ -93,16 +93,20 @@
 msim_send_zap(MsimSession *session, const gchar *username, guint code)
 {
 	gchar *zap_string;
+	gboolean rc;
 #ifndef MSIM_USE_ATTENTION_API
+	GList *types;
+	MsimAttentionType *attn;
 	gchar *zap_description;
 #endif
-	GList *types;
-	MsimAttentionType *attn;
-	gboolean rc;
 
 	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);
@@ -111,9 +115,6 @@
 	}
 
 
-#ifdef MSIM_USE_ATTENTION_API
-	serv_got_attention(session->gc, username, attn, FALSE);
-#else
 	zap_description = g_strdup_printf("*** Attention: %s %s ***", attn->outgoing_description,
 			username);
 
@@ -218,12 +219,9 @@
 {
 	gchar *msg_text, *username;
 	gint zap;
+#ifndef MSIM_USE_ATTENTION_API
 	const gchar *zap_past_tense[10];
-#ifdef MSIM_USE_ATTENTION_API
-	MsimAttentionType attn;
-#else
 	gchar *zap_text;
-#endif
 
 	zap_past_tense[0] = _("zapped");
 	zap_past_tense[1] = _("whacked");
@@ -235,6 +233,7 @@
 	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");
@@ -244,15 +243,10 @@
 
 	g_return_val_if_fail(sscanf(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", &zap) == 1, FALSE);
 
-	zap = CLAMP(zap, 0, sizeof(zap_past_tense) / sizeof(zap_past_tense[0]));
+	zap = CLAMP(zap, 0, 9);
 
-	/* TODO:ZAP: use msim_attention_types */
 #ifdef MSIM_USE_ATTENTION_API
-	attn.incoming_description = zap_past_tense[zap];
-	attn.outgoing_description = NULL;
-	attn.icon_name = NULL;		/* TODO: icon */
-
-	serv_got_attention(session->gc, username, &attn, TRUE);
+	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,