Mercurial > pidgin
comparison libpurple/protocols/jabber/buddy.c @ 26985:bc2aa262a567
propagate from branch 'im.pidgin.pidgin' (head ca6eb11f6084be37aeabcb2d99df789aaf8b4afd)
to branch 'im.pidgin.cpw.malu.client_type' (head 61fe08ebe574f1112f120259839dbc0474a701cb)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 25 May 2009 19:24:17 +0000 |
parents | 2dfb639b4f26 a8537bbcfb79 |
children | 01c91af62ab3 |
comparison
equal
deleted
inserted
replaced
26984:d2424873c666 | 26985:bc2aa262a567 |
---|---|
1042 } | 1042 } |
1043 } | 1043 } |
1044 | 1044 |
1045 if (!jbi->jb->resources) { | 1045 if (!jbi->jb->resources) { |
1046 /* the buddy is offline */ | 1046 /* the buddy is offline */ |
1047 gchar *status = | 1047 gchar *status = |
1048 g_strdup_printf("%s%s%s", _("Offline"), | 1048 g_strdup_printf("%s%s%s", _("Offline"), |
1049 jbi->last_message ? ": " : "", | 1049 jbi->last_message ? ": " : "", |
1050 jbi->last_message ? jbi->last_message : ""); | 1050 jbi->last_message ? jbi->last_message : ""); |
1051 if (jbi->last_seconds > 0) { | 1051 if (jbi->last_seconds > 0) { |
1052 char *last = purple_str_seconds_to_string(jbi->last_seconds); | 1052 char *last = purple_str_seconds_to_string(jbi->last_seconds); |
1053 gchar *message = g_strdup_printf(_("%s ago"), last); | 1053 gchar *message = g_strdup_printf(_("%s ago"), last); |
1054 purple_notify_user_info_prepend_pair(user_info, | 1054 purple_notify_user_info_prepend_pair(user_info, |
1055 _("Logged off"), message); | 1055 _("Logged off"), message); |
1056 g_free(last); | 1056 g_free(last); |
1057 g_free(message); | 1057 g_free(message); |
1058 } | 1058 } |
1059 purple_notify_user_info_prepend_pair(user_info, _("Status"), status); | 1059 purple_notify_user_info_prepend_pair(user_info, _("Status"), status); |
1458 if((query = xmlnode_get_child(packet, "query"))) { | 1458 if((query = xmlnode_get_child(packet, "query"))) { |
1459 seconds = xmlnode_get_attrib(query, "seconds"); | 1459 seconds = xmlnode_get_attrib(query, "seconds"); |
1460 if(seconds) { | 1460 if(seconds) { |
1461 char *end = NULL; | 1461 char *end = NULL; |
1462 long sec = strtol(seconds, &end, 10); | 1462 long sec = strtol(seconds, &end, 10); |
1463 JabberBuddy *jb = NULL; | 1463 JabberBuddy *jb = NULL; |
1464 char *resource = NULL; | 1464 char *resource = NULL; |
1465 char *buddy_name = NULL; | 1465 char *buddy_name = NULL; |
1466 JabberBuddyResource *jbr = NULL; | 1466 JabberBuddyResource *jbr = NULL; |
1467 | 1467 |
1468 if(end != seconds) { | 1468 if(end != seconds) { |
1469 JabberBuddyInfoResource *jbir = g_hash_table_lookup(jbi->resources, resource_name); | 1469 JabberBuddyInfoResource *jbir = g_hash_table_lookup(jbi->resources, resource_name); |
1470 if(jbir) { | 1470 if(jbir) { |
1471 jbir->idle_seconds = sec; | 1471 jbir->idle_seconds = sec; |
1472 } | 1472 } |
1473 } | 1473 } |
1474 /* Update the idle time of the buddy resource, if we got it. | 1474 /* Update the idle time of the buddy resource, if we got it. |
1475 This will correct the value when a server doesn't mark | 1475 This will correct the value when a server doesn't mark |
1476 delayed presence and we got the presence when signing on */ | 1476 delayed presence and we got the presence when signing on */ |
1477 jb = jabber_buddy_find(js, from, FALSE); | 1477 jb = jabber_buddy_find(js, from, FALSE); |
1478 if (jb) { | 1478 if (jb) { |
1479 resource = jabber_get_resource(from); | 1479 resource = jabber_get_resource(from); |
1480 buddy_name = jabber_get_bare_jid(from); | 1480 buddy_name = jabber_get_bare_jid(from); |
1481 /* if the resource already has an idle time set, we | 1481 /* if the resource already has an idle time set, we |
1482 must have gotten it originally from a presence. In | 1482 must have gotten it originally from a presence. In |
1483 this case we update it. Otherwise don't update it, to | 1483 this case we update it. Otherwise don't update it, to |
1484 avoid setting an idle and not getting informed about | 1484 avoid setting an idle and not getting informed about |
1485 the resource getting unidle */ | 1485 the resource getting unidle */ |
1486 if (resource && buddy_name) { | 1486 if (resource && buddy_name) { |
1487 jbr = jabber_buddy_find_resource(jb, resource); | 1487 jbr = jabber_buddy_find_resource(jb, resource); |
1488 | 1488 if (jbr) { |
1489 if (jbr->idle) { | 1489 if (jbr->idle) { |
1490 if (sec) { | 1490 if (sec) { |
1491 jbr->idle = time(NULL) - sec; | 1491 jbr->idle = time(NULL) - sec; |
1492 } else { | 1492 } else { |
1493 jbr->idle = 0; | 1493 jbr->idle = 0; |
1494 } | 1494 } |
1495 | 1495 |
1496 if (jbr == | 1496 if (jbr == |
1497 jabber_buddy_find_resource(jb, NULL)) { | 1497 jabber_buddy_find_resource(jb, NULL)) { |
1498 purple_prpl_got_user_idle(js->gc->account, | 1498 purple_prpl_got_user_idle(js->gc->account, |
1499 buddy_name, jbr->idle, jbr->idle); | 1499 buddy_name, jbr->idle, jbr->idle); |
1500 } | 1500 } |
1501 } | 1501 } |
1502 } | 1502 } |
1503 g_free(resource); | 1503 } |
1504 g_free(buddy_name); | 1504 g_free(resource); |
1505 } | 1505 g_free(buddy_name); |
1506 } | |
1506 } | 1507 } |
1507 } | 1508 } |
1508 } | 1509 } |
1509 g_free(resource_name); | 1510 g_free(resource_name); |
1510 } | 1511 } |
1747 xmlnode_set_attrib(iq->node, "to", jid); | 1748 xmlnode_set_attrib(iq->node, "to", jid); |
1748 jabber_iq_set_callback(iq, jabber_last_offline_parse, jbi); | 1749 jabber_iq_set_callback(iq, jabber_last_offline_parse, jbi); |
1749 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); | 1750 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); |
1750 jabber_iq_send(iq); | 1751 jabber_iq_send(iq); |
1751 } | 1752 } |
1752 | 1753 |
1753 js->pending_buddy_info_requests = g_slist_prepend(js->pending_buddy_info_requests, jbi); | 1754 js->pending_buddy_info_requests = g_slist_prepend(js->pending_buddy_info_requests, jbi); |
1754 jbi->timeout_handle = purple_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi); | 1755 jbi->timeout_handle = purple_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi); |
1755 } | 1756 } |
1756 | 1757 |
1757 void jabber_buddy_get_info(PurpleConnection *gc, const char *who) | 1758 void jabber_buddy_get_info(PurpleConnection *gc, const char *who) |
2498 | 2499 |
2499 /* TODO: Are these messages actually useful? */ | 2500 /* TODO: Are these messages actually useful? */ |
2500 if (node) | 2501 if (node) |
2501 purple_debug_info("jabber", "Found cap: %s\n", cap); | 2502 purple_debug_info("jabber", "Found cap: %s\n", cap); |
2502 else | 2503 else |
2503 purple_debug_info("jabber", "Cap %s not found\n", cap); | 2504 purple_debug_info("jabber", "Cap %s not found\n", cap); |
2504 | 2505 |
2505 return (node != NULL); | 2506 return (node != NULL); |
2506 } | 2507 } |
2507 | 2508 |
2508 gboolean | 2509 gboolean |