Handle idle time from contacts

This commit is contained in:
James Booth
2012-12-09 03:07:33 +00:00
parent 6b99624348
commit 8e90f7a414
11 changed files with 162 additions and 61 deletions

View File

@@ -20,6 +20,7 @@
*
*/
#include <stdlib.h>
#include <string.h>
#include <glib.h>
@@ -359,3 +360,34 @@ stanza_get_new_nick(xmpp_stanza_t * const stanza)
return NULL;
}
}
int
stanza_get_idle_time(xmpp_stanza_t * const stanza)
{
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
if (query == NULL) {
return 0;
}
char *ns = xmpp_stanza_get_ns(query);
if (ns == NULL) {
return 0;
}
if (strcmp(ns, STANZA_NS_LASTACTIVITY) != 0) {
return 0;
}
char *seconds_str = xmpp_stanza_get_attribute(query, STANZA_ATTR_SECONDS);
if (seconds_str == NULL) {
return 0;
}
int result = atoi(seconds_str);
if (result < 1) {
return 0;
} else {
return result;
}
}