aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/twitter
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/twitter')
-rw-r--r--protocols/twitter/twitter.c14
-rw-r--r--protocols/twitter/twitter.h6
-rw-r--r--protocols/twitter/twitter_lib.c17
3 files changed, 34 insertions, 3 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index 85d10a56..ca279b8f 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -394,6 +394,16 @@ static int twitter_send_typing( struct im_connection *ic, char *who, int typing
// return value;
//}
+static void twitter_buddy_data_add( struct bee_user *bu )
+{
+ bu->data = g_new0( struct twitter_user_data, 1 );
+}
+
+static void twitter_buddy_data_free( struct bee_user *bu )
+{
+ g_free( bu->data );
+}
+
static void twitter_handle_command( struct im_connection *ic, char *message )
{
struct twitter_data *td = ic->proto_data;
@@ -407,7 +417,7 @@ static void twitter_handle_command( struct im_connection *ic, char *message )
g_free( cmds );
return;
}
- else if( !set_getbool( &ic->set, "commands" ) )
+ else if( !set_getbool( &ic->acc->set, "commands" ) )
{
/* Not supporting commands. */
}
@@ -490,6 +500,8 @@ void twitter_initmodule()
ret->add_deny = twitter_add_deny;
ret->rem_deny = twitter_rem_deny;
ret->send_typing = twitter_send_typing;
+ ret->buddy_data_add = twitter_buddy_data_add;
+ ret->buddy_data_free = twitter_buddy_data_free;
ret->handle_cmp = g_strcasecmp;
register_protocol(ret);
diff --git a/protocols/twitter/twitter.h b/protocols/twitter/twitter.h
index 9485520f..0acb3b4d 100644
--- a/protocols/twitter/twitter.h
+++ b/protocols/twitter/twitter.h
@@ -57,6 +57,12 @@ struct twitter_data
char *prefix; /* Used to generate contact + channel name. */
};
+struct twitter_user_data
+{
+ guint64 last_id;
+ time_t last_time;
+};
+
/**
* This has the same function as the msn_connections GSList. We use this to
* make sure the connection is still alive in callbacks before we do anything
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c
index a24e9969..699558b2 100644
--- a/protocols/twitter/twitter_lib.c
+++ b/protocols/twitter/twitter_lib.c
@@ -430,10 +430,11 @@ static xt_status twitter_xt_get_status( struct xt_node *node, struct twitter_xml
* - all <status>es within the <status> element and
* - the next_cursor.
*/
-static xt_status twitter_xt_get_status_list( struct xt_node *node, struct twitter_xml_list *txl )
+static xt_status twitter_xt_get_status_list( struct im_connection *ic, struct xt_node *node, struct twitter_xml_list *txl )
{
struct twitter_xml_status *txs;
struct xt_node *child;
+ bee_user_t *bu;
// Set the type of the list.
txl->type = TXL_STATUS;
@@ -448,6 +449,18 @@ static xt_status twitter_xt_get_status_list( struct xt_node *node, struct twitte
twitter_xt_get_status(child, txs);
// Put the item in the front of the list.
txl->list = g_slist_prepend (txl->list, txs);
+
+ if (txs->user && txs->user->screen_name &&
+ (bu = bee_user_by_handle(ic->bee, ic, txs->user->screen_name)))
+ {
+ struct twitter_user_data *tud = bu->data;
+
+ if (txs->id > tud->last_id)
+ {
+ tud->last_id = txs->id;
+ tud->last_time = txs->created_at;
+ }
+ }
}
else if ( g_strcasecmp( "next_cursor", child->name ) == 0)
{
@@ -626,7 +639,7 @@ static void twitter_http_get_home_timeline(struct http_request *req)
parser = xt_new( NULL, txl );
xt_feed( parser, req->reply_body, req->body_size );
// The root <statuses> node should hold the list of statuses <status>
- twitter_xt_get_status_list(parser->root, txl);
+ twitter_xt_get_status_list(ic, parser->root, txl);
xt_free( parser );
// See if the user wants to see the messages in a groupchat window or as private messages.