# HG changeset patch # User Mark Doliner # Date 1130011764 0 # Node ID 11e95968c9fffbb613d72af323332b5b4213e4a9 # Parent 84d1145522c27b6ed910a46854ebd6524527bcab [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 diff -r 84d1145522c2 -r 11e95968c9ff src/connection.h --- 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. diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/bonjour/bonjour.c --- 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; diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/gg/gg.c --- 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; diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/irc/irc.c --- 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); } diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/jabber/presence.c --- 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) diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/msn/msn.c --- 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; diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/novell/novell.c --- 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 diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/oscar/oscar.c --- 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 diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/sametime/sametime.c --- 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); diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/silc/silc.c --- 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; diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/simple/simple.c --- 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) { diff -r 84d1145522c2 -r 11e95968c9ff src/protocols/yahoo/yahoo.c --- 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; diff -r 84d1145522c2 -r 11e95968c9ff src/prpl.c --- 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)