comparison libpurple/server.c @ 19716:a359452f9ea2

Take aliases into account for the attention messages.
author Richard Laager <rlaager@wiktel.com>
date Mon, 10 Sep 2007 21:06:14 +0000
parents 437c320c8d29
children 6a0d9fa477d4 669c152c0290
comparison
equal deleted inserted replaced
19715:472e263e88a8 19716:a359452f9ea2
272 PurpleAttentionType *attn; 272 PurpleAttentionType *attn;
273 PurpleMessageFlags flags; 273 PurpleMessageFlags flags;
274 PurplePlugin *prpl; 274 PurplePlugin *prpl;
275 PurpleConversation *conv; 275 PurpleConversation *conv;
276 gboolean (*send_attention)(PurpleConnection *, const char *, guint); 276 gboolean (*send_attention)(PurpleConnection *, const char *, guint);
277 277 PurpleBuddy *buddy;
278 const char *alias;
278 gchar *description; 279 gchar *description;
279 time_t mtime; 280 time_t mtime;
280 281
281 g_return_if_fail(gc != NULL); 282 g_return_if_fail(gc != NULL);
282 g_return_if_fail(who != NULL); 283 g_return_if_fail(who != NULL);
287 288
288 mtime = time(NULL); 289 mtime = time(NULL);
289 290
290 attn = purple_get_attention_type_from_code(gc->account, type_code); 291 attn = purple_get_attention_type_from_code(gc->account, type_code);
291 292
293 if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
294 alias = purple_buddy_get_contact_alias(buddy);
295 else
296 alias = who;
297
292 if (attn && attn->outgoing_description) { 298 if (attn && attn->outgoing_description) {
293 description = g_strdup_printf(attn->outgoing_description, who); 299 description = g_strdup_printf(attn->outgoing_description, alias);
294 } else { 300 } else {
295 description = g_strdup_printf(_("Requesting %s's attention..."), who); 301 description = g_strdup_printf(_("Requesting %s's attention..."), alias);
296 } 302 }
297 303
298 flags = PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM; 304 flags = PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM;
299 305
300 purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n", 306 purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n",
312 void 318 void
313 serv_got_attention(PurpleConnection *gc, const char *who, guint type_code) 319 serv_got_attention(PurpleConnection *gc, const char *who, guint type_code)
314 { 320 {
315 PurpleMessageFlags flags; 321 PurpleMessageFlags flags;
316 PurpleAttentionType *attn; 322 PurpleAttentionType *attn;
323 PurpleBuddy *buddy;
324 const char *alias;
317 gchar *description; 325 gchar *description;
318 time_t mtime; 326 time_t mtime;
319 327
320 mtime = time(NULL); 328 mtime = time(NULL);
321 329
325 flags = PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_RECV; 333 flags = PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_RECV;
326 334
327 /* TODO: if (attn->icon_name) is non-null, use it to lookup an emoticon and display 335 /* TODO: if (attn->icon_name) is non-null, use it to lookup an emoticon and display
328 * it next to the attention command. And if it is null, display a generic icon. */ 336 * it next to the attention command. And if it is null, display a generic icon. */
329 337
338 if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
339 alias = purple_buddy_get_contact_alias(buddy);
340 else
341 alias = who;
342
330 if (attn && attn->incoming_description) { 343 if (attn && attn->incoming_description) {
331 description = g_strdup_printf(attn->incoming_description, who); 344 description = g_strdup_printf(attn->incoming_description, alias);
332 } else { 345 } else {
333 description = g_strdup(_("%s has requested your attention!")); 346 description = g_strdup_printf(_("%s has requested your attention!"), alias);
334 } 347 }
335 348
336 purple_debug_info("server", "serv_got_attention: got '%s' from %s\n", 349 purple_debug_info("server", "serv_got_attention: got '%s' from %s\n",
337 description, who); 350 description, who);
338 351