comparison libpurple/server.c @ 23616:49850f7ca393

Add purple_prpl_got_attention_in_chat, then deprecate serv_{send,got}_attention, and add purple_prpl_{send,got}_attention instead. References #4542.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 19 Jul 2008 03:03:17 +0000
parents 8ea901db8e34
children 00420530cc56 4bc74deeb503 e81f0d1966db
comparison
equal deleted inserted replaced
23615:d370388bfc89 23616:49850f7ca393
321 } 321 }
322 322
323 void 323 void
324 serv_send_attention(PurpleConnection *gc, const char *who, guint type_code) 324 serv_send_attention(PurpleConnection *gc, const char *who, guint type_code)
325 { 325 {
326 PurpleAttentionType *attn; 326 purple_prpl_send_attention(gc, who, type_code);
327 PurpleMessageFlags flags;
328 PurplePlugin *prpl;
329 PurpleConversation *conv;
330 gboolean (*send_attention)(PurpleConnection *, const char *, guint);
331 PurpleBuddy *buddy;
332 const char *alias;
333 gchar *description;
334 time_t mtime;
335
336 g_return_if_fail(gc != NULL);
337 g_return_if_fail(who != NULL);
338
339 prpl = purple_find_prpl(purple_account_get_protocol_id(gc->account));
340 send_attention = PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->send_attention;
341 g_return_if_fail(send_attention != NULL);
342
343 mtime = time(NULL);
344
345 attn = purple_get_attention_type_from_code(gc->account, type_code);
346
347 if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
348 alias = purple_buddy_get_contact_alias(buddy);
349 else
350 alias = who;
351
352 if (attn && purple_attention_type_get_outgoing_desc(attn)) {
353 description = g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias);
354 } else {
355 description = g_strdup_printf(_("Requesting %s's attention..."), alias);
356 }
357
358 flags = PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM;
359
360 purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n",
361 description, who);
362
363 if (!send_attention(gc, who, type_code))
364 return;
365
366 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, gc->account, who);
367 purple_conv_im_write(PURPLE_CONV_IM(conv), NULL, description, flags, mtime);
368
369 g_free(description);
370 } 327 }
371 328
372 void 329 void
373 serv_got_attention(PurpleConnection *gc, const char *who, guint type_code) 330 serv_got_attention(PurpleConnection *gc, const char *who, guint type_code)
374 { 331 {
375 PurpleMessageFlags flags; 332 purple_prpl_got_attention(gc, who, type_code);
376 PurpleAttentionType *attn;
377 PurpleBuddy *buddy;
378 const char *alias;
379 gchar *description;
380 time_t mtime;
381
382 mtime = time(NULL);
383
384 attn = purple_get_attention_type_from_code(gc->account, type_code);
385
386 /* PURPLE_MESSAGE_NOTIFY is for attention messages. */
387 flags = PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_RECV;
388
389 /* TODO: if (attn->icon_name) is non-null, use it to lookup an emoticon and display
390 * it next to the attention command. And if it is null, display a generic icon. */
391
392 if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
393 alias = purple_buddy_get_contact_alias(buddy);
394 else
395 alias = who;
396
397 if (attn && purple_attention_type_get_incoming_desc(attn)) {
398 description = g_strdup_printf(purple_attention_type_get_incoming_desc(attn), alias);
399 } else {
400 description = g_strdup_printf(_("%s has requested your attention!"), alias);
401 }
402
403 purple_debug_info("server", "serv_got_attention: got '%s' from %s\n",
404 description, who);
405
406 serv_got_im(gc, who, description, flags, mtime);
407
408 /* TODO: sounds (depending on PurpleAttentionType), shaking, etc. */
409
410 g_free(description);
411 } 333 }
412 334
413 335
414 /* 336 /*
415 * Move a buddy from one group to another on server. 337 * Move a buddy from one group to another on server.