void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state) { GaimConnectionUiOps *ops; g_return_if_fail(gc != NULL); if (gc->state == state) return; gc->state = state; ops = gaim_get_connection_ui_ops(); if (gc->state == GAIM_CONNECTING) { connections_connecting = g_list_append(connections_connecting, gc); } else { connections_connecting = g_list_remove(connections_connecting, gc); } if (gc->state == GAIM_CONNECTED) { GaimBlistNode *gnode,*cnode,*bnode; GList *wins; GList *add_buds=NULL; /* Set the time the account came online */ time(&gc->login_time); if (ops != NULL && ops->connected != NULL) ops->connected(gc); gaim_blist_show(); gaim_blist_add_account(gc->account); /* * XXX This is a hack! Remove this and replace it with a better event * notification system. */ for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { GaimWindow *win = (GaimWindow *)wins->data; gaim_conversation_update(gaim_window_get_conversation_at(win, 0), GAIM_CONV_ACCOUNT_ONLINE); } gaim_signal_emit(gaim_connections_get_handle(), "signed-on", gc); system_log(log_signon, gc, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); #if 0 /* away option given? */ if (opt_away) { away_on_login(opt_away_arg); /* don't do it again */ opt_away = 0; } else if (awaymessage) { serv_set_away(gc, GAIM_AWAY_CUSTOM, awaymessage->message); } if (opt_away_arg != NULL) { g_free(opt_away_arg); opt_away_arg = NULL; } #endif /* let the prpl know what buddies we pulled out of the local list */ for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) continue; for(cnode = gnode->child; cnode; cnode = cnode->next) { if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) continue; for(bnode = cnode->child; bnode; bnode = bnode->next) { GaimBuddy *b; if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) continue; b = (GaimBuddy *)bnode; if(b->account == gc->account) { add_buds = g_list_append(add_buds, b->name); } } } } if(add_buds) { serv_add_buddies(gc, add_buds); g_list_free(add_buds); } serv_set_permit_deny(gc); } else if (gc->state == GAIM_DISCONNECTED) { if (ops != NULL && ops->disconnected != NULL) ops->disconnected(gc); } }
void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state) { GaimConnectionUiOps *ops; g_return_if_fail(gc != NULL); if (gc->state == state) return; gc->state = state; ops = gaim_connections_get_ui_ops(); if (gc->state == GAIM_CONNECTING) { connections_connecting = g_list_append(connections_connecting, gc); } else { connections_connecting = g_list_remove(connections_connecting, gc); } if (gc->state == GAIM_CONNECTED) { GaimAccount *account; GaimPresence *presence; account = gaim_connection_get_account(gc); presence = gaim_account_get_presence(account); /* Set the time the account came online */ gaim_presence_set_login_time(presence, time(NULL)); if (gaim_prefs_get_bool("/core/logging/log_system")) { GaimLog *log = gaim_account_get_log(account, TRUE); if (log != NULL) { char *msg = g_strdup_printf(_("+++ %s signed on"), gaim_account_get_username(account)); gaim_log_write(log, GAIM_MESSAGE_SYSTEM, gaim_account_get_username(account), gaim_presence_get_login_time(presence), msg); g_free(msg); } } if (ops != NULL && ops->connected != NULL) ops->connected(gc); gaim_blist_add_account(account); gaim_signal_emit(gaim_connections_get_handle(), "signed-on", gc); serv_set_permit_deny(gc); update_keepalive(gc, TRUE); } else if (gc->state == GAIM_DISCONNECTED) { GaimAccount *account = gaim_connection_get_account(gc); if (gaim_prefs_get_bool("/core/logging/log_system")) { GaimLog *log = gaim_account_get_log(account, FALSE); if (log != NULL) { char *msg = g_strdup_printf(_("+++ %s signed off"), gaim_account_get_username(account)); gaim_log_write(log, GAIM_MESSAGE_SYSTEM, gaim_account_get_username(account), time(NULL), msg); g_free(msg); } } gaim_account_destroy_log(account); if (ops != NULL && ops->disconnected != NULL) ops->disconnected(gc); } }