changeset 11718:11e95968c9ff

[gaim-migrate @ 14009] PRPLs are no longer required to call gaim_account_connect() and gaim_account_disconnect()--it is done in the core. Having the PRPLs do it was kind of silly. And this should allow me to improve the auto-reconnect plugin some. I think. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 22 Oct 2005 20:09:24 +0000
parents 84d1145522c2
children 109ee3bfeac5
files src/connection.h src/protocols/bonjour/bonjour.c src/protocols/gg/gg.c src/protocols/irc/irc.c src/protocols/jabber/presence.c src/protocols/msn/msn.c src/protocols/novell/novell.c src/protocols/oscar/oscar.c src/protocols/sametime/sametime.c src/protocols/silc/silc.c src/protocols/simple/simple.c src/protocols/yahoo/yahoo.c src/prpl.c
diffstat 13 files changed, 51 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/src/connection.h	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/connection.h	Sat Oct 22 20:09:24 2005 +0000
@@ -145,7 +145,11 @@
 void gaim_connection_destroy(GaimConnection *gc);
 
 /**
- * Sets the connection state.
+ * Sets the connection state.  PRPLs should call this and pass in
+ * the state "GAIM_CONNECTED" when the account is completely
+ * signed on.  What does it mean to be completely signed on?  If
+ * the core can call prpl->set_status, and it successfully changes
+ * your status, then the account is online.
  *
  * @param gc    The connection.
  * @param state The connection state.
--- a/src/protocols/bonjour/bonjour.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/bonjour/bonjour.c	Sat Oct 22 20:09:24 2005 +0000
@@ -178,17 +178,6 @@
 	primitive = gaim_status_type_get_primitive(type);
 	presence = gaim_account_get_presence(account);
 
-	if (primitive != GAIM_STATUS_OFFLINE && disconnected)
-	{
-		gaim_account_connect(account);
-		return;
-	}
-	if (primitive == GAIM_STATUS_OFFLINE && !disconnected)
-	{
-		gaim_account_disconnect(account);
-		return;
-	}
-
 	if (!gaim_account_is_connected(account))
 		/* TODO: Does this mean we're connecting? */
 		return;
--- a/src/protocols/gg/gg.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/gg/gg.c	Sat Oct 22 20:09:24 2005 +0000
@@ -1278,16 +1278,6 @@
 	if (!gaim_status_is_active(status))
 		return;
 
-	if (prim == GAIM_STATUS_OFFLINE) {
-		gaim_account_disconnect(account);
-		return;
-	}
-
-	if (!gaim_account_is_connected(account)) {
-		gaim_account_connect(account);
-		return;
-	}
-
 	gc = gaim_account_get_connection(account);
 	info = gc->proto_data;
 
--- a/src/protocols/irc/irc.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/irc/irc.c	Sat Oct 22 20:09:24 2005 +0000
@@ -448,11 +448,7 @@
 
 	args[0] = NULL;
 
-	if (strcmp(status_id, "offline") && !gc) {
-		gaim_account_connect(account);
-	} else if (!strcmp(status_id, "offline") && gc) {
-		gaim_account_disconnect(account);
-	} else if (!strcmp(status_id, "away")) {
+	if (!strcmp(status_id, "away")) {
 		args[0] = gaim_status_get_attr_string(status, "message");
 		irc_cmd_away(irc, "away", NULL, args);
 	}
--- a/src/protocols/jabber/presence.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/jabber/presence.c	Sat Oct 22 20:09:24 2005 +0000
@@ -105,10 +105,6 @@
 	disconnected = gaim_account_is_disconnected(account);
 	primitive = gaim_status_type_get_primitive(gaim_status_get_type(status));
 
-	if(primitive != GAIM_STATUS_OFFLINE && disconnected) {
-		gaim_account_connect(account);
-	}
-
 	if(disconnected)
 		return;
 
@@ -136,10 +132,6 @@
 	xmlnode_free(presence);
 
 	jabber_presence_fake_to_self(js, status);
-
-	if(primitive == GAIM_STATUS_OFFLINE && !disconnected) {
-		gaim_account_disconnect(account);
-	}
 }
 
 xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority)
--- a/src/protocols/msn/msn.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/msn/msn.c	Sat Oct 22 20:09:24 2005 +0000
@@ -886,15 +886,7 @@
 
 	gaim_debug_info("msn", "Set status to %s\n", gaim_status_get_name(status));
 
-	if (!strcmp(state, "offline") && (gc != NULL)) {
-		gaim_account_disconnect(account);
-		return;
-	}
-	else if (strcmp(state, "offline") && (gc == NULL)) {
-		gaim_account_connect(account);
-		return;
-	}
-	else if (!strcmp(state, "away"))
+	if (!strcmp(state, "away"))
 		msnstatus = MSN_AWAY;
 	else if (!strcmp(state, "brb"))
 		msnstatus = MSN_BRB;
--- a/src/protocols/novell/novell.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/novell/novell.c	Sat Oct 22 20:09:24 2005 +0000
@@ -2987,16 +2987,10 @@
 	if (!gaim_status_is_active(status))
 		return;
 
-	if (primitive != GAIM_STATUS_OFFLINE && !connected) {
-		gaim_account_connect(account);
-	} else if (primitive == GAIM_STATUS_OFFLINE && connected) {
-		gaim_account_disconnect(account);
-	} else {
-		if (!connected)
-			return;
-
-		/* TODO: Need to do the same stuff that novell_set_away does here */
-	}
+	if (!connected)
+		return;
+
+	/* TODO: Need to do the same stuff that novell_set_away does here */
 }
 
 #if 0
