aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--protocols/bee.h1
-rw-r--r--protocols/bee_user.c4
-rw-r--r--protocols/nogaim.h3
-rw-r--r--protocols/twitter/twitter.c14
-rw-r--r--protocols/twitter/twitter.h6
-rw-r--r--protocols/twitter/twitter_lib.c17
6 files changed, 42 insertions, 3 deletions
diff --git a/protocols/bee.h b/protocols/bee.h
index a8517f2e..5792e988 100644
--- a/protocols/bee.h
+++ b/protocols/bee.h
@@ -79,6 +79,7 @@ typedef struct bee_user
bee_t *bee;
void *ui_data;
+ void *data; /* Can be used by the IM module. */
} bee_user_t;
/* This one's mostly used so save space and make it easier (cheaper) to
diff --git a/protocols/bee_user.c b/protocols/bee_user.c
index 4399a566..5acd5b83 100644
--- a/protocols/bee_user.c
+++ b/protocols/bee_user.c
@@ -42,6 +42,8 @@ bee_user_t *bee_user_new( bee_t *bee, struct im_connection *ic, const char *hand
if( bee->ui->user_new )
bee->ui->user_new( bee, bu );
+ if( ic->acc->prpl->buddy_data_add )
+ ic->acc->prpl->buddy_data_add( bu );
/* Offline by default. This will set the right flags. */
imcb_buddy_status( ic, handle, 0, NULL, NULL );
@@ -56,6 +58,8 @@ int bee_user_free( bee_t *bee, bee_user_t *bu )
if( bee->ui->user_free )
bee->ui->user_free( bee, bu );
+ if( bu->ic->acc->prpl->buddy_data_free )
+ bu->ic->acc->prpl->buddy_data_free( bu );
g_free( bu->handle );
g_free( bu->fullname );
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index 1665a730..be67bb24 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -246,6 +246,9 @@ struct prpl {
/* Incoming transfer request */
void (* transfer_request) (struct im_connection *, file_transfer_t *ft, char *handle );
+ void (* buddy_data_add) (struct bee_user *bu);
+ void (* buddy_data_free) (struct bee_user *bu);
+
/* Some placeholders so eventually older plugins may cooperate with newer BitlBees. */
void *resv1;
void *resv2;
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.