Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/jabber.c @ 27894:f3477b0d32f4
improved "now listening" status support.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 03 Oct 2008 12:17:03 +0000 |
parents | d477b5b53660 |
children | 7cda79469830 |
comparison
equal
deleted
inserted
replaced
27893:43b19e3dbda7 | 27894:f3477b0d32f4 |
---|---|
1496 | 1496 |
1497 char *jabber_status_text(PurpleBuddy *b) | 1497 char *jabber_status_text(PurpleBuddy *b) |
1498 { | 1498 { |
1499 char *ret = NULL; | 1499 char *ret = NULL; |
1500 JabberBuddy *jb = NULL; | 1500 JabberBuddy *jb = NULL; |
1501 | 1501 |
1502 if (b->account->gc && b->account->gc->proto_data) | 1502 if (b->account->gc && b->account->gc->proto_data) |
1503 jb = jabber_buddy_find(b->account->gc->proto_data, b->name, FALSE); | 1503 jb = jabber_buddy_find(b->account->gc->proto_data, b->name, FALSE); |
1504 | 1504 |
1505 if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { | 1505 if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
1506 ret = g_strdup(_("Not Authorized")); | 1506 ret = g_strdup(_("Not Authorized")); |
1507 } else if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) { | 1507 } else if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) { |
1508 ret = g_strdup(jb->error_msg); | 1508 ret = g_strdup(jb->error_msg); |
1509 } else { | 1509 } else { |
1510 char *stripped; | 1510 char *stripped = NULL; |
1511 | 1511 |
1512 if(!(stripped = purple_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { | 1512 if(!(stripped = purple_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { |
1513 PurplePresence *presence = purple_buddy_get_presence(b); | 1513 PurplePresence *presence = purple_buddy_get_presence(b); |
1514 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { | 1514 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { |
1515 PurpleStatus *status = purple_presence_get_status(presence, "tune"); | 1515 PurpleStatus *status; |
1516 stripped = g_strdup(purple_status_get_attr_string(status, PURPLE_TUNE_TITLE)); | 1516 const char *title, *artist; |
1517 | |
1518 status = purple_presence_get_status(presence, "tune"); | |
1519 title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE); | |
1520 artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST); | |
1521 | |
1522 stripped = g_strdup_printf("%s%s%s", title, artist ? " - " : "", | |
1523 artist ? artist : ""); | |
1524 | |
1517 } | 1525 } |
1518 } | 1526 } |
1519 | 1527 |
1520 if(stripped) { | 1528 if(stripped) { |
1521 ret = g_markup_escape_text(stripped, -1); | 1529 ret = g_markup_escape_text(stripped, -1); |
1582 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { | 1590 if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { |
1583 PurpleStatus *tune = purple_presence_get_status(presence, "tune"); | 1591 PurpleStatus *tune = purple_presence_get_status(presence, "tune"); |
1584 const char *title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); | 1592 const char *title = purple_status_get_attr_string(tune, PURPLE_TUNE_TITLE); |
1585 const char *artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST); | 1593 const char *artist = purple_status_get_attr_string(tune, PURPLE_TUNE_ARTIST); |
1586 const char *album = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM); | 1594 const char *album = purple_status_get_attr_string(tune, PURPLE_TUNE_ALBUM); |
1595 | |
1587 char *playing = purple_util_format_song_info(title, artist, album, NULL); | 1596 char *playing = purple_util_format_song_info(title, artist, album, NULL); |
1588 if (playing) { | 1597 if (playing) { |
1589 purple_notify_user_info_add_pair(user_info, _("Now Listening"), playing); | 1598 purple_notify_user_info_add_pair(user_info, _("Now Listening"), playing); |
1590 g_free(playing); | 1599 g_free(playing); |
1591 } | 1600 } |