aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2012-11-09 00:07:23 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2012-11-09 00:07:23 +0000
commitfb351ce6b6cdc714019f49f693182e32055fd78b (patch)
tree0d058b25127942a1574b58e8f8ed33b7841c8f50 /protocols
parent8e3b7acdfc96e086f1cd1c606e46d9a91d46a842 (diff)
Getting better. Corruption fixed, fetching of mentions fixed, error handling
"fixed".
Diffstat (limited to 'protocols')
-rw-r--r--protocols/twitter/twitter_lib.c20
-rw-r--r--protocols/twitter/twitter_lib.h2
2 files changed, 15 insertions, 7 deletions
diff --git a/protocols/twitter/twitter_lib.c b/protocols/twitter/twitter_lib.c
index 47264db0..6231cf69 100644
--- a/protocols/twitter/twitter_lib.c
+++ b/protocols/twitter/twitter_lib.c
@@ -173,6 +173,8 @@ char *twitter_parse_error(struct http_request *req)
g_free(ret);
ret = NULL;
+ /* EX:
+ {"errors":[{"message":"Rate limit exceeded","code":88}]} */
if (req->body_size > 0) {
root = xt_from_string(req->reply_body, req->body_size);
@@ -188,7 +190,8 @@ char *twitter_parse_error(struct http_request *req)
return ret ? ret : req->status_string;
}
-/* TODO: NULL means failure, but not always that the connection is dead. This sucks for callers. */
+/* WATCH OUT: This function might or might not destroy your connection.
+ Sub-optimal indeed, but just be careful when this returns NULL! */
static json_value *twitter_parse_response(struct im_connection *ic, struct http_request *req)
{
gboolean logging_in = !(ic->flags & OPT_LOGGED_IN);
@@ -456,7 +459,7 @@ static xt_status twitter_xt_get_users(json_value *node, struct twitter_xml_list
*/
static xt_status twitter_xt_get_status(const json_value *node, struct twitter_xml_status *txs)
{
- const json_value *c, *rt = NULL, *entities = NULL;
+ const json_value *rt = NULL, *entities = NULL;
int i;
if (node->type != json_object)
@@ -467,7 +470,7 @@ static xt_status twitter_xt_get_status(const json_value *node, struct twitter_xm
const json_value *v = node->u.object.values[i].value;
if (strcmp("text", k) == 0 && v->type == json_string) {
- txs->text = g_memdup(v->u.string.ptr, v->u.string.length);
+ txs->text = g_memdup(v->u.string.ptr, v->u.string.length + 1);
} else if (strcmp("retweeted_status", k) == 0 && v->type == json_object) {
rt = v;
} else if (strcmp("created_at", k) == 0 && v->type == json_string) {
@@ -485,7 +488,7 @@ static xt_status twitter_xt_get_status(const json_value *node, struct twitter_xm
} else if (strcmp("in_reply_to_status_id", k) == 0 && v->type == json_integer) {
txs->reply_to = v->u.integer;
} else if (strcmp("entities", k) == 0 && v->type == json_object) {
- txs->reply_to = v->u.integer;
+ entities = v;
}
}
@@ -501,7 +504,7 @@ static xt_status twitter_xt_get_status(const json_value *node, struct twitter_xm
g_free(txs->text);
txs->text = g_strdup_printf("RT @%s: %s", rtxs->user->screen_name, rtxs->text);
txs_free(rtxs);
- } else if (entities && NULL) {
+ } else if (entities) {
JSON_O_FOREACH (entities, k, v) {
int i;
@@ -544,7 +547,6 @@ static xt_status twitter_xt_get_status_list(struct im_connection *ic, const json
struct twitter_xml_list *txl)
{
struct twitter_xml_status *txs;
- json_value *c;
bee_user_t *bu;
int i;
@@ -916,6 +918,9 @@ static void twitter_http_get_home_timeline(struct http_request *req)
td->home_timeline_obj = txl;
end:
+ if (!g_slist_find(twitter_connections, ic))
+ return;
+
td->flags |= TWITTER_GOT_TIMELINE;
twitter_flush_timeline(ic);
@@ -949,6 +954,9 @@ static void twitter_http_get_mentions(struct http_request *req)
td->mentions_obj = txl;
end:
+ if (!g_slist_find(twitter_connections, ic))
+ return;
+
td->flags |= TWITTER_GOT_MENTIONS;
twitter_flush_timeline(ic);
diff --git a/protocols/twitter/twitter_lib.h b/protocols/twitter/twitter_lib.h
index 104a168b..7b640b00 100644
--- a/protocols/twitter/twitter_lib.h
+++ b/protocols/twitter/twitter_lib.h
@@ -42,7 +42,7 @@
#define TWITTER_FEATURED_USERS_URL "/statuses/featured.json"
#define TWITTER_FRIENDS_TIMELINE_URL "/statuses/friends_timeline.json"
#define TWITTER_HOME_TIMELINE_URL "/statuses/home_timeline.json"
-#define TWITTER_MENTIONS_URL "/statuses/mentions.json"
+#define TWITTER_MENTIONS_URL "/statuses/mentions_timeline.json"
#define TWITTER_USER_TIMELINE_URL "/statuses/user_timeline.json"
/* Users URLs */