Mercurial > pidgin.yaz
comparison 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 |
comparison
equal
deleted
inserted
replaced
19460:e5f73cebcb36 | 19461:1b5e786d137a |
---|---|
91 /** Send a zap to a user. */ | 91 /** Send a zap to a user. */ |
92 static gboolean | 92 static gboolean |
93 msim_send_zap(MsimSession *session, const gchar *username, guint code) | 93 msim_send_zap(MsimSession *session, const gchar *username, guint code) |
94 { | 94 { |
95 gchar *zap_string; | 95 gchar *zap_string; |
96 gboolean rc; | |
96 #ifndef MSIM_USE_ATTENTION_API | 97 #ifndef MSIM_USE_ATTENTION_API |
97 gchar *zap_description; | |
98 #endif | |
99 GList *types; | 98 GList *types; |
100 MsimAttentionType *attn; | 99 MsimAttentionType *attn; |
101 gboolean rc; | 100 gchar *zap_description; |
101 #endif | |
102 | 102 |
103 g_return_val_if_fail(session != NULL, FALSE); | 103 g_return_val_if_fail(session != NULL, FALSE); |
104 g_return_val_if_fail(username != NULL, FALSE); | 104 g_return_val_if_fail(username != NULL, FALSE); |
105 | 105 |
106 | |
107 #ifdef MSIM_USE_ATTENTION_API | |
108 serv_send_attention(session->gc, username, code); | |
109 #else | |
106 types = msim_attention_types(session->account); | 110 types = msim_attention_types(session->account); |
107 | 111 |
108 attn = g_list_nth_data(types, code); | 112 attn = g_list_nth_data(types, code); |
109 if (!attn) { | 113 if (!attn) { |
110 return FALSE; | 114 return FALSE; |
111 } | 115 } |
112 | 116 |
113 | 117 |
114 #ifdef MSIM_USE_ATTENTION_API | |
115 serv_got_attention(session->gc, username, attn, FALSE); | |
116 #else | |
117 zap_description = g_strdup_printf("*** Attention: %s %s ***", attn->outgoing_description, | 118 zap_description = g_strdup_printf("*** Attention: %s %s ***", attn->outgoing_description, |
118 username); | 119 username); |
119 | 120 |
120 serv_got_im(session->gc, username, zap_description, | 121 serv_got_im(session->gc, username, zap_description, |
121 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_SYSTEM, time(NULL)); | 122 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
216 gboolean | 217 gboolean |
217 msim_incoming_zap(MsimSession *session, MsimMessage *msg) | 218 msim_incoming_zap(MsimSession *session, MsimMessage *msg) |
218 { | 219 { |
219 gchar *msg_text, *username; | 220 gchar *msg_text, *username; |
220 gint zap; | 221 gint zap; |
222 #ifndef MSIM_USE_ATTENTION_API | |
221 const gchar *zap_past_tense[10]; | 223 const gchar *zap_past_tense[10]; |
222 #ifdef MSIM_USE_ATTENTION_API | |
223 MsimAttentionType attn; | |
224 #else | |
225 gchar *zap_text; | 224 gchar *zap_text; |
226 #endif | |
227 | 225 |
228 zap_past_tense[0] = _("zapped"); | 226 zap_past_tense[0] = _("zapped"); |
229 zap_past_tense[1] = _("whacked"); | 227 zap_past_tense[1] = _("whacked"); |
230 zap_past_tense[2] = _("torched"); | 228 zap_past_tense[2] = _("torched"); |
231 zap_past_tense[3] = _("smooched"); | 229 zap_past_tense[3] = _("smooched"); |
233 zap_past_tense[5] = _("bslapped"); | 231 zap_past_tense[5] = _("bslapped"); |
234 zap_past_tense[6] = _("goosed"); | 232 zap_past_tense[6] = _("goosed"); |
235 zap_past_tense[7] = _("hi-fived"); | 233 zap_past_tense[7] = _("hi-fived"); |
236 zap_past_tense[8] = _("punk'd"); | 234 zap_past_tense[8] = _("punk'd"); |
237 zap_past_tense[9] = _("raspberried"); | 235 zap_past_tense[9] = _("raspberried"); |
236 #endif | |
238 | 237 |
239 msg_text = msim_msg_get_string(msg, "msg"); | 238 msg_text = msim_msg_get_string(msg, "msg"); |
240 username = msim_msg_get_string(msg, "_username"); | 239 username = msim_msg_get_string(msg, "_username"); |
241 | 240 |
242 g_return_val_if_fail(msg_text != NULL, FALSE); | 241 g_return_val_if_fail(msg_text != NULL, FALSE); |
243 g_return_val_if_fail(username != NULL, FALSE); | 242 g_return_val_if_fail(username != NULL, FALSE); |
244 | 243 |
245 g_return_val_if_fail(sscanf(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", &zap) == 1, FALSE); | 244 g_return_val_if_fail(sscanf(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", &zap) == 1, FALSE); |
246 | 245 |
247 zap = CLAMP(zap, 0, sizeof(zap_past_tense) / sizeof(zap_past_tense[0])); | 246 zap = CLAMP(zap, 0, 9); |
248 | 247 |
249 /* TODO:ZAP: use msim_attention_types */ | |
250 #ifdef MSIM_USE_ATTENTION_API | 248 #ifdef MSIM_USE_ATTENTION_API |
251 attn.incoming_description = zap_past_tense[zap]; | 249 serv_got_attention(session->gc, username, zap); |
252 attn.outgoing_description = NULL; | |
253 attn.icon_name = NULL; /* TODO: icon */ | |
254 | |
255 serv_got_attention(session->gc, username, &attn, TRUE); | |
256 #else | 250 #else |
257 zap_text = g_strdup_printf(_("*** You have been %s! ***"), zap_past_tense[zap]); | 251 zap_text = g_strdup_printf(_("*** You have been %s! ***"), zap_past_tense[zap]); |
258 serv_got_im(session->gc, username, zap_text, | 252 serv_got_im(session->gc, username, zap_text, |
259 PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, time(NULL)); | 253 PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
260 g_free(zap_text); | 254 g_free(zap_text); |