aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-11-21 15:23:54 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2010-11-21 15:23:54 +0000
commit748bcdde269da5cd8184418f0df334e12338a541 (patch)
tree5e046d6d0426872666722ceab8b04e48296f8360 /protocols
parentbb151f7aad467bf29c6e5ca552088f7f0b8ec876 (diff)
Time out if logging in takes too long (2m for now). Except for Twitter
OAuth login, which requires user action. This mostly solves problems with OSCAR login silently failing, but may also be useful in other places.
Diffstat (limited to 'protocols')
-rw-r--r--protocols/account.c15
-rw-r--r--protocols/nogaim.c1
-rw-r--r--protocols/nogaim.h1
-rw-r--r--protocols/twitter/twitter.c4
4 files changed, 21 insertions, 0 deletions
diff --git a/protocols/account.c b/protocols/account.c
index 50b7be8e..819bdc10 100644
--- a/protocols/account.c
+++ b/protocols/account.c
@@ -338,6 +338,8 @@ void account_del( bee_t *bee, account_t *acc )
}
}
+static gboolean account_on_timeout( gpointer d, gint fd, b_input_condition cond );
+
void account_on( bee_t *bee, account_t *a )
{
if( a->ic )
@@ -350,6 +352,9 @@ void account_on( bee_t *bee, account_t *a )
a->reconnect = 0;
a->prpl->login( a );
+
+ if( !( a->ic->flags & OPT_SLOW_LOGIN ) )
+ a->ic->keepalive = b_timeout_add( 120000, account_on_timeout, a->ic );
}
void account_off( bee_t *bee, account_t *a )
@@ -363,6 +368,16 @@ void account_off( bee_t *bee, account_t *a )
}
}
+static gboolean account_on_timeout( gpointer d, gint fd, b_input_condition cond )
+{
+ struct im_connection *ic = d;
+
+ imcb_error( ic, "Connection timeout" );
+ imc_logout( ic, TRUE );
+
+ return FALSE;
+}
+
struct account_reconnect_delay
{
int start;
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index aa3ad5bb..8fb85ea7 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -276,6 +276,7 @@ void imcb_connected( struct im_connection *ic )
imcb_log( ic, "Logged in" );
+ b_event_remove( ic->keepalive );
ic->keepalive = b_timeout_add( 60000, send_keepalive, ic );
ic->flags |= OPT_LOGGED_IN;
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index ab75ac1c..62d49e30 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -63,6 +63,7 @@
#define OPT_MOBILE 0x00000008
#define OPT_DOES_HTML 0x00000010
#define OPT_LOCALBUDDY 0x00000020 /* For nicks local to one groupchat */
+#define OPT_SLOW_LOGIN 0x00000040 /* I.e. Twitter Oauth @ login time */
#define OPT_TYPING 0x00000100 /* Some pieces of code make assumptions */
#define OPT_THINKING 0x00000200 /* about these values... Stupid me! */
#define OPT_NOOTR 0x00001000 /* protocol not suitable for OTR */
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index 083246b1..2f28f746 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -107,6 +107,10 @@ static void twitter_oauth_start( struct im_connection *ic )
imcb_log( ic, "Requesting OAuth request token" );
td->oauth_info = oauth_request_token( &twitter_oauth, twitter_oauth_callback, ic );
+
+ /* We need help from the user to complete OAuth login, so don't time
+ out on this login. */
+ ic->flags |= OPT_SLOW_LOGIN;
}
static gboolean twitter_oauth_callback( struct oauth_info *info )