diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2012-11-24 14:10:34 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2012-11-24 14:10:34 +0000 |
commit | f26d9a3e54a89b640902d6ffad4f3d32b76dc97e (patch) | |
tree | ed970fc63b9c73cc0df9135b6748b65fa1225075 /protocols/twitter | |
parent | c751e512afd4dc200c04a70cc6d0edb94e63e8b3 (diff) |
Add help info for "stream" setting. Also, disable it for non-Twitter accounts.
Diffstat (limited to 'protocols/twitter')
-rw-r--r-- | protocols/twitter/twitter.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c index 6bde497a..b7eacc4b 100644 --- a/protocols/twitter/twitter.c +++ b/protocols/twitter/twitter.c @@ -64,13 +64,17 @@ static void twitter_main_loop_start(struct im_connection *ic) imcb_log(ic, "Getting initial statuses"); - // Run this once. After this queue the main loop function. + // Run this once. After this queue the main loop function (or open the + // stream if available). twitter_main_loop(ic, -1, 0); if (set_getbool(&ic->acc->set, "stream")) { /* That fetch was just to get backlog, the stream will give us the rest. \o/ */ twitter_open_stream(ic); + + /* Stream sends keepalives (empty lines) or actual data at + least twice a minute. Disconnect if this stops. */ ic->flags |= OPT_PONGS; } else { /* Not using the streaming API, so keep polling the old- @@ -95,7 +99,6 @@ void twitter_login_finish(struct im_connection *ic) !(td->flags & TWITTER_HAVE_FRIENDS)) { imcb_log(ic, "Getting contact list"); twitter_get_friends_ids(ic, -1); - //twitter_get_statuses_friends(ic, -1); } else twitter_main_loop_start(ic); } @@ -288,12 +291,14 @@ static void twitter_init(account_t * acc) s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc); - s = set_add(&acc->set, "stream", "true", set_eval_bool, acc); - s->flags |= ACC_SET_OFFLINE_ONLY; + if (strcmp(acc->prpl->name, "twitter") == 0) { + s = set_add(&acc->set, "stream", "true", set_eval_bool, acc); + s->flags |= ACC_SET_OFFLINE_ONLY; + } } /** - * Login method. Since the twitter API works with seperate HTTP request we + * Login method. Since the twitter API works with separate HTTP request we * only save the user and pass to the twitter_data object. */ static void twitter_login(account_t * acc) @@ -311,6 +316,12 @@ static void twitter_login(account_t * acc) return; } + if (!strstr(url.host, "twitter.com") && + set_getbool(&ic->acc->set, "stream")) { + imcb_error(ic, "Warning: The streaming API is only supported by Twitter, " + "and you seem to be connecting to a different service."); + } + imcb_log(ic, "Connecting"); twitter_connections = g_slist_append(twitter_connections, ic); |