--- a/src/protocols/oscar/oscar.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/oscar/oscar.c	Sat Oct 22 20:09:24 2005 +0000
@@ -6653,29 +6653,19 @@
 static void
 oscar_set_status(GaimAccount *account, GaimStatus *status)
 {
-	gboolean disconnected = gaim_account_is_disconnected(account);
-	GaimStatusType *type = gaim_status_get_type(status);
-	int primitive = gaim_status_type_get_primitive(type);
-
 	gaim_debug_info("oscar", "Set status to %s\n", gaim_status_get_name(status));
 
 	if (!gaim_status_is_active(status))
 		return;
 
-	if (primitive != GAIM_STATUS_OFFLINE && disconnected) {
-		gaim_account_connect(account);
-	} else if (primitive == GAIM_STATUS_OFFLINE && !disconnected) {
-		gaim_account_disconnect(account);
-	} else {
-		if (!gaim_account_is_connected(account))
-			return;
-
-		if (aim_sn_is_icq(gaim_account_get_username(account)))
-			oscar_set_status_icq(account, status);
-		else
-			/* QQQ - Should probably also set this for ICQ */
-			oscar_set_status_aim(account, status);
-	}
+	if (!gaim_account_is_connected(account))
+		return;
+
+	if (aim_sn_is_icq(gaim_account_get_username(account)))
+		oscar_set_status_icq(account, status);
+	else
+		/* QQQ - Should probably also set this for ICQ */
+		oscar_set_status_aim(account, status);
 }
 
 #ifdef CRAZY_WARN
--- a/src/protocols/sametime/sametime.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/sametime/sametime.c	Sat Oct 22 20:09:24 2005 +0000
@@ -3492,15 +3492,6 @@
 
   gaim_debug_info("meanwhile", "Set status to %s\n", gaim_status_get_name(status));
 
-  if (!strcmp(state, "offline") && (gc != NULL)) {
-     gaim_account_disconnect(acct);
-     return;
-  }
-  else if (strcmp(state, "offline") && (gc == NULL)) {
-     gaim_account_connect(acct);
-     return;
-  }
-
   g_return_if_fail(gc != NULL);
 
   session = gc_to_session(gc);
--- a/src/protocols/silc/silc.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/silc/silc.c	Sat Oct 22 20:09:24 2005 +0000
@@ -82,14 +82,6 @@
 	if (state == NULL)
 		return;
 
-	if (strcmp(state, "offline") && !gc) {
-		gaim_account_connect(account);
-		return;
-	} else if (!strcmp(state, "offline") && (gc != NULL)) {
-		gaim_account_disconnect(account);
-		return;
-	}
-
 	if ((sg == NULL) || (sg->conn == NULL))
 		return;
 
--- a/src/protocols/simple/simple.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/simple/simple.c	Sat Oct 22 20:09:24 2005 +0000
@@ -108,21 +108,23 @@
 static void simple_set_status(GaimAccount *account, GaimStatus *status) {
 	GaimStatusPrimitive primitive = gaim_status_type_get_primitive(gaim_status_get_type(status));
 	struct simple_account_data *sip = NULL;
+
 	if (!gaim_status_is_active(status))
 		return;
 
-	if(account->gc) sip = account->gc->proto_data;
-	if(sip) {
+	if (account->gc)
+		sip = account->gc->proto_data;
+
+	if (sip)
+	{
 		g_free(sip->status);
-		if(primitive == GAIM_STATUS_AVAILABLE) sip->status = g_strdup("available");
-		else sip->status = g_strdup("busy");
+		if (primitive == GAIM_STATUS_AVAILABLE)
+			sip->status = g_strdup("available");
+		else
+			sip->status = g_strdup("busy");
 
 		do_notifies(sip);
 	}
-	if ((primitive != GAIM_STATUS_OFFLINE)
-			&& (!gaim_account_is_connected(account))) {
-		gaim_account_connect(account);
-	}
 }
 
 static struct sip_connection *connection_find(struct simple_account_data *sip, int fd) {
--- a/src/protocols/yahoo/yahoo.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sat Oct 22 20:09:24 2005 +0000
@@ -3042,7 +3042,6 @@
 static void yahoo_set_status(GaimAccount *account, GaimStatus *status)
 {
 	GaimConnection *gc = gaim_account_get_connection(account);
-	gboolean disconnected = gaim_account_is_disconnected(account);
 	struct yahoo_data *yd;
 	struct yahoo_packet *pkt;
 	int old_status;
@@ -3053,13 +3052,6 @@
 	id = gaim_status_get_id(status);
 	if (!gaim_status_is_active(status))
 		return;
-	if (strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && disconnected) {
-		gaim_account_connect(account);
-		return;
-	} else if (!strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && !disconnected) {
-		gaim_account_disconnect(account);
-		return;
-	}
 
 	if (!gaim_account_is_connected(account))
 		return;
--- a/src/prpl.c	Sat Oct 22 19:56:02 2005 +0000
+++ b/src/prpl.c	Sat Oct 22 20:09:24 2005 +0000
@@ -289,6 +289,28 @@
 	g_return_if_fail(old_status != NULL);
 	g_return_if_fail(new_status != NULL);
 
+	if (gaim_account_is_connecting(account))
+		/*
+		 * We don't need to call the set_status PRPL function because
+		 * the PRPL will take care of setting its status during the
+		 * connection process.
+		 */
+		return;
+
+	if (gaim_status_is_online(new_status) &&
+		gaim_account_is_disconnected(account))
+	{
+		gaim_account_connect(account);
+		return;
+	}
+
+	if (!gaim_status_is_online(new_status) &&
+			 !gaim_account_is_disconnected(account))
+	{
+		gaim_account_disconnect(account);
+		return;
+	}
+
 	prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
 
 	if (prpl == NULL)