void msn_switchboard_disconnect(MsnSwitchBoard *swboard) { g_return_if_fail(swboard != NULL); msn_servconn_disconnect(swboard->servconn); }
void msn_servconn_destroy(MsnServConn *servconn) { g_return_if_fail(servconn != NULL); if (servconn->processing) { servconn->wasted = TRUE; return; } if (servconn->connected) msn_servconn_disconnect(servconn); if (servconn->destroy_cb) servconn->destroy_cb(servconn); if (servconn->httpconn != NULL) msn_httpconn_destroy(servconn->httpconn); g_free(servconn->host); gaim_circ_buffer_destroy(servconn->tx_buf); if (servconn->tx_handler > 0) gaim_input_remove(servconn->tx_handler); msn_cmdproc_destroy(servconn->cmdproc); g_free(servconn); }
static gboolean servconn_idle_timeout_cb(MsnServConn *servconn) { servconn->timeout_handle = 0; msn_servconn_disconnect(servconn); return FALSE; }
void msn_notification_disconnect(MsnNotification *notification) { g_return_if_fail(notification != NULL); g_return_if_fail(notification->in_use); msn_servconn_disconnect(notification->servconn); notification->in_use = FALSE; }
void msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error, const char *reason) { MsnSession *session = servconn->session; MsnServConnType type = servconn->type; const char *names[] = { "Notification", "Switchboard" }; const char *name; name = names[type]; if (reason == NULL) { switch (error) { case MSN_SERVCONN_ERROR_CONNECT: reason = _("Unable to connect"); break; case MSN_SERVCONN_ERROR_WRITE: reason = _("Writing error"); break; case MSN_SERVCONN_ERROR_READ: reason = _("Reading error"); break; default: reason = _("Unknown error"); break; } } purple_debug_error("msn", "Connection error from %s server (%s): %s\n", name, servconn->host, reason); if (type == MSN_SERVCONN_SB) { MsnSwitchBoard *swboard; swboard = servconn->cmdproc->data; if (swboard != NULL) swboard->error = MSN_SB_ERROR_CONNECTION; } /* servconn->disconnect_cb may destroy servconn, so don't use it again */ msn_servconn_disconnect(servconn); if (type == MSN_SERVCONN_NS) { char *tmp = g_strdup_printf(_("Connection error from %s server:\n%s"), name, reason); msn_session_set_error(session, MSN_ERROR_SERVCONN, tmp); g_free(tmp); } }
gboolean msn_servconn_connect(MsnServConn *servconn, const char *host, int port) { MsnSession *session; g_return_val_if_fail(servconn != NULL, FALSE); g_return_val_if_fail(host != NULL, FALSE); g_return_val_if_fail(port > 0, FALSE); session = servconn->session; if (servconn->connected) msn_servconn_disconnect(servconn); g_free(servconn->host); servconn->host = g_strdup(host); if (session->http_method) { /* HTTP Connection. */ if (!servconn->httpconn->connected) if (!msn_httpconn_connect(servconn->httpconn, host, port)) return FALSE;; servconn->connected = TRUE; servconn->httpconn->virgin = TRUE; /* Someone wants to know we connected. */ servconn->connect_cb(servconn); return TRUE; } servconn->connect_data = gaim_proxy_connect(NULL, session->account, host, port, connect_cb, servconn); if (servconn->connect_data != NULL) { servconn->processing = TRUE; return TRUE; } else return FALSE; }