gboolean msn_directconn_connect(MsnDirectConn *directconn, const char *host, int port) { MsnSession *session; g_return_val_if_fail(directconn != NULL, FALSE); g_return_val_if_fail(host != NULL, TRUE); g_return_val_if_fail(port > 0, FALSE); session = directconn->slplink->session; #if 0 if (session->http_method) { servconn->http_data->gateway_host = g_strdup(host); } #endif directconn->connect_data = gaim_proxy_connect(NULL, session->account, host, port, connect_cb, directconn); if (directconn->connect_data != NULL) { return TRUE; } else return FALSE; }
static void gaym_login_with_chat_key(GaimAccount * account) { GaimConnection *gc; struct gaym_conn *gaym; char *buf; const char *username = gaim_account_get_username(account); int err; gc = gaim_account_get_connection(account); gaym = gc->proto_data; buf = g_strdup_printf(_("Signon: %s"), username); gaim_connection_update_progress(gc, buf, 5, 6); g_free(buf); gaim_debug_misc("gaym", "Trying login to %s\n", gaym->server); err = gaim_proxy_connect(account, gaym->server, gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), gaym_login_cb, gc); if (err || !account->gc) { gaim_connection_error(gc, _("Couldn't create socket")); gaim_debug_misc("gaym", "err: %d, account->gc: %x\n", err, account->gc); return; } }
static void irc_login(GaimAccount *account) { GaimConnection *gc; struct irc_conn *irc; char **userparts; const char *username = gaim_account_get_username(account); gc = gaim_account_get_connection(account); gc->flags |= GAIM_CONNECTION_NO_NEWLINES; if (strpbrk(username, " \t\v\r\n") != NULL) { gaim_connection_error(gc, _("IRC nicks may not contain whitespace")); return; } gc->proto_data = irc = g_new0(struct irc_conn, 1); irc->fd = -1; irc->account = account; irc->outbuf = gaim_circ_buffer_new(512); userparts = g_strsplit(username, "@", 2); gaim_connection_set_display_name(gc, userparts[0]); irc->server = g_strdup(userparts[1]); g_strfreev(userparts); irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal, NULL, (GDestroyNotify)irc_buddy_free); irc->cmds = g_hash_table_new(g_str_hash, g_str_equal); irc_cmd_table_build(irc); irc->msgs = g_hash_table_new(g_str_hash, g_str_equal); irc_msg_table_build(irc); gaim_connection_update_progress(gc, _("Connecting"), 1, 2); if (gaim_account_get_bool(account, "ssl", FALSE)) { if (gaim_ssl_is_supported()) { irc->gsc = gaim_ssl_connect(account, irc->server, gaim_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT), irc_login_cb_ssl, irc_ssl_connect_failure, gc); } else { gaim_connection_error(gc, _("SSL support unavailable")); return; } } if (!irc->gsc) { if (gaim_proxy_connect(gc, account, irc->server, gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), irc_login_cb, gc) == NULL) { gaim_connection_error(gc, _("Couldn't create socket")); return; } } }
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; }
void gaim_xfer_start(GaimXfer *xfer, int fd, const char *ip, unsigned int port) { GaimInputCondition cond; GaimXferType type; g_return_if_fail(xfer != NULL); g_return_if_fail(gaim_xfer_get_type(xfer) != GAIM_XFER_UNKNOWN); type = gaim_xfer_get_type(xfer); xfer->bytes_remaining = gaim_xfer_get_size(xfer); xfer->bytes_sent = 0; if (type == GAIM_XFER_RECEIVE) { cond = GAIM_INPUT_READ; if (ip != NULL) { xfer->remote_ip = g_strdup(ip); xfer->remote_port = port; /* Establish a file descriptor. */ gaim_proxy_connect(xfer->account, xfer->remote_ip, xfer->remote_port, connect_cb, xfer); return; } else { xfer->fd = fd; } } else { cond = GAIM_INPUT_WRITE; xfer->fd = fd; } begin_transfer(xfer, cond); }
GaimSslConnection * gaim_ssl_connect(GaimAccount *account, const char *host, int port, GaimSslInputFunction func, GaimSslErrorFunction error_func, void *data) { GaimSslConnection *gsc; g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port != 0 && port != -1, NULL); g_return_val_if_fail(func != NULL, NULL); g_return_val_if_fail(gaim_ssl_is_supported(), NULL); if (!_ssl_initialized) { if (!ssl_init()) return NULL; } gsc = g_new0(GaimSslConnection, 1); gsc->fd = -1; gsc->host = g_strdup(host); gsc->port = port; gsc->connect_cb_data = data; gsc->connect_cb = func; gsc->error_cb = error_func; gsc->connect_data = gaim_proxy_connect(NULL, account, host, port, gaim_ssl_connect_cb, gsc); if (gsc->connect_data == NULL) { g_free(gsc->host); g_free(gsc); return NULL; } return (GaimSslConnection *)gsc; }
void gaim_session_fetch(const char *url, gboolean full, const char *user_agent, gboolean http11, void (*cb) (gpointer, const char *, size_t), void *user_data, GaimUrlSession * session) { int sock; GaimFetchUrlData *gfud; g_return_if_fail(url != NULL); g_return_if_fail(cb != NULL); gaim_debug_info("gaim_session_fetch", "requested to fetch (%s), full=%d, user_agent=(%s), http11=%d\n", url, full, user_agent ? user_agent : "(null)", http11); gfud = g_new0(GaimFetchUrlData, 1); gfud->callback = cb; gfud->user_data = user_data; gfud->url = g_strdup(url); gfud->user_agent = (user_agent != NULL ? g_strdup(user_agent) : NULL); gfud->http11 = http11; gfud->full = full; gfud->session = session; gaim_url_parse(url, &gfud->website.address, &gfud->website.port, &gfud->website.page, &gfud->website.user, &gfud->website.passwd); if ((sock = gaim_proxy_connect(NULL, gfud->website.address, gfud->website.port, session_fetched_cb, gfud)) < 0) { destroy_fetch_url_data(gfud); cb(user_data, g_strdup(_("g003: Error opening connection.\n")), 0); } }