pidgin: 6fd13fcd: Add a timeout which forces the login pro...

qulogic at pidgin.im qulogic at pidgin.im
Sat Jul 17 20:52:36 EDT 2010


----------------------------------------------------------------------
Revision: 6fd13fcd41c95794bed286994ba8dc779da0aa01
Parent:   f38dff3ad576d850f799c5f1624565060546323b
Author:   qulogic at pidgin.im
Date:     07/17/10 19:10:39
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6fd13fcd41c95794bed286994ba8dc779da0aa01

Changelog: 

Add a timeout which forces the login process to complete. This won't
fix the underlying problem of a failed FQY, but at least it will
complete the connection and show people online.

Refs #10023.
Refs #12210.

Changes against parent f38dff3ad576d850f799c5f1624565060546323b

  patched  libpurple/protocols/msn/notification.c
  patched  libpurple/protocols/msn/session.c
  patched  libpurple/protocols/msn/session.h

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/notification.c	fc71e11bcde07d83376358db8174a7d71ab79b79
+++ libpurple/protocols/msn/notification.c	b9288160a2e508af36da3203d01e8587a54ea918
@@ -674,6 +674,8 @@ msn_notification_dump_contact(MsnSession
 	xmlnode_free(adl_node);
 	xmlnode_free(fqy_node);
 
+	msn_session_activate_login_timeout(session);
+
 	pc = purple_account_get_connection(session->account);
 	display_name = purple_connection_get_display_name(pc);
 	if (display_name
============================================================
--- libpurple/protocols/msn/session.c	ca42a1d350eee0cf5e7efff0de5a2fb6d8eb10dd
+++ libpurple/protocols/msn/session.c	5dc761eceb3f62b2d9b6ca39b778b4d2f344b1c7
@@ -131,6 +131,11 @@ msn_session_disconnect(MsnSession *sessi
 	if (!session->connected)
 		return;
 
+	if (session->login_timeout) {
+		purple_timeout_remove(session->login_timeout);
+		session->login_timeout = 0;
+	}
+
 	session->connected = FALSE;
 
 	while (session->switches != NULL)
@@ -258,6 +263,28 @@ msn_session_get_swboard(MsnSession *sess
 	return swboard;
 }
 
+static gboolean
+msn_login_timeout_cb(gpointer data)
+{
+	MsnSession *session = data;
+	/* This forces the login process to finish, even though we haven't heard
+	   a response for our FQY requests yet. We'll at least end up online to the
+	   people we've already added. The rest will follow later. */
+	msn_session_finish_login(session);
+	session->login_timeout = 0;
+	return FALSE;
+}
+
+void
+msn_session_activate_login_timeout(MsnSession *session)
+{
+	if (!session->logged_in) {
+		session->login_timeout =
+			purple_timeout_add_seconds(MSN_LOGIN_FQY_TIMEOUT,
+			                           msn_login_timeout_cb, session);
+	}
+}
+
 static void
 msn_session_sync_users(MsnSession *session)
 {
============================================================
--- libpurple/protocols/msn/session.h	1bb2cb4677ad0100d5a95dcc33c06a501e9255c0
+++ libpurple/protocols/msn/session.h	ab1581b4479bd685479a2ad74a281cf8427a45c9
@@ -59,6 +59,8 @@ typedef enum
 
 #define MSN_LOGIN_STEPS MSN_LOGIN_STEP_END
 
+#define MSN_LOGIN_FQY_TIMEOUT 30
+
 #include "group.h"
 #include "httpconn.h"
 #include "nexus.h"
@@ -83,6 +85,7 @@ struct _MsnSession
 	gboolean connected;
 	gboolean logged_in; /**< A temporal flag to ignore local buddy list adds. */
 	int      adl_fqy; /**< A count of ADL/FQY so status is only changed once. */
+	guint    login_timeout; /**< Timeout to force status change if ADL/FQY fail. */
 	gboolean destroying; /**< A flag that states if the session is being destroyed. */
 	gboolean http_method;
 
@@ -213,9 +216,18 @@ void msn_session_set_error(MsnSession *s
 						   const char *info);
 
 /**
- * Sets the current step in the login proccess.
+ * Starts a timeout to initiate finishing login. Sometimes the server ignores
+ * our FQY requests, so this forces ourselves online eventually.
  *
  * @param session The MSN session.
+ */
+void
+msn_session_activate_login_timeout(MsnSession *session);
+
+/**
+ * Sets the current step in the login process.
+ *
+ * @param session The MSN session.
  * @param step The current step.
  */
 void msn_session_set_login_step(MsnSession *session, MsnLoginStep step);


More information about the Commits mailing list