diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2015-01-17 20:13:19 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2015-01-17 20:13:19 +0000 |
commit | eb4ad8d31f7ed4210f24beb8753ecce594b0beef (patch) | |
tree | f7f9cf04738522a79f874e0e8ce9b915014861fc /protocols/twitter | |
parent | 1065dd4f38c81c83934ba51526471072837700ae (diff) | |
parent | 664bac38fcdf6889d3ceb29b73a0c3a4e27820ce (diff) |
Merging random other fixes/cleanups.
Diffstat (limited to 'protocols/twitter')
-rw-r--r-- | protocols/twitter/twitter.c | 7 | ||||
-rw-r--r-- | protocols/twitter/twitter_lib.c | 29 |
2 files changed, 24 insertions, 12 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index ca32b3ce..d2aafcb4 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -50,6 +50,10 @@ static void twitter_main_loop_start(struct im_connection *ic) { struct twitter_data *td = ic->proto_data; + char *last_tweet = set_getstr(&ic->acc->set, "_last_tweet"); + if (last_tweet) + td->timeline_id = g_ascii_strtoull(last_tweet, NULL, 0); + /* Create the room now that we "logged in". */ if (td->flags & TWITTER_MODE_CHAT) twitter_groupchat_init(ic); @@ -326,6 +330,9 @@ static void twitter_init(account_t * acc) s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc); + s = set_add(&acc->set, "_last_tweet", "0", NULL, acc); + s->flags |= SET_HIDDEN | SET_NOSAVE; + if (strcmp(acc->prpl->name, "twitter") == 0) { s = set_add(&acc->set, "stream", "true", set_eval_bool, acc); s->flags |= ACC_SET_OFFLINE_ONLY; diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c index b1995e73..718867a7 100644 --- a/protocols/twitter/twitter_lib.c +++ b/protocols/twitter/twitter_lib.c @@ -233,10 +233,10 @@ static void twitter_http_get_friends_ids(struct http_request *req); */ void twitter_get_friends_ids(struct im_connection *ic, gint64 next_cursor) { - // Primitive, but hey! It works... + // Primitive, but hey! It works... char *args[2]; args[0] = "cursor"; - args[1] = g_strdup_printf("%lld", (long long) next_cursor); + args[1] = g_strdup_printf("%" G_GINT64_FORMAT, next_cursor); twitter_http(ic, TWITTER_FRIENDS_IDS_URL, twitter_http_get_friends_ids, ic, 0, args, 2); g_free(args[1]); @@ -720,6 +720,7 @@ static void twitter_status_show_msg(struct im_connection *ic, struct twitter_xml static void twitter_status_show(struct im_connection *ic, struct twitter_xml_status *status) { struct twitter_data *td = ic->proto_data; + char *last_id_str; if (status->user == NULL || status->text == NULL) return; @@ -737,6 +738,10 @@ static void twitter_status_show(struct im_connection *ic, struct twitter_xml_sta // Update the timeline_id to hold the highest id, so that by the next request // we won't pick up the updates already in the list. td->timeline_id = MAX(td->timeline_id, status->rt_id); + + last_id_str = g_strdup_printf("%" G_GUINT64_FORMAT, td->timeline_id); + set_setstr(&ic->acc->set, "last_tweet", last_id_str); + g_free(last_id_str); } static gboolean twitter_stream_handle_object(struct im_connection *ic, json_value *o); @@ -996,12 +1001,12 @@ static void twitter_get_home_timeline(struct im_connection *ic, gint64 next_curs char *args[6]; args[0] = "cursor"; - args[1] = g_strdup_printf("%lld", (long long) next_cursor); + args[1] = g_strdup_printf("%" G_GINT64_FORMAT, next_cursor); args[2] = "include_entities"; args[3] = "true"; if (td->timeline_id) { args[4] = "since_id"; - args[5] = g_strdup_printf("%llu", (long long unsigned int) td->timeline_id); + args[5] = g_strdup_printf("%" G_GUINT64_FORMAT, td->timeline_id); } if (twitter_http(ic, TWITTER_HOME_TIMELINE_URL, twitter_http_get_home_timeline, ic, 0, args, @@ -1032,12 +1037,12 @@ static void twitter_get_mentions(struct im_connection *ic, gint64 next_cursor) char *args[6]; args[0] = "cursor"; - args[1] = g_strdup_printf("%lld", (long long) next_cursor); + args[1] = g_strdup_printf("%" G_GINT64_FORMAT, next_cursor); args[2] = "include_entities"; args[3] = "true"; if (td->timeline_id) { args[4] = "since_id"; - args[5] = g_strdup_printf("%llu", (long long unsigned int) td->timeline_id); + args[5] = g_strdup_printf("%" G_GUINT64_FORMAT, td->timeline_id); } else { args[4] = "count"; args[5] = g_strdup_printf("%d", set_getint(&ic->acc->set, "show_old_mentions")); @@ -1166,7 +1171,7 @@ void twitter_post_status(struct im_connection *ic, char *msg, guint64 in_reply_t char *args[4] = { "status", msg, "in_reply_to_status_id", - g_strdup_printf("%llu", (unsigned long long) in_reply_to) + g_strdup_printf("%" G_GUINT64_FORMAT, in_reply_to) }; twitter_http(ic, TWITTER_STATUS_UPDATE_URL, twitter_http_post, ic, 1, args, in_reply_to ? 4 : 2); @@ -1200,8 +1205,8 @@ void twitter_friendships_create_destroy(struct im_connection *ic, char *who, int void twitter_status_destroy(struct im_connection *ic, guint64 id) { char *url; - url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_DESTROY_URL, - (unsigned long long) id, ".json"); + url = g_strdup_printf("%s%" G_GUINT64_FORMAT "%s", + TWITTER_STATUS_DESTROY_URL, id, ".json"); twitter_http_f(ic, url, twitter_http_post, ic, 1, NULL, 0, TWITTER_HTTP_USER_ACK); g_free(url); @@ -1210,8 +1215,8 @@ void twitter_status_destroy(struct im_connection *ic, guint64 id) void twitter_status_retweet(struct im_connection *ic, guint64 id) { char *url; - url = g_strdup_printf("%s%llu%s", TWITTER_STATUS_RETWEET_URL, - (unsigned long long) id, ".json"); + url = g_strdup_printf("%s%" G_GUINT64_FORMAT "%s", + TWITTER_STATUS_RETWEET_URL, id, ".json"); twitter_http_f(ic, url, twitter_http_post, ic, 1, NULL, 0, TWITTER_HTTP_USER_ACK); g_free(url); @@ -1240,7 +1245,7 @@ void twitter_favourite_tweet(struct im_connection *ic, guint64 id) "id", NULL, }; - args[1] = g_strdup_printf("%llu", (unsigned long long) id); + args[1] = g_strdup_printf("%" G_GUINT64_FORMAT, id); twitter_http_f(ic, TWITTER_FAVORITE_CREATE_URL, twitter_http_post, ic, 1, args, 2, TWITTER_HTTP_USER_ACK); g_free(args[1]); |