From: <the...@us...> - 2006-08-14 08:36:38
|
Revision: 16756 Author: thekingant Date: 2006-08-14 01:36:25 -0700 (Mon, 14 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16756&view=rev Log Message: ----------- Alright, backport SVN revisions 16742 through 16755 from HEAD to v2_0_0 This was mostly my changes to protocols to use gaim_proxy_connect_cancel() Modified Paths: -------------- branches/v2_0_0/plugins/ChangeLog.API branches/v2_0_0/src/connection.h branches/v2_0_0/src/ft.c branches/v2_0_0/src/protocols/irc/irc.c branches/v2_0_0/src/protocols/irc/irc.h branches/v2_0_0/src/protocols/jabber/jabber.c branches/v2_0_0/src/protocols/jabber/jabber.h branches/v2_0_0/src/protocols/jabber/si.c branches/v2_0_0/src/protocols/msn/directconn.c branches/v2_0_0/src/protocols/msn/directconn.h branches/v2_0_0/src/protocols/msn/httpconn.c branches/v2_0_0/src/protocols/msn/httpconn.h branches/v2_0_0/src/protocols/msn/servconn.c branches/v2_0_0/src/protocols/msn/servconn.h branches/v2_0_0/src/protocols/oscar/flap_connection.c branches/v2_0_0/src/protocols/oscar/oscar.c branches/v2_0_0/src/protocols/oscar/oscar.h branches/v2_0_0/src/protocols/oscar/peer.c branches/v2_0_0/src/protocols/oscar/peer.h branches/v2_0_0/src/protocols/oscar/peer_proxy.c branches/v2_0_0/src/protocols/sametime/sametime.c branches/v2_0_0/src/protocols/silc/silc.c branches/v2_0_0/src/protocols/silc/silcgaim.h branches/v2_0_0/src/protocols/simple/simple.c branches/v2_0_0/src/protocols/toc/toc.c branches/v2_0_0/src/protocols/yahoo/yahoo.c branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c branches/v2_0_0/src/protocols/yahoo/yahoochat.c branches/v2_0_0/src/protocols/yahoo/ycht.c branches/v2_0_0/src/proxy.c branches/v2_0_0/src/proxy.h branches/v2_0_0/src/sslconn.c branches/v2_0_0/src/upnp.c branches/v2_0_0/src/util.c Modified: branches/v2_0_0/plugins/ChangeLog.API =================================================================== --- branches/v2_0_0/plugins/ChangeLog.API 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/plugins/ChangeLog.API 2006-08-14 08:36:25 UTC (rev 16756) @@ -114,9 +114,9 @@ * All network activity has been updated to use non-blocking sockets. This means that plugins must be updated to expect such a socket from gaim_proxy_connect() and gaim_network_listen*(). - * gaim_proxy_connect(): changed to return NULL on error and a void * - handle on success, and changed parameters. It is now possible to - cancel connection attempts. + * gaim_proxy_connect(): changed to return NULL on error and a pointer + to a GaimProxyConnectInfo object which can be used to cancel + connection attempts using gaim_proxy_connect_cancel(). * gaim_gtk_create_imhtml(): Added sw_ret() parameter * gaim_account_get_log(): Added create parameter * GAIM_CMD_P_VERYHIGH is now GAIM_CMD_P_VERY_HIGH Modified: branches/v2_0_0/src/connection.h =================================================================== --- branches/v2_0_0/src/connection.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/connection.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -271,6 +271,10 @@ * * @return @c TRUE if gc is valid. */ +/* + * TODO: Eventually this bad boy will be removed, because it is + * a gross fix for a crashy problem. + */ #define GAIM_CONNECTION_IS_VALID(gc) (g_list_find(gaim_connections_get_all(), (gc))) /*@}*/ Modified: branches/v2_0_0/src/ft.c =================================================================== --- branches/v2_0_0/src/ft.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/ft.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -911,7 +911,7 @@ } static void -connect_cb(gpointer data, gint source) +connect_cb(gpointer data, gint source, const gchar *error_message) { GaimXfer *xfer = (GaimXfer *)data; @@ -946,7 +946,7 @@ /* Establish a file descriptor. */ gaim_proxy_connect(xfer->account, xfer->remote_ip, - xfer->remote_port, connect_cb, NULL, xfer); + xfer->remote_port, connect_cb, xfer); return; } Modified: branches/v2_0_0/src/protocols/irc/irc.c =================================================================== --- branches/v2_0_0/src/protocols/irc/irc.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/irc/irc.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -46,7 +46,7 @@ /* static GList *irc_chat_info(GaimConnection *gc); */ static void irc_login(GaimAccount *account); static void irc_login_cb_ssl(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond); -static void irc_login_cb(gpointer data, gint source); +static void irc_login_cb(gpointer data, gint source, const gchar *error_message); static void irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, gpointer data); static void irc_close(GaimConnection *gc); static int irc_im_send(GaimConnection *gc, const char *who, const char *what, GaimMessageFlags flags); @@ -283,7 +283,6 @@ struct irc_conn *irc; char **userparts; const char *username = gaim_account_get_username(account); - GaimProxyConnectInfo *connect_info; gc = gaim_account_get_connection(account); gc->flags |= GAIM_CONNECTION_NO_NEWLINES; @@ -325,11 +324,11 @@ if (!irc->gsc) { - connect_info = gaim_proxy_connect(account, irc->server, + irc->connect_info = gaim_proxy_connect(account, irc->server, gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), - irc_login_cb, NULL, gc); + irc_login_cb, gc); - if (!connect_info || !gaim_account_get_connection(account)) { + if (!irc->connect_info || !gaim_account_get_connection(account)) { gaim_connection_error(gc, _("Couldn't create socket")); return; } @@ -394,22 +393,18 @@ } } -static void irc_login_cb(gpointer data, gint source) +static void irc_login_cb(gpointer data, gint source, const gchar *error_message) { GaimConnection *gc = data; struct irc_conn *irc = gc->proto_data; - GList *connections = gaim_connections_get_all(); + irc->connect_info = NULL; + if (source < 0) { gaim_connection_error(gc, _("Couldn't connect to host")); return; } - if (!g_list_find(connections, gc)) { - close(source); - return; - } - irc->fd = source; if (do_login(gc)) { @@ -443,8 +438,12 @@ if (irc == NULL) return; - irc_cmd_quit(irc, "quit", NULL, NULL); + if (irc->gsc || (irc->fd >= 0)) + irc_cmd_quit(irc, "quit", NULL, NULL); + if (irc->connect_info) + gaim_proxy_connect_cancel(irc->connect_info); + if (gc->inpa) gaim_input_remove(gc->inpa); Modified: branches/v2_0_0/src/protocols/irc/irc.h =================================================================== --- branches/v2_0_0/src/protocols/irc/irc.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/irc/irc.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -54,6 +54,8 @@ guint timer; GHashTable *buddies; + GaimProxyConnectInfo *connect_info; + char *inbuf; int inbuflen; int inbufused; Modified: branches/v2_0_0/src/protocols/jabber/jabber.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/jabber.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/jabber/jabber.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -30,6 +30,7 @@ #include "message.h" #include "notify.h" #include "pluginpref.h" +#include "proxy.h" #include "prpl.h" #include "request.h" #include "server.h" @@ -418,21 +419,18 @@ static void -jabber_login_callback(gpointer data, gint source) +jabber_login_callback(gpointer data, gint source, const gchar *error) { GaimConnection *gc = data; JabberStream *js = gc->proto_data; + js->connect_info = NULL; + if (source < 0) { gaim_connection_error(gc, _("Couldn't connect to host")); return; } - if(!g_list_find(gaim_connections_get_all(), gc)) { - close(source); - return; - } - js->fd = source; if(js->state == JABBER_STREAM_CONNECTING) @@ -471,12 +469,10 @@ static void jabber_login_connect(JabberStream *js, const char *server, int port) { - GaimProxyConnectInfo *connect_info; + js->connect_info = gaim_proxy_connect(js->gc->account, server, + port, jabber_login_callback, js->gc); - connect_info = gaim_proxy_connect(js->gc->account, server, - port, jabber_login_callback, NULL, js->gc); - - if (connect_info == NULL) + if (js->connect_info == NULL) gaim_connection_error(js->gc, _("Unable to create socket")); } @@ -859,7 +855,6 @@ const char *connect_server = gaim_account_get_string(account, "connect_server", ""); const char *server; - GaimProxyConnectInfo *connect_info; js = gc->proto_data = g_new0(JabberStream, 1); js->gc = gc; @@ -909,11 +904,11 @@ } if(!js->gsc) { - connect_info = gaim_proxy_connect(account, server, + js->connect_info = gaim_proxy_connect(account, server, gaim_account_get_int(account, "port", 5222), - jabber_login_callback, NULL, gc); + jabber_login_callback, gc); - if (connect_info == NULL) + if (js->connect_info == NULL) gaim_connection_error(gc, _("Unable to create socket")); } } @@ -929,6 +924,9 @@ if (!gc->disconnect_timeout) jabber_send_raw(js, "</stream:stream>", -1); + if (js->connect_info) + gaim_proxy_connect_cancel(js->connect_info); + if(js->gsc) { #ifdef HAVE_OPENSSL if (!gc->disconnect_timeout) Modified: branches/v2_0_0/src/protocols/jabber/jabber.h =================================================================== --- branches/v2_0_0/src/protocols/jabber/jabber.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/jabber/jabber.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -67,6 +67,8 @@ { int fd; + GaimProxyConnectInfo *connect_info; + #ifdef HAVE_LIBXML xmlParserCtxt *context; #else Modified: branches/v2_0_0/src/protocols/jabber/si.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/si.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/jabber/si.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -46,6 +46,8 @@ typedef struct _JabberSIXfer { JabberStream *js; + GaimProxyConnectInfo *connect_info; + gboolean accepted; char *stream_id; @@ -88,7 +90,8 @@ static void jabber_si_bytestreams_attempt_connect(GaimXfer *xfer); -static void jabber_si_bytestreams_connect_cb(gpointer data, gint source) +static void +jabber_si_bytestreams_connect_cb(gpointer data, gint source, const gchar *error_message) { GaimXfer *xfer = data; JabberSIXfer *jsx = xfer->data; @@ -97,6 +100,7 @@ struct bytestreams_streamhost *streamhost = jsx->streamhosts->data; gaim_proxy_info_destroy(jsx->gpi); + jsx->connect_info = NULL; if(source < 0) { jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); @@ -167,8 +171,18 @@ for(i=0; i<20; i++, p+=2) snprintf(p, 3, "%02x", hashval[i]); - gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, jabber_si_bytestreams_connect_cb, NULL, xfer); + jsx->connect_info = gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, + jabber_si_bytestreams_connect_cb, xfer); g_free(dstaddr); + + if (jsx->connect_info == NULL) + { + jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost); + g_free(streamhost->jid); + g_free(streamhost->host); + g_free(streamhost); + jabber_si_bytestreams_attempt_connect(xfer); + } } void jabber_bytestreams_parse(JabberStream *js, xmlnode *packet) @@ -682,6 +696,9 @@ js->file_transfers = g_list_remove(js->file_transfers, xfer); + if (jsx->connect_info != NULL) + gaim_proxy_connect_cancel(jsx->connect_info); + g_free(jsx->stream_id); g_free(jsx->iq_id); /* XXX: free other stuff */ Modified: branches/v2_0_0/src/protocols/msn/directconn.c =================================================================== --- branches/v2_0_0/src/protocols/msn/directconn.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/msn/directconn.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -288,11 +288,6 @@ /* ERROR */ gaim_debug_error("msn", "error reading\n"); - if (directconn->inpa) - gaim_input_remove(directconn->inpa); - - close(directconn->fd); - msn_directconn_destroy(directconn); return; @@ -307,11 +302,6 @@ /* ERROR */ gaim_debug_error("msn", "error reading\n"); - if (directconn->inpa) - gaim_input_remove(directconn->inpa); - - close(directconn->fd); - msn_directconn_destroy(directconn); return; @@ -358,17 +348,12 @@ /* ERROR */ gaim_debug_error("msn", "error reading\n"); - if (directconn->inpa) - gaim_input_remove(directconn->inpa); - - close(directconn->fd); - msn_directconn_destroy(directconn); } } static void -connect_cb(gpointer data, gint source) +connect_cb(gpointer data, gint source, const gchar *error_message) { MsnDirectConn* directconn; int fd; @@ -376,6 +361,7 @@ gaim_debug_misc("msn", "directconn: connect_cb: %d\n", source); directconn = data; + directconn->connect_info = NULL; if (TRUE) { @@ -423,7 +409,6 @@ msn_directconn_connect(MsnDirectConn *directconn, const char *host, int port) { MsnSession *session; - GaimProxyConnectInfo *connect_info; g_return_val_if_fail(directconn != NULL, FALSE); g_return_val_if_fail(host != NULL, TRUE); @@ -438,10 +423,10 @@ } #endif - connect_info = gaim_proxy_connect(session->account, host, port, - connect_cb, NULL, directconn); + directconn->connect_info = gaim_proxy_connect(session->account, host, port, + connect_cb, directconn); - if (connect_info != NULL) + if (directconn->connect_info != NULL) { return TRUE; } @@ -491,6 +476,15 @@ void msn_directconn_destroy(MsnDirectConn *directconn) { + if (directconn->connect_info != NULL) + gaim_proxy_connect_cancel(directconn->connect_info); + + if (directconn->inpa != 0) + gaim_input_remove(directconn->inpa); + + if (directconn->fd >= 0) + close(directconn->fd); + if (directconn->nonce != NULL) g_free(directconn->nonce); Modified: branches/v2_0_0/src/protocols/msn/directconn.h =================================================================== --- branches/v2_0_0/src/protocols/msn/directconn.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/msn/directconn.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -35,6 +35,8 @@ MsnSlpLink *slplink; MsnSlpCall *initial_call; + GaimProxyConnectInfo *connect_info; + gboolean acked; char *nonce; Modified: branches/v2_0_0/src/protocols/msn/httpconn.c =================================================================== --- branches/v2_0_0/src/protocols/msn/httpconn.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/msn/httpconn.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -693,21 +693,12 @@ } static void -connect_cb(gpointer data, gint source) +connect_cb(gpointer data, gint source, const gchar *error_message) { - MsnHttpConn *httpconn = data; + MsnHttpConn *httpconn; - /* - TODO: Need to do this in case the account is disabled while connecting - if (!g_list_find(gaim_connections_get_all(), gc)) - { - if (source >= 0) - close(source); - destroy_new_conn_data(new_conn_data); - return; - } - */ - + httpconn = data; + httpconn->connect_info = NULL; httpconn->fd = source; if (source >= 0) @@ -729,8 +720,6 @@ gboolean msn_httpconn_connect(MsnHttpConn *httpconn, const char *host, int port) { - GaimProxyConnectInfo *connect_info; - g_return_val_if_fail(httpconn != NULL, FALSE); g_return_val_if_fail(host != NULL, FALSE); g_return_val_if_fail(port > 0, FALSE); @@ -738,10 +727,10 @@ if (httpconn->connected) msn_httpconn_disconnect(httpconn); - connect_info = gaim_proxy_connect(httpconn->session->account, - "gateway.messenger.hotmail.com", 80, connect_cb, NULL, httpconn); + httpconn->connect_info = gaim_proxy_connect(httpconn->session->account, + "gateway.messenger.hotmail.com", 80, connect_cb, httpconn); - if (connect_info != NULL) + if (httpconn->connect_info != NULL) { httpconn->waiting_response = TRUE; httpconn->connected = TRUE; @@ -758,11 +747,18 @@ if (!httpconn->connected) return; + if (httpconn->connect_info != NULL) + { + gaim_proxy_connect_cancel(httpconn->connect_info); + httpconn->connect_info = NULL; + } + if (httpconn->timer) + { gaim_timeout_remove(httpconn->timer); + httpconn->timer = 0; + } - httpconn->timer = 0; - if (httpconn->inpa > 0) { gaim_input_remove(httpconn->inpa); @@ -770,6 +766,7 @@ } close(httpconn->fd); + httpconn->fd = -1; g_free(httpconn->rx_buf); httpconn->rx_buf = NULL; Modified: branches/v2_0_0/src/protocols/msn/httpconn.h =================================================================== --- branches/v2_0_0/src/protocols/msn/httpconn.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/msn/httpconn.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -37,6 +37,8 @@ MsnSession *session; /**< The MSN Session. */ MsnServConn *servconn; /**< The connection object. */ + GaimProxyConnectInfo *connect_info; + char *full_session_id; /**< The full session id. */ char *session_id; /**< The trimmed session id. */ Modified: branches/v2_0_0/src/protocols/msn/servconn.c =================================================================== --- branches/v2_0_0/src/protocols/msn/servconn.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/msn/servconn.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -166,10 +166,12 @@ **************************************************************************/ static void -connect_cb(gpointer data, gint source) +connect_cb(gpointer data, gint source, const gchar *error_message) { - MsnServConn *servconn = data; + MsnServConn *servconn; + servconn = data; + servconn->connect_info = NULL; servconn->processing = FALSE; if (servconn->wasted) @@ -199,7 +201,6 @@ msn_servconn_connect(MsnServConn *servconn, const char *host, int port) { MsnSession *session; - GaimProxyConnectInfo *connect_info; g_return_val_if_fail(servconn != NULL, FALSE); g_return_val_if_fail(host != NULL, FALSE); @@ -232,10 +233,10 @@ return TRUE; } - connect_info = gaim_proxy_connect(session->account, host, port, - connect_cb, NULL, servconn); + servconn->connect_info = gaim_proxy_connect(session->account, host, port, + connect_cb, servconn); - if (connect_info != NULL) + if (servconn->connect_info != NULL) { servconn->processing = TRUE; return TRUE; @@ -267,6 +268,12 @@ return; } + if (servconn->connect_info != NULL) + { + gaim_proxy_connect_cancel(servconn->connect_info); + servconn->connect_info = NULL; + } + if (servconn->inpa > 0) { gaim_input_remove(servconn->inpa); Modified: branches/v2_0_0/src/protocols/msn/servconn.h =================================================================== --- branches/v2_0_0/src/protocols/msn/servconn.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/msn/servconn.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -63,6 +63,8 @@ MsnSession *session; /**< The MSN session of this connection. */ MsnCmdProc *cmdproc; /**< The command processor of this connection. */ + GaimProxyConnectInfo *connect_info; + gboolean connected; /**< A flag that states if it's connected. */ gboolean processing; /**< A flag that states if something is working with this connection. */ Modified: branches/v2_0_0/src/protocols/oscar/flap_connection.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/flap_connection.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/oscar/flap_connection.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -21,6 +21,7 @@ #include "oscar.h" #include "eventloop.h" +#include "proxy.h" #ifndef _WIN32 #include <netdb.h> @@ -131,21 +132,37 @@ /** * Close (but not free) a connection. * - * This leaves everything untouched except for setting the fd - * to -1 (used to recognize dead connections). + * This cancels any currently pending connection attempt, + * closes any open fd and frees the auth cookie. * * @param conn The connection to close. */ void flap_connection_close(OscarData *od, FlapConnection *conn) { - if (conn->fd == -1) - return; + if (conn->connect_info != NULL) + { + gaim_proxy_connect_cancel(conn->connect_info); + conn->connect_info = NULL; + } - if (conn->type == SNAC_FAMILY_LOCATE) - flap_connection_send_close(od, conn); + if (conn->connect_data != NULL) + { + if (conn->type == SNAC_FAMILY_CHAT) + { + oscar_chat_destroy(conn->connect_data); + conn->connect_data = NULL; + } + } - close(conn->fd); + if (conn->fd != -1) + { + if (conn->type == SNAC_FAMILY_LOCATE) + flap_connection_send_close(od, conn); + + close(conn->fd); + conn->fd = -1; + } } static void @@ -188,6 +205,8 @@ flap_connection_close(od, conn); + g_free(conn->cookie); + if (conn->watcher_incoming != 0) gaim_input_remove(conn->watcher_incoming); if (conn->watcher_outgoing != 0) Modified: branches/v2_0_0/src/protocols/oscar/oscar.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/oscar.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/oscar/oscar.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -76,35 +76,11 @@ static guint8 features_icq_offline[] = {0x01}; static guint8 ck[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -typedef struct _NewFlapConnectionData NewFlapConnectionData; -struct _NewFlapConnectionData -{ - GaimConnection *gc; - FlapConnection *conn; - guint16 cookielen; - guint8 *cookie; - gpointer data; -}; - struct create_room { char *name; int exchange; }; -struct chat_connection -{ - char *name; - char *show; /* AOL did something funny to us */ - guint16 exchange; - guint16 instance; - FlapConnection *conn; - int id; - GaimConnection *gc; /* i hate this. */ - GaimConversation *conv; /* bah. */ - int maxlen; - int maxvis; -}; - struct oscar_ask_directim_data { OscarData *od; @@ -903,7 +879,7 @@ return NULL; } -static void +void oscar_chat_destroy(struct chat_connection *cc) { g_free(cc->name); @@ -925,46 +901,25 @@ oscar_chat_destroy(cc); } -static void -destroy_new_conn_data(NewFlapConnectionData *new_conn_data) -{ - if ((new_conn_data->data != NULL) && - (new_conn_data->conn->type == SNAC_FAMILY_CHAT)) - { - oscar_chat_destroy(new_conn_data->data); - } - g_free(new_conn_data->cookie); - g_free(new_conn_data); -} - /** * This is the callback function anytime gaim_proxy_connect() * establishes a new TCP connection with an oscar host. Depending * on the type of host, we do a few different things here. */ static void -connection_established_cb(gpointer data, gint source) +connection_established_cb(gpointer data, gint source, const gchar *error_message) { - NewFlapConnectionData *new_conn_data; GaimConnection *gc; OscarData *od; GaimAccount *account; FlapConnection *conn; - new_conn_data = data; - gc = new_conn_data->gc; - - if (!GAIM_CONNECTION_IS_VALID(gc)) - { - if (source >= 0) - close(source); - destroy_new_conn_data(new_conn_data); - return; - } - - od = gc->proto_data; + conn = data; + od = conn->od; + gc = od->gc; account = gaim_connection_get_account(gc); - conn = new_conn_data->conn; + + conn->connect_info = NULL; conn->fd = source; if (source < 0) @@ -978,7 +933,6 @@ else /* Maybe we should call this for BOS connections, too? */ flap_connection_schedule_destroy(conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); - destroy_new_conn_data(new_conn_data); return; } @@ -986,7 +940,7 @@ conn->type); conn->watcher_incoming = gaim_input_add(conn->fd, GAIM_INPUT_READ, flap_connection_recv_cb, conn); - if (new_conn_data->cookie == NULL) + if (conn->cookie == NULL) { if (!aim_sn_is_icq(gaim_account_get_username(account))) /* @@ -997,8 +951,12 @@ flap_connection_send_version(od, conn); } else + { flap_connection_send_version_with_cookie(od, conn, - new_conn_data->cookielen, new_conn_data->cookie); + conn->cookielen, conn->cookie); + g_free(conn->cookie); + conn->cookie = NULL; + } if (conn->type == SNAC_FAMILY_AUTH) { @@ -1014,11 +972,9 @@ } else if (conn->type == SNAC_FAMILY_CHAT) { - od->oscar_chats = g_slist_append(od->oscar_chats, new_conn_data->data); - new_conn_data->data = NULL; + od->oscar_chats = g_slist_append(od->oscar_chats, conn->connect_data); + conn->connect_data = NULL; } - - destroy_new_conn_data(new_conn_data); } static void @@ -1152,7 +1108,7 @@ { GaimConnection *gc; OscarData *od; - NewFlapConnectionData *new_conn_data; + FlapConnection *newconn; gc = gaim_account_get_connection(account); od = gc->proto_data = oscar_data_new(); @@ -1240,17 +1196,12 @@ /* Connect to core Gaim signals */ gaim_prefs_connect_callback(gc, "/plugins/prpl/oscar/recent_buddies", recent_buddies_cb, gc); - new_conn_data = g_new(NewFlapConnectionData, 1); - new_conn_data->gc = gc; - new_conn_data->conn = flap_connection_new(od, SNAC_FAMILY_AUTH); - new_conn_data->cookielen = 0; - new_conn_data->cookie = NULL; - new_conn_data->data = NULL; - - if (gaim_proxy_connect(account, + newconn = flap_connection_new(od, SNAC_FAMILY_AUTH); + newconn->connect_info = gaim_proxy_connect(account, gaim_account_get_string(account, "server", OSCAR_DEFAULT_LOGIN_SERVER), gaim_account_get_int(account, "port", OSCAR_DEFAULT_LOGIN_PORT), - connection_established_cb, NULL, new_conn_data) == NULL) + connection_established_cb, newconn); + if (newconn->connect_info == NULL) { gaim_connection_error(gc, _("Couldn't connect to host")); return; @@ -1295,8 +1246,7 @@ GaimAccount *account = gc->account; char *host; int port; int i; - GaimProxyConnectInfo *connect_info; - NewFlapConnectionData *new_conn_data; + FlapConnection *newconn; va_list ap; struct aim_authresp_info *info; @@ -1361,16 +1311,14 @@ } } host = g_strndup(info->bosip, i); - new_conn_data = g_new(NewFlapConnectionData, 1); - new_conn_data->gc = gc; - new_conn_data->conn = flap_connection_new(od, SNAC_FAMILY_LOCATE); - new_conn_data->cookielen = info->cookielen; - new_conn_data->cookie = g_memdup(info->cookie, info->cookielen); - new_conn_data->data = NULL; - connect_info = gaim_proxy_connect(gc->account, host, port, - connection_established_cb, NULL, new_conn_data); + newconn = flap_connection_new(od, SNAC_FAMILY_LOCATE); + newconn->cookielen = info->cookielen; + newconn->cookie = g_memdup(info->cookie, info->cookielen); + newconn->connect_info = gaim_proxy_connect(account, host, port, + connection_established_cb, newconn); g_free(host); - if (connect_info == NULL) { + if (newconn->connect_info == NULL) + { gaim_connection_error(gc, _("Could Not Connect")); od->killme = TRUE; return 0; @@ -1482,11 +1430,18 @@ } static void -straight_to_hell(gpointer data, gint source) +straight_to_hell(gpointer data, gint source, const gchar *error_message) { struct pieceofcrap *pos = data; gchar *buf; + if (!GAIM_CONNECTION_IS_VALID(pos->gc)) + { + g_free(pos->modname); + g_free(pos); + return; + } + pos->fd = source; if (source < 0) { @@ -1496,8 +1451,7 @@ _("Gaim was unable to get a valid AIM login hash."), buf); g_free(buf); - if (pos->modname) - g_free(pos->modname); + g_free(pos->modname); g_free(pos); return; } @@ -1506,8 +1460,7 @@ pos->offset, pos->len, pos->modname ? pos->modname : ""); write(pos->fd, buf, strlen(buf)); g_free(buf); - if (pos->modname) - g_free(pos->modname); + g_free(pos->modname); pos->inpa = gaim_input_add(pos->fd, GAIM_INPUT_READ, damn_you, pos); return; } @@ -1573,8 +1526,9 @@ pos->len = len; pos->modname = g_strdup(modname); + /* TODO: Keep track of this return value. */ if (gaim_proxy_connect(pos->gc->account, "gaim.sourceforge.net", 80, - straight_to_hell, NULL, pos) == NULL) + straight_to_hell, pos) == NULL) { char buf[256]; if (pos->modname) @@ -1622,7 +1576,7 @@ GaimAccount *account = gaim_connection_get_account(gc); char *host, *separator; int port; - NewFlapConnectionData *new_conn_data; + FlapConnection *newconn; va_list ap; struct aim_redirect_data *redir; @@ -1642,36 +1596,30 @@ gaim_debug_info("oscar", "Connecting to FLAP server %s:%d of type 0x%04hx\n", host, port, redir->group); - new_conn_data = g_new(NewFlapConnectionData, 1); - new_conn_data->gc = gc; - new_conn_data->conn = flap_connection_new(od, redir->group); - new_conn_data->cookielen = redir->cookielen; - new_conn_data->cookie = g_memdup(redir->cookie, redir->cookielen); - if (new_conn_data->conn->type == SNAC_FAMILY_CHAT) + newconn = flap_connection_new(od, redir->group); + newconn->cookielen = redir->cookielen; + newconn->cookie = g_memdup(redir->cookie, redir->cookielen); + if (newconn->type == SNAC_FAMILY_CHAT) { struct chat_connection *cc; cc = g_new0(struct chat_connection, 1); - cc->conn = new_conn_data->conn; + cc->conn = newconn; cc->gc = gc; cc->name = g_strdup(redir->chat.room); cc->exchange = redir->chat.exchange; cc->instance = redir->chat.instance; cc->show = extract_name(redir->chat.room); - new_conn_data->data = cc; + newconn->connect_data = cc; gaim_debug_info("oscar", "Connecting to chat room %s exchange %hu\n", cc->name, cc->exchange); } - else - { - new_conn_data->data = NULL; - } - if (gaim_proxy_connect(account, host, port, connection_established_cb, NULL, new_conn_data) == NULL) + newconn->connect_info = gaim_proxy_connect(account, host, port, + connection_established_cb, newconn); + if (newconn->connect_info == NULL) { - flap_connection_schedule_destroy(new_conn_data->conn, - OSCAR_DISCONNECT_COULD_NOT_CONNECT); + flap_connection_schedule_destroy(newconn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); gaim_debug_error("oscar", "Unable to connect to FLAP server " "of type 0x%04hx\n", redir->group); - destroy_new_conn_data(new_conn_data); } g_free(host); Modified: branches/v2_0_0/src/protocols/oscar/oscar.h =================================================================== --- branches/v2_0_0/src/protocols/oscar/oscar.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/oscar/oscar.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -33,6 +33,7 @@ #include "debug.h" #include "eventloop.h" #include "internal.h" +#include "proxy.h" #include <stdio.h> #include <string.h> @@ -366,6 +367,12 @@ guint destroy_timeout; OscarDisconnectReason disconnect_reason; + /* A few variables that are only used when connecting */ + GaimProxyConnectInfo *connect_info; + guint16 cookielen; + guint8 *cookie; + gpointer connect_data; + int fd; FlapFrame buffer_incoming; GaimCircBuffer *buffer_outgoing; @@ -661,6 +668,9 @@ guint32 minmsginterval; /* in milliseconds? */ }; +/* + * TODO: Should probably combine this with struct chat_connection. + */ struct aim_chat_roominfo { guint16 exchange; @@ -668,6 +678,25 @@ guint16 instance; }; +struct chat_connection +{ + char *name; + char *show; /* AOL did something funny to us */ + guint16 exchange; + guint16 instance; + FlapConnection *conn; + int id; + GaimConnection *gc; + GaimConversation *conv; + int maxlen; + int maxvis; +}; + +/* + * All this chat struct stuff should be in family_chat.c + */ +void oscar_chat_destroy(struct chat_connection *cc); + #define AIM_IMFLAGS_AWAY 0x0001 /* mark as an autoreply */ #define AIM_IMFLAGS_ACK 0x0002 /* request a receipt notice */ #define AIM_IMFLAGS_BUDDYREQ 0x0010 /* buddy icon requested */ Modified: branches/v2_0_0/src/protocols/oscar/peer.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/oscar/peer.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -482,7 +482,7 @@ * either connected or failed to connect. */ static void -peer_connection_established_cb(gpointer data, gint source) +peer_connection_established_cb(gpointer data, gint source, const gchar *error_message) { PeerConnection *conn; @@ -658,9 +658,7 @@ gaim_debug_info("oscar", "Peer connection timed out after 15 seconds. " "Trying next method...\n"); - gaim_proxy_connect_cancel(conn->connect_info); - conn->connect_info = NULL; - conn->connect_timeout_timer = 0; + peer_connection_close(conn); peer_connection_trynext(conn); @@ -706,7 +704,7 @@ conn->connect_info = gaim_proxy_connect(account, conn->verifiedip, conn->port, - peer_connection_established_cb, NULL, conn); + peer_connection_established_cb, conn); if (conn->connect_info != NULL) { /* Connecting... */ @@ -741,7 +739,7 @@ conn->connect_info = gaim_proxy_connect(account, conn->clientip, conn->port, - peer_connection_established_cb, NULL, conn); + peer_connection_established_cb, conn); if (conn->connect_info != NULL) { /* Connecting... */ @@ -813,7 +811,7 @@ conn->connect_info = gaim_proxy_connect(account, (conn->proxyip != NULL) ? conn->proxyip : PEER_PROXY_SERVER, PEER_PROXY_PORT, - peer_proxy_connection_established_cb, NULL, conn); + peer_proxy_connection_established_cb, conn); if (conn->connect_info != NULL) { /* Connecting... */ Modified: branches/v2_0_0/src/protocols/oscar/peer.h =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/oscar/peer.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -265,7 +265,7 @@ /* * For peer proxying */ -void peer_proxy_connection_established_cb(gpointer data, gint source); +void peer_proxy_connection_established_cb(gpointer data, gint source, const gchar *error_message); #if 0 int peer_oft_sendheader(OscarData *od, guint16 type, PeerConnection *peer_connection); Modified: branches/v2_0_0/src/protocols/oscar/peer_proxy.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer_proxy.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/oscar/peer_proxy.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -326,7 +326,7 @@ * either connected or failed to connect. */ void -peer_proxy_connection_established_cb(gpointer data, gint source) +peer_proxy_connection_established_cb(gpointer data, gint source, const gchar *error_message) { PeerConnection *conn; Modified: branches/v2_0_0/src/protocols/sametime/sametime.c =================================================================== --- branches/v2_0_0/src/protocols/sametime/sametime.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/sametime/sametime.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -4,17 +4,17 @@ Adds Lotus Sametime support to Gaim using the Meanwhile library Copyright (C) 2004 Christopher (siege) O'Brien <si...@pr...> - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, @@ -226,6 +226,7 @@ /** socket fd */ int socket; gint outpa; /* like inpa, but the other way */ + GaimProxyConnectInfo *connect_info; /** circular buffer for outgoing data */ GaimCircBuffer *sock_buf; @@ -310,7 +311,7 @@ /* connection functions */ -static void connect_cb(gpointer data, gint source); +static void connect_cb(gpointer data, gint source, const gchar *error_message); /* ----- session ------ */ @@ -1409,7 +1410,7 @@ port = gaim_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); if(gaim_account_get_bool(account, MW_KEY_FORCE, FALSE) || - (gaim_proxy_connect(account, host, port, connect_cb, NULL, pd) == NULL)) { + (gaim_proxy_connect(account, host, port, connect_cb, pd) == NULL)) { mwSession_forceLogin(session); } @@ -1669,15 +1670,12 @@ /** Callback passed to gaim_proxy_connect when an account is logged in, and if the session logging in receives a redirect message */ -static void connect_cb(gpointer data, gint source) { +static void connect_cb(gpointer data, gint source, const gchar *error_message) { struct mwGaimPluginData *pd = data; GaimConnection *gc = pd->gc; - if(! g_list_find(gaim_connections_get_all(), pd->gc)) { - close(source); - g_return_if_reached(); - } + pd->connect_info = NULL; if(source < 0) { /* connection failed */ @@ -3683,7 +3681,8 @@ gaim_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); - if(gaim_proxy_connect(account, host, port, connect_cb, NULL, pd) == NULL) { + pd->connect_info = gaim_proxy_connect(account, host, port, connect_cb, pd); + if(pd->connect_info == NULL) { gaim_connection_error(gc, _("Unable to connect to host")); } } @@ -3716,6 +3715,11 @@ gc->inpa = 0; } + if(pd->connect_info != NULL) { + gaim_proxy_connect_cancel(pd->connect_info); + pd->connect_info = NULL; + } + /* clean up the rest */ mwGaimPluginData_free(pd); } Modified: branches/v2_0_0/src/protocols/silc/silc.c =================================================================== --- branches/v2_0_0/src/protocols/silc/silc.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/silc/silc.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -141,7 +141,7 @@ } static void -silcgaim_login_connected(gpointer data, gint source) +silcgaim_login_connected(gpointer data, gint source, const gchar *error_message) { GaimConnection *gc = data; SilcGaim sg; @@ -153,20 +153,14 @@ g_return_if_fail(gc != NULL); - if (!GAIM_CONNECTION_IS_VALID(gc)) { - close(source); - return; - } + sg = gc->proto_data; + sg->connect_info = NULL; if (source < 0) { gaim_connection_error(gc, _("Connection failed")); return; } - sg = gc->proto_data; - if (sg == NULL) - return; - client = sg->client; account = sg->account; @@ -363,11 +357,12 @@ gc->proto_data = sg; /* Connect to the SILC server */ - if (gaim_proxy_connect(account, + sg->connect_info = gaim_proxy_connect(account, gaim_account_get_string(account, "server", "silc.silcnet.org"), gaim_account_get_int(account, "port", 706), - silcgaim_login_connected, NULL, gc) == NULL) + silcgaim_login_connected, gc); + if (sg->connect_info == NULL) { gaim_connection_error(gc, _("Unable to create connection")); return; @@ -387,6 +382,8 @@ SilcGaim sg = (SilcGaim)context; silc_client_stop(sg->client); silc_client_free(sg->client); + if (sg->connect_info != NULL) + gaim_proxy_connect_cancel(sg->connect_info); #ifdef HAVE_SILCMIME_H if (sg->mimeass) silc_mime_assembler_free(sg->mimeass); Modified: branches/v2_0_0/src/protocols/silc/silcgaim.h =================================================================== --- branches/v2_0_0/src/protocols/silc/silcgaim.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/silc/silcgaim.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -67,6 +67,7 @@ SilcClient client; SilcClientConnection conn; + GaimProxyConnectInfo *connect_info; guint scheduler; GaimConnection *gc; GaimAccount *account; Modified: branches/v2_0_0/src/protocols/simple/simple.c =================================================================== --- branches/v2_0_0/src/protocols/simple/simple.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/simple/simple.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -421,16 +421,24 @@ static void simple_input_cb(gpointer data, gint source, GaimInputCondition cond); -static void send_later_cb(gpointer data, gint source) { +static void send_later_cb(gpointer data, gint source, const gchar *error) { GaimConnection *gc = data; - struct simple_account_data *sip = gc->proto_data; + struct simple_account_data *sip; struct sip_connection *conn; + if (!GAIM_CONNECTION_IS_VALID(gc)) + { + if (source >= 0) + close(source); + return; + } + if(source < 0) { gaim_connection_error(gc, _("Could not connect")); return; } + sip = gc->proto_data; sip->fd = source; sip->connecting = FALSE; @@ -452,7 +460,7 @@ if(!sip->connecting) { gaim_debug_info("simple", "connecting to %s port %d\n", sip->realhostname ? sip->realhostname : "{NULL}", sip->realport); - connect_info = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, send_later_cb, NULL, gc); + connect_info = gaim_proxy_connect(sip->account, sip->realhostname, sip->realport, send_later_cb, gc); if(connect_info == NULL) { gaim_connection_error(gc, _("Couldn't create socket")); } @@ -1453,16 +1461,24 @@ conn->inputhandler = gaim_input_add(newfd, GAIM_INPUT_READ, simple_input_cb, gc); } -static void login_cb(gpointer data, gint source) { +static void login_cb(gpointer data, gint source, const gchar *error_message) { GaimConnection *gc = data; - struct simple_account_data *sip = gc->proto_data; + struct simple_account_data *sip; struct sip_connection *conn; + if (!GAIM_CONNECTION_IS_VALID(gc)) + { + if (source >= 0) + close(source); + return; + } + if(source < 0) { gaim_connection_error(gc, _("Could not connect")); return; } + sip = gc->proto_data; sip->fd = source; conn = connection_create(sip, source); @@ -1553,7 +1569,7 @@ sip->realhostname, sip->realport); /* open tcp connection to the server */ connect_info = gaim_proxy_connect(sip->account, sip->realhostname, - sip->realport, login_cb, NULL, sip->gc); + sip->realport, login_cb, sip->gc); if(connect_info == NULL) { gaim_connection_error(sip->gc, _("Couldn't create socket")); } Modified: branches/v2_0_0/src/protocols/toc/toc.c =================================================================== --- branches/v2_0_0/src/protocols/toc/toc.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/toc/toc.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -160,8 +160,9 @@ struct sockaddr_in name; socklen_t namelen; - if (!g_list_find(gaim_connections_get_all(), data)) { - close(source); + if (!GAIM_CONNECTION_IS_VALID(gc)) { + if (source >= 0) + close(source); return; } Modified: branches/v2_0_0/src/protocols/yahoo/yahoo.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/yahoo/yahoo.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -2239,7 +2239,7 @@ } } -static void yahoo_got_connected(gpointer data, gint source) +static void yahoo_got_connected(gpointer data, gint source, const gchar *error_message) { GaimConnection *gc = data; struct yahoo_data *yd; @@ -2266,7 +2266,7 @@ gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); } -static void yahoo_got_web_connected(gpointer data, gint source) +static void yahoo_got_web_connected(gpointer data, gint source, const gchar *error_message) { GaimConnection *gc = data; struct yahoo_data *yd; @@ -2348,7 +2348,7 @@ /* Now we have our cookies to login with. I'll go get the milk. */ if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com", gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), - yahoo_got_web_connected, NULL, gc) == NULL) { + yahoo_got_web_connected, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; } @@ -2390,7 +2390,7 @@ gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); } -static void yahoo_got_cookies(gpointer data, gint source) +static void yahoo_got_cookies(gpointer data, gint source, const gchar *error_message) { GaimConnection *gc = data; @@ -2516,7 +2516,7 @@ "Host: login.yahoo.com\r\n\r\n"); g_hash_table_destroy(hash); yd->auth = g_string_free(url, FALSE); - if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, NULL, gc) == NULL) { + if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; } @@ -2618,7 +2618,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), - yahoo_got_connected, NULL, gc) == NULL) + yahoo_got_connected, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; @@ -2628,7 +2628,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), - yahoo_got_connected, NULL, gc) == NULL) + yahoo_got_connected, gc) == NULL) { gaim_connection_error(gc, _("Connection problem")); return; Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_filexfer.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -92,7 +92,7 @@ } -static void yahoo_receivefile_connected(gpointer data, gint source) +static void yahoo_receivefile_connected(gpointer data, gint source, const gchar *error_message) { GaimXfer *xfer; struct yahoo_xfer_data *xd; @@ -162,7 +162,7 @@ gaim_xfer_start(xfer, source, NULL, 0); } -static void yahoo_sendfile_connected(gpointer data, gint source) +static void yahoo_sendfile_connected(gpointer data, gint source, const gchar *error_message) { GaimXfer *xfer; struct yahoo_xfer_data *xd; @@ -263,7 +263,7 @@ if (yd->jp) { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_sendfile_connected, NULL, xfer) == NULL) + yahoo_sendfile_connected, xfer) == NULL) { gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); @@ -272,7 +272,7 @@ } else { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_sendfile_connected, NULL, xfer) == NULL) + yahoo_sendfile_connected, xfer) == NULL) { gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Unable to establish file descriptor.")); @@ -282,7 +282,7 @@ } else { /* TODO: Using xfer->fd like this is probably a bad thing... */ if (gaim_proxy_connect(account, xfer_data->host, xfer_data->port, - yahoo_receivefile_connected, NULL, xfer) == NULL) + yahoo_receivefile_connected, xfer) == NULL) xfer->fd = -1; else xfer->fd = 0; Modified: branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/yahoo/yahoo_picture.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -406,7 +406,7 @@ } } -static void yahoo_buddy_icon_upload_connected(gpointer data, gint source) +static void yahoo_buddy_icon_upload_connected(gpointer data, gint source, const gchar *error_message) { struct yahoo_buddy_icon_upload_data *d = data; struct yahoo_packet *pkt; @@ -484,7 +484,7 @@ if (yd->jp) { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xferjp_host", YAHOOJP_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_buddy_icon_upload_connected, NULL, d) == NULL) + yahoo_buddy_icon_upload_connected, d) == NULL) { gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n"); yahoo_buddy_icon_upload_data_free(d); @@ -492,7 +492,7 @@ } else { if (gaim_proxy_connect(account, gaim_account_get_string(account, "xfer_host", YAHOO_XFER_HOST), gaim_account_get_int(account, "xfer_port", YAHOO_XFER_PORT), - yahoo_buddy_icon_upload_connected, NULL, d) == NULL) + yahoo_buddy_icon_upload_connected, d) == NULL) { gaim_debug_error("yahoo", "Uploading our buddy icon failed to connect.\n"); yahoo_buddy_icon_upload_data_free(d); Modified: branches/v2_0_0/src/protocols/yahoo/yahoochat.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/yahoochat.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/yahoo/yahoochat.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -1373,7 +1373,7 @@ } -static void yahoo_roomlist_got_connected(gpointer data, gint source) +static void yahoo_roomlist_got_connected(gpointer data, gint source, const gchar *error_message) { struct yahoo_roomlist *yrl = data; GaimRoomlist *list = yrl->list; @@ -1450,7 +1450,7 @@ gaim_roomlist_set_fields(rl, fields); if (gaim_proxy_connect(gaim_connection_get_account(gc), yrl->host, 80, - yahoo_roomlist_got_connected, NULL, yrl) == NULL) + yahoo_roomlist_got_connected, yrl) == NULL) { gaim_notify_error(gc, NULL, _("Connection problem"), _("Unable to fetch room list.")); yahoo_roomlist_cleanup(rl, yrl); @@ -1519,7 +1519,7 @@ gaim_roomlist_room_add(list, yrl->ucat); if (gaim_proxy_connect(list->account, yrl->host, 80, - yahoo_roomlist_got_connected, NULL, yrl) == NULL) + yahoo_roomlist_got_connected, yrl) == NULL) { gaim_notify_error(gaim_account_get_connection(list->account), NULL, _("Connection problem"), _("Unable to fetch room list.")); Modified: branches/v2_0_0/src/protocols/yahoo/ycht.c =================================================================== --- branches/v2_0_0/src/protocols/yahoo/ycht.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/protocols/yahoo/ycht.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -528,7 +528,7 @@ } } -static void ycht_got_connected(gpointer data, gint source) +static void ycht_got_connected(gpointer data, gint source, const gchar *error_message) { YchtConn *ycht = data; GaimConnection *gc = ycht->gc; @@ -571,7 +571,7 @@ if (gaim_proxy_connect(account, gaim_account_get_string(account, "ycht-server", YAHOO_YCHT_HOST), gaim_account_get_int(account, "ycht-port", YAHOO_YCHT_PORT), - ycht_got_connected, NULL, ycht) == NULL) + ycht_got_connected, ycht) == NULL) { ycht_connection_error(ycht, _("Connection problem")); return; Modified: branches/v2_0_0/src/proxy.c =================================================================== --- branches/v2_0_0/src/proxy.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/proxy.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -40,7 +40,6 @@ struct _GaimProxyConnectInfo { GaimProxyConnectFunction connect_cb; - GaimProxyErrorFunction error_cb; gpointer data; char *host; int port; @@ -324,7 +323,7 @@ static void gaim_proxy_connect_info_connected(GaimProxyConnectInfo *connect_info) { - connect_info->connect_cb(connect_info->data, connect_info->fd); + connect_info->connect_cb(connect_info->data, connect_info->fd, NULL); /* * We've passed the file descriptor to the protocol, so it's no longer @@ -348,22 +347,7 @@ static void gaim_proxy_connect_info_error(GaimProxyConnectInfo *connect_info, const gchar *error_message) { - if (connect_info->error_cb == NULL) - { - /* - * TODO - * While we're transitioning to the new gaim_proxy_connect() - * code, not all callers supply an error_cb. If this is the - * case then they're expecting connect_cb to be called with - * an fd of -1 in the case of an error. Once all callers have - * been changed this whole if statement should be removed. - */ - connect_info->connect_cb(connect_info->data, -1); - gaim_proxy_connect_info_destroy(connect_info); - return; - } - - connect_info->error_cb(connect_info->data, error_message); + connect_info->connect_cb(connect_info->data, -1, error_message); gaim_proxy_connect_info_destroy(connect_info); } @@ -2339,8 +2323,7 @@ GaimProxyConnectInfo * gaim_proxy_connect(GaimAccount *account, const char *host, int port, - GaimProxyConnectFunction connect_cb, - GaimProxyErrorFunction error_cb, gpointer data) + GaimProxyConnectFunction connect_cb, gpointer data) { const char *connecthost = host; int connectport = port; @@ -2349,12 +2332,10 @@ g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port > 0, NULL); g_return_val_if_fail(connect_cb != NULL, NULL); - /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ connect_info = g_new0(GaimProxyConnectInfo, 1); connect_info->fd = -1; connect_info->connect_cb = connect_cb; - connect_info->error_cb = error_cb; connect_info->data = data; connect_info->host = g_strdup(host); connect_info->port = port; @@ -2404,20 +2385,17 @@ */ GaimProxyConnectInfo * gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port, - GaimProxyConnectFunction connect_cb, - GaimProxyErrorFunction error_cb, gpointer data) + GaimProxyConnectFunction connect_cb, gpointer data) { GaimProxyConnectInfo *connect_info; g_return_val_if_fail(host != NULL, NULL); g_return_val_if_fail(port > 0, NULL); g_return_val_if_fail(connect_cb != NULL, NULL); - /* g_return_val_if_fail(error_cb != NULL, NULL); *//* TODO: Soon! */ connect_info = g_new0(GaimProxyConnectInfo, 1); connect_info->fd = -1; connect_info->connect_cb = connect_cb; - connect_info->error_cb = error_cb; connect_info->data = data; connect_info->host = g_strdup(host); connect_info->port = port; Modified: branches/v2_0_0/src/proxy.h =================================================================== --- branches/v2_0_0/src/proxy.h 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/proxy.h 2006-08-14 08:36:25 UTC (rev 16756) @@ -58,8 +58,7 @@ typedef struct _GaimProxyConnectInfo GaimProxyConnectInfo; -typedef void (*GaimProxyConnectFunction)(gpointer data, gint source); -typedef void (*GaimProxyErrorFunction)(gpointer dat, const gchar *error_message); +typedef void (*GaimProxyConnectFunction)(gpointer data, gint source, const gchar *error_message); /** * The "hosts" parameter is a linked list containing pairs of @@ -235,9 +234,9 @@ * @param host The destination host. * @param port The destination port. * @param connect_cb The function to call when the connection is - * established. - * @param error_cb The function to call if there is an error while - * establishing the connection. + * established. If the connection failed then + * fd will be -1 and error message will be set + * to something descriptive (hopefully). * @param data User-defined data. * * @return NULL if there was an error, or a reference to a data @@ -246,8 +245,7 @@ */ GaimProxyConnectInfo *gaim_proxy_connect(GaimAccount *account, const char *host, int port, - GaimProxyConnectFunction connect_cb, - GaimProxyErrorFunction error_cb, gpointer data); + GaimProxyConnectFunction connect_cb, gpointer data); /** * Makes a connection through a SOCKS5 proxy. @@ -256,9 +254,9 @@ * @param host The destination host. * @param port The destination port. * @param connect_cb The function to call when the connection is - * established. - * @param error_cb The function to call if there is an error while - * establishing the connection. + * established. If the connection failed then + * fd will be -1 and error message will be set + * to something descriptive (hopefully). * @param data User-defined data. * * @return NULL if there was an error, or a reference to a data @@ -267,8 +265,7 @@ */ GaimProxyConnectInfo *gaim_proxy_connect_socks5(GaimProxyInfo *gpi, const char *host, int port, - GaimProxyConnectFunction connect_cb, - GaimProxyErrorFunction error_cb, gpointer data); + GaimProxyConnectFunction connect_cb, gpointer data); /** * Cancel an in-progress connection attempt. This should be called Modified: branches/v2_0_0/src/sslconn.c =================================================================== --- branches/v2_0_0/src/sslconn.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/sslconn.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -95,7 +95,7 @@ gsc->connect_cb = func; gsc->error_cb = error_func; - connect_info = gaim_proxy_connect(account, host, port, ops->connect_cb, NULL, gsc); + connect_info = gaim_proxy_connect(account, host, port, ops->connect_cb, gsc); if (connect_info == NULL) { Modified: branches/v2_0_0/src/upnp.c =================================================================== --- branches/v2_0_0/src/upnp.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/upnp.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -780,7 +780,7 @@ } static void -looked_up_internal_ip_cb(gpointer data, gint source) +looked_up_internal_ip_cb(gpointer data, gint source, const gchar *error_message) { if (source) { strncpy(control_info.internalip, @@ -811,7 +811,7 @@ } if(gaim_proxy_connect(NULL, addressOfControl, port, - looked_up_internal_ip_cb, NULL, NULL) == NULL) + looked_up_internal_ip_cb, NULL) == NULL) { gaim_debug_error("upnp", "Get Local IP Connect Failed: Address: %s @@@ Port %d\n", addressOfControl, port); Modified: branches/v2_0_0/src/util.c =================================================================== --- branches/v2_0_0/src/util.c 2006-08-14 08:32:52 UTC (rev 16755) +++ branches/v2_0_0/src/util.c 2006-08-14 08:36:25 UTC (rev 16756) @@ -3367,7 +3367,7 @@ } static void -url_fetch_connect_cb(gpointer url_data, gint source) +url_fetch_connect_cb(gpointer url_data, gint source, const gchar *error_message) { GaimFetchUrlData *gfud; @@ -3446,7 +3446,7 @@ &gfud->website.page, &gfud->website.user, &gfud->website.passwd); if (gaim_proxy_connect(NULL, gfud->website.address, - gfud->website.port, url_fetch_connect_cb, NULL, gfud) == NULL) + gfud->website.port, url_fetch_connect_cb, gfud) == NULL) { destroy_fetch_url_data(gfud); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |