You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(106) |
Oct
(334) |
Nov
(246) |
Dec
(145) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(42) |
Feb
(53) |
Mar
(232) |
Apr
(109) |
May
(137) |
Jun
(63) |
Jul
(26) |
Aug
(263) |
Sep
(193) |
Oct
(507) |
Nov
(440) |
Dec
(241) |
2003 |
Jan
(567) |
Feb
(195) |
Mar
(504) |
Apr
(481) |
May
(524) |
Jun
(522) |
Jul
(594) |
Aug
(502) |
Sep
(643) |
Oct
(508) |
Nov
(430) |
Dec
(377) |
2004 |
Jan
(361) |
Feb
(251) |
Mar
(219) |
Apr
(499) |
May
(461) |
Jun
(419) |
Jul
(314) |
Aug
(519) |
Sep
(416) |
Oct
(247) |
Nov
(305) |
Dec
(382) |
2005 |
Jan
(267) |
Feb
(282) |
Mar
(327) |
Apr
(338) |
May
(189) |
Jun
(400) |
Jul
(462) |
Aug
(530) |
Sep
(316) |
Oct
(523) |
Nov
(481) |
Dec
(650) |
2006 |
Jan
(536) |
Feb
(361) |
Mar
(287) |
Apr
(146) |
May
(101) |
Jun
(169) |
Jul
(221) |
Aug
(498) |
Sep
(300) |
Oct
(236) |
Nov
(209) |
Dec
(205) |
2007 |
Jan
(30) |
Feb
(23) |
Mar
(26) |
Apr
(15) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <the...@us...> - 2006-08-14 06:38:14
|
Revision: 16745 Author: thekingant Date: 2006-08-13 23:38:12 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16745&view=rev Log Message: ----------- IRC is now canceling gaim_proxy_connect() attempts instead of using GAIM_CONNECTION_IS_VALID(). This will probably be the most clear example of the changes needed, for you folks sitting at home. Modified Paths: -------------- trunk/src/protocols/irc/irc.c trunk/src/protocols/irc/irc.h Modified: trunk/src/protocols/irc/irc.c =================================================================== --- trunk/src/protocols/irc/irc.c 2006-08-14 06:27:04 UTC (rev 16744) +++ trunk/src/protocols/irc/irc.c 2006-08-14 06:38:12 UTC (rev 16745) @@ -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, 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: trunk/src/protocols/irc/irc.h =================================================================== --- trunk/src/protocols/irc/irc.h 2006-08-14 06:27:04 UTC (rev 16744) +++ trunk/src/protocols/irc/irc.h 2006-08-14 06:38:12 UTC (rev 16745) @@ -54,6 +54,8 @@ guint timer; GHashTable *buddies; + GaimProxyConnectInfo *connect_info; + char *inbuf; int inbuflen; int inbufused; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-14 06:27:07
|
Revision: 16744 Author: thekingant Date: 2006-08-13 23:27:04 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16744&view=rev Log Message: ----------- Code re-use! Modified Paths: -------------- trunk/src/protocols/oscar/peer.c Modified: trunk/src/protocols/oscar/peer.c =================================================================== --- trunk/src/protocols/oscar/peer.c 2006-08-14 06:24:17 UTC (rev 16743) +++ trunk/src/protocols/oscar/peer.c 2006-08-14 06:27:04 UTC (rev 16744) @@ -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); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-14 06:24:20
|
Revision: 16743 Author: thekingant Date: 2006-08-13 23:24:17 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16743&view=rev Log Message: ----------- Almost all of oscar is using gaim_proxy_connect_cancel() now Modified Paths: -------------- trunk/src/protocols/oscar/flap_connection.c trunk/src/protocols/oscar/oscar.c trunk/src/protocols/oscar/oscar.h trunk/src/protocols/oscar/peer.c trunk/src/protocols/oscar/peer.h trunk/src/protocols/oscar/peer_proxy.c Modified: trunk/src/protocols/oscar/flap_connection.c =================================================================== --- trunk/src/protocols/oscar/flap_connection.c 2006-08-14 04:43:38 UTC (rev 16742) +++ trunk/src/protocols/oscar/flap_connection.c 2006-08-14 06:24:17 UTC (rev 16743) @@ -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: trunk/src/protocols/oscar/oscar.c =================================================================== --- trunk/src/protocols/oscar/oscar.c 2006-08-14 04:43:38 UTC (rev 16742) +++ trunk/src/protocols/oscar/oscar.c 2006-08-14 06:24:17 UTC (rev 16743) @@ -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, 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, 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,6 +1526,7 @@ 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, pos) == NULL) { @@ -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, 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: trunk/src/protocols/oscar/oscar.h =================================================================== --- trunk/src/protocols/oscar/oscar.h 2006-08-14 04:43:38 UTC (rev 16742) +++ trunk/src/protocols/oscar/oscar.h 2006-08-14 06:24:17 UTC (rev 16743) @@ -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: trunk/src/protocols/oscar/peer.c =================================================================== --- trunk/src/protocols/oscar/peer.c 2006-08-14 04:43:38 UTC (rev 16742) +++ trunk/src/protocols/oscar/peer.c 2006-08-14 06:24:17 UTC (rev 16743) @@ -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; Modified: trunk/src/protocols/oscar/peer.h =================================================================== --- trunk/src/protocols/oscar/peer.h 2006-08-14 04:43:38 UTC (rev 16742) +++ trunk/src/protocols/oscar/peer.h 2006-08-14 06:24:17 UTC (rev 16743) @@ -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: trunk/src/protocols/oscar/peer_proxy.c =================================================================== --- trunk/src/protocols/oscar/peer_proxy.c 2006-08-14 04:43:38 UTC (rev 16742) +++ trunk/src/protocols/oscar/peer_proxy.c 2006-08-14 06:24:17 UTC (rev 16743) @@ -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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-14 04:43:49
|
Revision: 16742 Author: thekingant Date: 2006-08-13 21:43:38 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16742&view=rev Log Message: ----------- Removing the "error_cb" parameter for gaim_proxy_connect(), changing it back to how it was. As I started making changes to oscar to support canceling connection attempts, I realized that having a separate callback for errors would result in more code duplication than was needed. Originally I thought the separate callback would make things cleaner. Anyway, sorry for the noise. Modified Paths: -------------- trunk/plugins/ChangeLog.API trunk/src/ft.c trunk/src/protocols/irc/irc.c trunk/src/protocols/jabber/jabber.c trunk/src/protocols/jabber/si.c trunk/src/protocols/msn/directconn.c trunk/src/protocols/msn/httpconn.c trunk/src/protocols/msn/servconn.c trunk/src/protocols/oscar/oscar.c trunk/src/protocols/oscar/peer.c trunk/src/protocols/qq/qq_proxy.c trunk/src/protocols/sametime/sametime.c trunk/src/protocols/silc/silc.c trunk/src/protocols/simple/simple.c trunk/src/protocols/yahoo/yahoo.c trunk/src/protocols/yahoo/yahoo_filexfer.c trunk/src/protocols/yahoo/yahoo_picture.c trunk/src/protocols/yahoo/yahoochat.c trunk/src/protocols/yahoo/ycht.c trunk/src/proxy.c trunk/src/proxy.h trunk/src/sslconn.c trunk/src/upnp.c trunk/src/util.c Modified: trunk/plugins/ChangeLog.API =================================================================== --- trunk/plugins/ChangeLog.API 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/plugins/ChangeLog.API 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/ft.c =================================================================== --- trunk/src/ft.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/ft.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/protocols/irc/irc.c =================================================================== --- trunk/src/protocols/irc/irc.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/irc/irc.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -327,7 +327,7 @@ 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)) { gaim_connection_error(gc, _("Couldn't create socket")); Modified: trunk/src/protocols/jabber/jabber.c =================================================================== --- trunk/src/protocols/jabber/jabber.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/jabber/jabber.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -477,7 +477,7 @@ GaimProxyConnectInfo *connect_info; connect_info = gaim_proxy_connect(js->gc->account, server, - port, jabber_login_callback, NULL, js->gc); + port, jabber_login_callback, js->gc); if (connect_info == NULL) gaim_connection_error(js->gc, _("Unable to create socket")); @@ -914,7 +914,7 @@ if(!js->gsc) { 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) gaim_connection_error(gc, _("Unable to create socket")); Modified: trunk/src/protocols/jabber/si.c =================================================================== --- trunk/src/protocols/jabber/si.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/jabber/si.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -167,7 +167,7 @@ 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); + gaim_proxy_connect_socks5(jsx->gpi, dstaddr, 0, jabber_si_bytestreams_connect_cb, xfer); g_free(dstaddr); } Modified: trunk/src/protocols/msn/directconn.c =================================================================== --- trunk/src/protocols/msn/directconn.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/msn/directconn.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -439,7 +439,7 @@ #endif connect_info = gaim_proxy_connect(session->account, host, port, - connect_cb, NULL, directconn); + connect_cb, directconn); if (connect_info != NULL) { Modified: trunk/src/protocols/msn/httpconn.c =================================================================== --- trunk/src/protocols/msn/httpconn.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/msn/httpconn.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -739,7 +739,7 @@ msn_httpconn_disconnect(httpconn); connect_info = gaim_proxy_connect(httpconn->session->account, - "gateway.messenger.hotmail.com", 80, connect_cb, NULL, httpconn); + "gateway.messenger.hotmail.com", 80, connect_cb, httpconn); if (connect_info != NULL) { Modified: trunk/src/protocols/msn/servconn.c =================================================================== --- trunk/src/protocols/msn/servconn.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/msn/servconn.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -233,7 +233,7 @@ } connect_info = gaim_proxy_connect(session->account, host, port, - connect_cb, NULL, servconn); + connect_cb, servconn); if (connect_info != NULL) { Modified: trunk/src/protocols/oscar/oscar.c =================================================================== --- trunk/src/protocols/oscar/oscar.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/oscar/oscar.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -1250,7 +1250,7 @@ if (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, new_conn_data) == NULL) { gaim_connection_error(gc, _("Couldn't connect to host")); return; @@ -1368,7 +1368,7 @@ 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); + connection_established_cb, new_conn_data); g_free(host); if (connect_info == NULL) { gaim_connection_error(gc, _("Could Not Connect")); @@ -1574,7 +1574,7 @@ pos->modname = g_strdup(modname); 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) @@ -1665,7 +1665,7 @@ new_conn_data->data = NULL; } - if (gaim_proxy_connect(account, host, port, connection_established_cb, NULL, new_conn_data) == NULL) + if (gaim_proxy_connect(account, host, port, connection_established_cb, new_conn_data) == NULL) { flap_connection_schedule_destroy(new_conn_data->conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); Modified: trunk/src/protocols/oscar/peer.c =================================================================== --- trunk/src/protocols/oscar/peer.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/oscar/peer.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -706,7 +706,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 +741,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 +813,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: trunk/src/protocols/qq/qq_proxy.c =================================================================== --- trunk/src/protocols/qq/qq_proxy.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/qq/qq_proxy.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -321,7 +321,7 @@ if (use_tcp) /* TCP mode */ - return (gaim_proxy_connect(account, host, port, func, NULL, data) == NULL); + return (gaim_proxy_connect(account, host, port, func, data) == NULL); else /* UDP mode */ return _qq_udp_proxy_connect(account, host, port, func, data); Modified: trunk/src/protocols/sametime/sametime.c =================================================================== --- trunk/src/protocols/sametime/sametime.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/sametime/sametime.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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, @@ -1409,7 +1409,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); } @@ -3683,7 +3683,7 @@ gaim_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); - if(gaim_proxy_connect(account, host, port, connect_cb, NULL, pd) == NULL) { + if(gaim_proxy_connect(account, host, port, connect_cb, pd) == NULL) { gaim_connection_error(gc, _("Unable to connect to host")); } } Modified: trunk/src/protocols/silc/silc.c =================================================================== --- trunk/src/protocols/silc/silc.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/silc/silc.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -367,7 +367,7 @@ 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) == NULL) { gaim_connection_error(gc, _("Unable to create connection")); return; Modified: trunk/src/protocols/simple/simple.c =================================================================== --- trunk/src/protocols/simple/simple.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/simple/simple.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -452,7 +452,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")); } @@ -1553,7 +1553,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: trunk/src/protocols/yahoo/yahoo.c =================================================================== --- trunk/src/protocols/yahoo/yahoo.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/yahoo/yahoo.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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; } @@ -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: trunk/src/protocols/yahoo/yahoo_filexfer.c =================================================================== --- trunk/src/protocols/yahoo/yahoo_filexfer.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/yahoo/yahoo_filexfer.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/protocols/yahoo/yahoo_picture.c =================================================================== --- trunk/src/protocols/yahoo/yahoo_picture.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/yahoo/yahoo_picture.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/protocols/yahoo/yahoochat.c =================================================================== --- trunk/src/protocols/yahoo/yahoochat.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/yahoo/yahoochat.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/protocols/yahoo/ycht.c =================================================================== --- trunk/src/protocols/yahoo/ycht.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/protocols/yahoo/ycht.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/proxy.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/proxy.h =================================================================== --- trunk/src/proxy.h 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/proxy.h 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/sslconn.c =================================================================== --- trunk/src/sslconn.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/sslconn.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/upnp.c =================================================================== --- trunk/src/upnp.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/upnp.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -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: trunk/src/util.c =================================================================== --- trunk/src/util.c 2006-08-14 02:16:58 UTC (rev 16741) +++ trunk/src/util.c 2006-08-14 04:43:38 UTC (rev 16742) @@ -3448,7 +3448,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. |
From: <sa...@us...> - 2006-08-14 02:17:04
|
Revision: 16741 Author: sadrul Date: 2006-08-13 19:16:58 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16741&view=rev Log Message: ----------- Show little scroll-arrows for trees and textviews when appropriate. Modified Paths: -------------- trunk/console/libgnt/gntmain.c trunk/console/libgnt/gnttextview.c trunk/console/libgnt/gnttree.c Modified: trunk/console/libgnt/gntmain.c =================================================================== --- trunk/console/libgnt/gntmain.c 2006-08-14 00:08:15 UTC (rev 16740) +++ trunk/console/libgnt/gntmain.c 2006-08-14 02:16:58 UTC (rev 16741) @@ -399,6 +399,10 @@ case 'j': case 'n': ch = '+'; break; + case '-': + ch = '^'; break; + case '.': + ch = 'v'; break; default: ch = ' '; break; } Modified: trunk/console/libgnt/gnttextview.c =================================================================== --- trunk/console/libgnt/gnttextview.c 2006-08-14 00:08:15 UTC (rev 16740) +++ trunk/console/libgnt/gnttextview.c 2006-08-14 02:16:58 UTC (rev 16741) @@ -46,6 +46,18 @@ } } + mvwaddch(widget->window, 0, + widget->priv.width - 1, + lines ? + ACS_UARROW | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D) : + ' '| COLOR_PAIR(GNT_COLOR_NORMAL)); + + mvwaddch(widget->window, widget->priv.height - 1, + widget->priv.width - 1, + (view->list && view->list->prev) ? + ACS_DARROW | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D) : + ' '| COLOR_PAIR(GNT_COLOR_NORMAL)); + DEBUG; } Modified: trunk/console/libgnt/gnttree.c =================================================================== --- trunk/console/libgnt/gnttree.c 2006-08-14 00:08:15 UTC (rev 16740) +++ trunk/console/libgnt/gnttree.c 2006-08-14 02:16:58 UTC (rev 16741) @@ -223,7 +223,7 @@ text = g_utf8_offset_to_pointer(col->text, len - fl); string = g_string_append_len(string, col->text, text - col->text); - if (len < tree->columns[i].width) + if (len < tree->columns[i].width && iter->next) g_string_append_printf(string, "%*s", tree->columns[i].width - len, ""); } return g_string_free(string, FALSE); @@ -306,6 +306,12 @@ else if (up >= widget->priv.height - pos) tree->top = get_prev_n(tree->current, nr); + mvwaddch(widget->window, start + pos, + widget->priv.width - pos - 1, + (tree->top != tree->root) ? + ACS_UARROW | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D) : + ' '| COLOR_PAIR(GNT_COLOR_NORMAL)); + row = tree->top; for (start = start + pos; row && start < widget->priv.height - pos; start++, row = get_next(row)) @@ -351,17 +357,23 @@ wbkgdset(widget->window, '\0' | attr); mvwprintw(widget->window, start, pos, str); - whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1)); + whline(widget->window, ' ', widget->priv.width - pos * 2 - g_utf8_strlen(str, -1) - 1); tree->bottom = row; g_free(str); tree_mark_columns(tree, pos, start, ACS_VLINE | attr); } + mvwaddch(widget->window, widget->priv.height - pos - 1, + widget->priv.width - pos - 1, + get_next(tree->bottom) ? + ACS_DARROW | COLOR_PAIR(GNT_COLOR_HIGHLIGHT_D) : + ' '| COLOR_PAIR(GNT_COLOR_NORMAL)); + wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); while (start < widget->priv.height - pos) { mvwhline(widget->window, start, pos, ' ', - widget->priv.width - pos * 2); + widget->priv.width - pos * 2 - 1); tree_mark_columns(tree, pos, start, ACS_VLINE); start++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-14 00:08:19
|
Revision: 16740 Author: datallah Date: 2006-08-13 17:08:15 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16740&view=rev Log Message: ----------- Fix for CID 97 Modified Paths: -------------- trunk/plugins/log_reader.c Modified: trunk/plugins/log_reader.c =================================================================== --- trunk/plugins/log_reader.c 2006-08-13 23:30:19 UTC (rev 16739) +++ trunk/plugins/log_reader.c 2006-08-14 00:08:15 UTC (rev 16740) @@ -857,11 +857,10 @@ * friendly name or alias. For this test, "match" is defined as: * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$ */ - from_name_matches = from_name != NULL && ( - (gaim_str_has_prefix(from_name, friendly_name) && + from_name_matches = (gaim_str_has_prefix(from_name, friendly_name) && !isalnum(*(from_name + friendly_name_length))) || (gaim_str_has_prefix(from_name, log->account->alias) && - !isalnum(*(from_name + alias_length)))); + !isalnum(*(from_name + alias_length))); to_name_matches = to_name != NULL && ( (gaim_str_has_prefix(to_name, friendly_name) && @@ -930,10 +929,11 @@ !isalnum(*(from_name + friendly_name_length))); - to_name_matches = (gaim_str_has_prefix( + to_name_matches = to_name && ( + (gaim_str_has_prefix( to_name, buddy->server_alias) && !isalnum(*(to_name + - friendly_name_length))); + friendly_name_length)))); if (from_name_matches) { if (!to_name_matches) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-08-13 23:30:32
|
Revision: 16739 Author: sadrul Date: 2006-08-13 16:30:19 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16739&view=rev Log Message: ----------- Allow autojoining chat rooms. Sort the buddies in the buddylist, and the plugins in the plugin list. Modified Paths: -------------- trunk/console/gntblist.c trunk/console/gntnotify.c trunk/console/gntplugin.c trunk/console/libgnt/gntcombobox.c trunk/console/libgnt/gntentry.c trunk/console/libgnt/gnttree.c trunk/console/libgnt/gnttree.h trunk/console/libgnt/test/focus.c trunk/console/libgnt/test/multiwin.c trunk/console/libgnt/test/tv.c Modified: trunk/console/gntblist.c =================================================================== --- trunk/console/gntblist.c 2006-08-13 17:38:25 UTC (rev 16738) +++ trunk/console/gntblist.c 2006-08-13 23:30:19 UTC (rev 16739) @@ -337,6 +337,9 @@ node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), group, NULL); + + if (gaim_blist_node_get_bool((GaimBlistNode*)chat, "gnt-autojoin")) + serv_join_chat(gaim_account_get_connection(chat->account), chat->components); } static void @@ -452,8 +455,23 @@ } static void +context_menu_toggle(GntTree *tree, GaimMenuAction *action, gpointer null) +{ + gboolean sel = gnt_tree_get_choice(tree, action); + gaim_blist_node_set_bool(action->data, "gnt-autojoin", sel); +} + +static void create_chat_menu(GntTree *tree, GaimChat *chat) { + GaimMenuAction *action = gaim_menu_action_new(_("Auto-join"), NULL, chat, NULL); + + gnt_tree_add_choice(tree, action, gnt_tree_create_row(tree, action->label), NULL, NULL); + gnt_tree_set_choice(tree, action, gaim_blist_node_get_bool((GaimBlistNode*)chat, "gnt-autojoin")); + + g_signal_connect_swapped(G_OBJECT(tree), "destroy", + G_CALLBACK(gaim_menu_action_free), action); + g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(context_menu_toggle), NULL); } static void @@ -1182,6 +1200,42 @@ 0, 0, NULL, status_text_changed, NULL); } +static int +blist_node_compare(GaimBlistNode *n1, GaimBlistNode *n2) +{ + const char *s1, *s2; + char *us1, *us2; + int ret; + + g_return_val_if_fail(n1->type == n2->type, -1); + + switch (n1->type) + { + case GAIM_BLIST_GROUP_NODE: + s1 = ((GaimGroup*)n1)->name; + s2 = ((GaimGroup*)n2)->name; + break; + case GAIM_BLIST_CHAT_NODE: + s1 = gaim_chat_get_name((GaimChat*)n1); + s2 = gaim_chat_get_name((GaimChat*)n2); + break; + case GAIM_BLIST_BUDDY_NODE: + s1 = gaim_buddy_get_alias((GaimBuddy*)n1); + s2 = gaim_buddy_get_alias((GaimBuddy*)n2); + break; + default: + return -1; + } + + us1 = g_utf8_strup(s1, -1); + us2 = g_utf8_strup(s2, -1); + ret = g_utf8_collate(us1, us2); + g_free(us1); + g_free(us2); + + return ret; +} + void gg_blist_show() { if (ggblist) @@ -1198,6 +1252,7 @@ gnt_box_set_pad(GNT_BOX(ggblist->window), 0); ggblist->tree = gnt_tree_new(); + gnt_tree_set_compare_func(GNT_TREE(ggblist->tree), (GCompareFunc)blist_node_compare); GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER); gnt_tree_set_col_width(GNT_TREE(ggblist->tree), 0, 25); gnt_widget_set_size(ggblist->tree, gaim_prefs_get_int(PREF_ROOT "/size/width"), Modified: trunk/console/gntnotify.c =================================================================== --- trunk/console/gntnotify.c 2006-08-13 17:38:25 UTC (rev 16738) +++ trunk/console/gntnotify.c 2006-08-13 23:30:19 UTC (rev 16739) @@ -163,14 +163,18 @@ } else { + char *to; + setup_email_dialog(); + to = g_strdup_printf("%s (%s)", tos ? *tos : gaim_account_get_username(account), + gaim_account_get_protocol_name(account)); gnt_tree_add_row_after(GNT_TREE(emaildialog.tree), GINT_TO_POINTER(time(NULL)), - gnt_tree_create_row(GNT_TREE(emaildialog.tree), - tos ? *tos : gaim_account_get_username(account), /* XXX: Perhaps add the prpl-name */ + gnt_tree_create_row(GNT_TREE(emaildialog.tree), to, froms ? *froms : "[Unknown sender]", *subjects), NULL, NULL); + g_free(to); gnt_widget_show(emaildialog.window); return NULL; } Modified: trunk/console/gntplugin.c =================================================================== --- trunk/console/gntplugin.c 2006-08-13 17:38:25 UTC (rev 16738) +++ trunk/console/gntplugin.c 2006-08-13 23:30:19 UTC (rev 16739) @@ -68,6 +68,7 @@ gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(plugins.aboot), text, GNT_TEXT_FLAG_NORMAL); gnt_text_view_scroll(GNT_TEXT_VIEW(plugins.aboot), 0); + g_free(text); } static void @@ -78,6 +79,17 @@ plugins.aboot = NULL; } +static int +plugin_compare(GaimPlugin *p1, GaimPlugin *p2) +{ + char *s1 = g_utf8_strup(p1->info->name, -1); + char *s2 = g_utf8_strup(p2->info->name, -1); + int ret = g_utf8_collate(s1, s2); + g_free(s1); + g_free(s2); + return ret; +} + void gg_plugins_show_all() { GntWidget *window, *tree, *box, *aboot; @@ -102,6 +114,7 @@ gnt_box_set_pad(GNT_BOX(box), 0); plugins.tree = tree = gnt_tree_new(); + gnt_tree_set_compare_func(GNT_TREE(tree), (GCompareFunc)plugin_compare); GNT_WIDGET_SET_FLAGS(tree, GNT_WIDGET_NO_BORDER); gnt_box_add_widget(GNT_BOX(box), tree); gnt_box_add_widget(GNT_BOX(box), gnt_vline_new()); @@ -128,8 +141,6 @@ g_signal_connect(G_OBJECT(tree), "selection_changed", G_CALLBACK(selection_changed), NULL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(reset_plugin_window), NULL); - gnt_tree_set_selected(GNT_TREE(tree), gaim_plugins_get_all()->data); - gnt_widget_show(window); } Modified: trunk/console/libgnt/gntcombobox.c =================================================================== --- trunk/console/libgnt/gntcombobox.c 2006-08-13 17:38:25 UTC (rev 16738) +++ trunk/console/libgnt/gntcombobox.c 2006-08-13 23:30:19 UTC (rev 16739) @@ -244,8 +244,8 @@ void gnt_combo_box_add_data(GntComboBox *box, gpointer key, const char *text) { - gnt_tree_add_row_after(GNT_TREE(box->dropdown), key, - gnt_tree_create_row(GNT_TREE(box->dropdown), text), NULL, NULL); + gnt_tree_add_row_last(GNT_TREE(box->dropdown), key, + gnt_tree_create_row(GNT_TREE(box->dropdown), text), NULL); if (box->selected == NULL) set_selection(box, key); } Modified: trunk/console/libgnt/gntentry.c =================================================================== --- trunk/console/libgnt/gntentry.c 2006-08-13 17:38:25 UTC (rev 16738) +++ trunk/console/libgnt/gntentry.c 2006-08-13 23:30:19 UTC (rev 16739) @@ -61,6 +61,7 @@ { GntWidget *box = gnt_vbox_new(FALSE); entry->ddown = gnt_tree_new(); + gnt_tree_set_compare_func(GNT_TREE(entry->ddown), (GCompareFunc)g_utf8_collate); gnt_box_add_widget(GNT_BOX(box), entry->ddown); GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT); Modified: trunk/console/libgnt/gnttree.c =================================================================== --- trunk/console/libgnt/gnttree.c 2006-08-13 17:38:25 UTC (rev 16738) +++ trunk/console/libgnt/gnttree.c 2006-08-13 23:30:19 UTC (rev 16739) @@ -249,8 +249,11 @@ int start; GntWidget *widget = GNT_WIDGET(tree); GntTreeRow *row; - int pos; + int pos, up, down, nr; + if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED)) + return; + if (GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER)) pos = 0; else @@ -288,6 +291,21 @@ start = 2; } + nr = widget->priv.height - pos * 2 - start - 1; + tree->bottom = get_next_n_opt(tree->top, nr, &down); + if (down < nr) + { + tree->top = get_prev_n(tree->bottom, nr); + if (tree->top == NULL) + tree->top = tree->root; + } + + up = get_distance(tree->top, tree->current); + if (up < 0) + tree->top = tree->current; + else if (up >= widget->priv.height - pos) + tree->top = get_prev_n(tree->current, nr); + row = tree->top; for (start = start + pos; row && start < widget->priv.height - pos; start++, row = get_next(row)) @@ -379,8 +397,13 @@ static void gnt_tree_map(GntWidget *widget) { + GntTree *tree = GNT_TREE(widget); if (widget->priv.width == 0 || widget->priv.height == 0) + { gnt_widget_size_request(widget); + } + tree->top = tree->root; + tree->current = tree->root; DEBUG; } @@ -616,12 +639,48 @@ g_signal_emit(tree, signals[SIG_SCROLLED], 0, count); } +static gpointer +find_position(GntTree *tree, gpointer key, gpointer parent) +{ + GntTreeRow *row; + + if (tree->compare == NULL) + return NULL; + + if (parent == NULL) + row = tree->root; + else + row = g_hash_table_lookup(tree->hash, parent); + + if (!row) + return NULL; + + if (parent) + row = row->child; + + while (row) + { + if (tree->compare(key, row->key) < 0) + return (row->prev ? row->prev->key : NULL); + if (row->next) + row = row->next; + else + return row->key; + } + return NULL; +} + GntTreeRow *gnt_tree_add_row_after(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro) { GntTreeRow *pr = NULL; g_hash_table_replace(tree->hash, key, row); + if (bigbro == NULL && tree->compare) + { + bigbro = find_position(tree, key, parent); + } + if (tree->root == NULL) { tree->root = row; @@ -663,12 +722,10 @@ if (pr == NULL) { GntTreeRow *r = tree->root; - while (r->next) - r = r->next; - r->next = row; - row->prev = r; - - tree->list = g_list_append(tree->list, key); + row->next = r; + if (r) r->prev = row; + tree->root = row; + tree->list = g_list_prepend(tree->list, key); } else { @@ -679,12 +736,32 @@ row->key = key; row->data = NULL; - if (GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_MAPPED)) - redraw_tree(tree); + redraw_tree(tree); return row; } +GntTreeRow *gnt_tree_add_row_last(GntTree *tree, void *key, GntTreeRow *row, void *parent) +{ + GntTreeRow *pr = NULL, *br = NULL; + + if (parent) + pr = g_hash_table_lookup(tree->hash, parent); + + if (pr) + br = pr->child; + else + br = tree->root; + + if (br) + { + while (br->next) + br = br->next; + } + + return gnt_tree_add_row_after(tree, key, row, parent, br ? br->key : NULL); +} + gpointer gnt_tree_get_selection_data(GntTree *tree) { if (tree->current) @@ -954,3 +1031,8 @@ tree->show_title = set; } +void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func) +{ + tree->compare = func; +} + Modified: trunk/console/libgnt/gnttree.h =================================================================== --- trunk/console/libgnt/gnttree.h 2006-08-13 17:38:25 UTC (rev 16738) +++ trunk/console/libgnt/gnttree.h 2006-08-13 23:30:19 UTC (rev 16739) @@ -46,6 +46,8 @@ char *title; } *columns; /* Would a GList be better? */ gboolean show_title; + + GCompareFunc compare; }; struct _GnTreeClass @@ -76,6 +78,8 @@ GntTreeRow *gnt_tree_add_row_after(GntTree *tree, void *key, GntTreeRow *row, void *parent, void *bigbro); +GntTreeRow *gnt_tree_add_row_last(GntTree *tree, void *key, GntTreeRow *row, void *parent); + gpointer gnt_tree_get_selection_data(GntTree *tree); /* Returned string needs to be freed */ @@ -112,6 +116,8 @@ void gnt_tree_set_show_title(GntTree *tree, gboolean set); +void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func); + G_END_DECLS #endif /* GNT_TREE_H */ Modified: trunk/console/libgnt/test/focus.c =================================================================== --- trunk/console/libgnt/test/focus.c 2006-08-13 17:38:25 UTC (rev 16738) +++ trunk/console/libgnt/test/focus.c 2006-08-13 23:30:19 UTC (rev 16739) @@ -44,13 +44,19 @@ box = gnt_box_new(FALSE, FALSE); tree = gnt_tree_new(); + gnt_tree_set_compare_func(GNT_TREE(tree), g_utf8_collate); gnt_widget_set_name(tree, "tree"); gnt_box_add_widget(GNT_BOX(box), tree); gnt_box_add_widget(GNT_BOX(hbox), box); + gnt_tree_add_row_after(GNT_TREE(tree), "c", gnt_tree_create_row(GNT_TREE(tree), "c"), NULL, NULL); gnt_tree_add_row_after(GNT_TREE(tree), "a", gnt_tree_create_row(GNT_TREE(tree), "a"), NULL, NULL); - gnt_tree_add_row_after(GNT_TREE(tree), "c", gnt_tree_create_row(GNT_TREE(tree), "c"), NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "z", gnt_tree_create_row(GNT_TREE(tree), "z"), "a", NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "y", gnt_tree_create_row(GNT_TREE(tree), "y"), "a", NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "g", gnt_tree_create_row(GNT_TREE(tree), "g"), "a", NULL); gnt_tree_add_row_after(GNT_TREE(tree), "d", gnt_tree_create_row(GNT_TREE(tree), "d"), NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "x", gnt_tree_create_row(GNT_TREE(tree), "x"), "a", NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "k", gnt_tree_create_row(GNT_TREE(tree), "k"), "a", NULL); gnt_tree_add_row_after(GNT_TREE(tree), "e", gnt_tree_create_row(GNT_TREE(tree), "e"), "a", NULL); gnt_tree_add_choice(GNT_TREE(tree), "b", gnt_tree_create_row(GNT_TREE(tree), "b"), "d", NULL); Modified: trunk/console/libgnt/test/multiwin.c =================================================================== Modified: trunk/console/libgnt/test/tv.c =================================================================== --- trunk/console/libgnt/test/tv.c 2006-08-13 17:38:25 UTC (rev 16738) +++ trunk/console/libgnt/test/tv.c 2006-08-13 23:30:19 UTC (rev 16739) @@ -62,9 +62,10 @@ gnt_entry_set_always_suggest(GNT_ENTRY(entry), FALSE); gnt_entry_add_suggest(GNT_ENTRY(entry), "a"); gnt_entry_add_suggest(GNT_ENTRY(entry), "ab"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "abe"); gnt_entry_add_suggest(GNT_ENTRY(entry), "abc"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "abcde"); gnt_entry_add_suggest(GNT_ENTRY(entry), "abcd"); - gnt_entry_add_suggest(GNT_ENTRY(entry), "abcde"); gnt_entry_add_suggest(GNT_ENTRY(entry), "acb"); view = gnt_text_view_new(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-08-13 17:39:38
|
Revision: 16738 Author: roast Date: 2006-08-13 10:38:25 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16738&view=rev Log Message: ----------- merged with svn trunk. 16676:16737. Modified Paths: -------------- branches/soc-2006-file-loggers/configure.ac branches/soc-2006-file-loggers/console/gntblist.c branches/soc-2006-file-loggers/console/gntconv.c branches/soc-2006-file-loggers/console/gntprefs.c branches/soc-2006-file-loggers/console/gntrequest.c branches/soc-2006-file-loggers/console/libgnt/Makefile.am branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c branches/soc-2006-file-loggers/console/libgnt/gntentry.c branches/soc-2006-file-loggers/console/libgnt/gntentry.h branches/soc-2006-file-loggers/console/libgnt/gntkeys.h branches/soc-2006-file-loggers/console/libgnt/gntmain.c branches/soc-2006-file-loggers/console/libgnt/gnttree.c branches/soc-2006-file-loggers/console/libgnt/gnttree.h branches/soc-2006-file-loggers/console/libgnt/gntutils.c branches/soc-2006-file-loggers/console/libgnt/gntwidget.c branches/soc-2006-file-loggers/console/libgnt/test/tv.c branches/soc-2006-file-loggers/gaim.apspec.in branches/soc-2006-file-loggers/plugins/ChangeLog.API branches/soc-2006-file-loggers/plugins/log_reader.c branches/soc-2006-file-loggers/po/ChangeLog branches/soc-2006-file-loggers/po/de.po branches/soc-2006-file-loggers/po/fi.po branches/soc-2006-file-loggers/po/gl.po branches/soc-2006-file-loggers/po/gu.po branches/soc-2006-file-loggers/po/it.po branches/soc-2006-file-loggers/po/sl.po branches/soc-2006-file-loggers/po/zh_TW.po branches/soc-2006-file-loggers/src/account.c branches/soc-2006-file-loggers/src/ft.c branches/soc-2006-file-loggers/src/gtkaccount.c branches/soc-2006-file-loggers/src/gtkblist.c branches/soc-2006-file-loggers/src/gtkdialogs.c branches/soc-2006-file-loggers/src/plugin.c branches/soc-2006-file-loggers/src/protocols/irc/irc.c branches/soc-2006-file-loggers/src/protocols/jabber/JEPS branches/soc-2006-file-loggers/src/protocols/jabber/buddy.c branches/soc-2006-file-loggers/src/protocols/jabber/jabber.c branches/soc-2006-file-loggers/src/protocols/jabber/si.c branches/soc-2006-file-loggers/src/protocols/msn/directconn.c branches/soc-2006-file-loggers/src/protocols/msn/directconn.h branches/soc-2006-file-loggers/src/protocols/msn/httpconn.c branches/soc-2006-file-loggers/src/protocols/msn/nexus.c branches/soc-2006-file-loggers/src/protocols/msn/servconn.c branches/soc-2006-file-loggers/src/protocols/msn/slp.c branches/soc-2006-file-loggers/src/protocols/oscar/family_icbm.c branches/soc-2006-file-loggers/src/protocols/oscar/family_oservice.c branches/soc-2006-file-loggers/src/protocols/oscar/oscar.c branches/soc-2006-file-loggers/src/protocols/oscar/peer.c branches/soc-2006-file-loggers/src/protocols/oscar/peer.h branches/soc-2006-file-loggers/src/protocols/oscar/peer_proxy.c branches/soc-2006-file-loggers/src/protocols/qq/qq_proxy.c branches/soc-2006-file-loggers/src/protocols/sametime/sametime.c branches/soc-2006-file-loggers/src/protocols/silc/silc.c branches/soc-2006-file-loggers/src/protocols/silc/util.c branches/soc-2006-file-loggers/src/protocols/simple/simple.c branches/soc-2006-file-loggers/src/protocols/simple/simple.h branches/soc-2006-file-loggers/src/protocols/simple/sipmsg.c branches/soc-2006-file-loggers/src/protocols/simple/sipmsg.h branches/soc-2006-file-loggers/src/protocols/yahoo/yahoo.c branches/soc-2006-file-loggers/src/protocols/yahoo/yahoo_filexfer.c branches/soc-2006-file-loggers/src/protocols/yahoo/yahoo_picture.c branches/soc-2006-file-loggers/src/protocols/yahoo/yahoochat.c branches/soc-2006-file-loggers/src/protocols/yahoo/ycht.c branches/soc-2006-file-loggers/src/proxy.c branches/soc-2006-file-loggers/src/proxy.h branches/soc-2006-file-loggers/src/request.c branches/soc-2006-file-loggers/src/request.h branches/soc-2006-file-loggers/src/sslconn.c branches/soc-2006-file-loggers/src/upnp.c branches/soc-2006-file-loggers/src/util.c branches/soc-2006-file-loggers/src/xmlnode.h Added Paths: ----------- branches/soc-2006-file-loggers/console/libgnt/gntkeys.c branches/soc-2006-file-loggers/po/ne.po Modified: branches/soc-2006-file-loggers/configure.ac =================================================================== --- branches/soc-2006-file-loggers/configure.ac 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/configure.ac 2006-08-13 17:38:25 UTC (rev 16738) @@ -46,7 +46,7 @@ ;; esac -ALL_LINGUAS="am az bg bn bs ca ca@valencia cs da de el en_AU en_CA en_GB es et eu fa fi fr gl gu he hi hu it ja ka ko ku lt mk my_MM nb nl nn pa pl pt_BR pt ro ru sk sl sq sr sr@Latn sv ta te th tr uk vi xh zh_CN zh_TW" +ALL_LINGUAS="am az bg bn bs ca ca@valencia cs da de el en_AU en_CA en_GB es et eu fa fi fr gl gu he hi hu it ja ka ko ku lt mk my_MM nb ne nl nn pa pl pt_BR pt ro ru sk sl sq sr sr@Latn sv ta te th tr uk vi xh zh_CN zh_TW" AM_GLIB_GNU_GETTEXT dnl we don't use autobreak on cygwin!! @@ -546,7 +546,6 @@ if test "x$enable_debug" = "xyes" ; then AC_DEFINE(DEBUG, 1, [Define if debugging is enabled.]) - enable_fatal_asserts="yes" fi if test "x$enable_fatal_asserts" = "xyes" ; then @@ -1822,9 +1821,10 @@ echo echo Use XScreenSaver Extension.... : $enable_xss echo Use X Session Management...... : $enable_sm -echo Use startup notification.......: $enable_startup_notification +echo Use startup notification...... : $enable_startup_notification echo echo Print debugging messages...... : $enable_debug +echo Assertions are fatal.......... : $enable_fatal_asserts echo eval eval echo Gaim will be installed in $bindir. if test "x$gaimpath" != "x" ; then Modified: branches/soc-2006-file-loggers/console/gntblist.c =================================================================== --- branches/soc-2006-file-loggers/console/gntblist.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/gntblist.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -1,5 +1,6 @@ #include <account.h> #include <blist.h> +#include <notify.h> #include <request.h> #include <savedstatuses.h> #include <server.h> @@ -100,7 +101,6 @@ gnt_tree_remove(GNT_TREE(ggblist->tree), node); node->ui_data = NULL; - /* XXX: Depending on the node, we may want to remove the group/contact node if necessary */ if (GAIM_BLIST_NODE_IS_BUDDY(node)) { GaimGroup *group = gaim_buddy_get_group((GaimBuddy*)node); @@ -141,6 +141,103 @@ { } +static void +add_buddy_cb(void *data, GaimRequestFields *allfields) +{ + const char *username = gaim_request_fields_get_string(allfields, "screenname"); + const char *alias = gaim_request_fields_get_string(allfields, "alias"); + const char *group = gaim_request_fields_get_string(allfields, "group"); + GaimAccount *account = gaim_request_fields_get_account(allfields, "account"); + const char *error = NULL; + GaimGroup *grp; + GaimBuddy *buddy; + + if (!username) + error = _("You must provide a screename for the buddy."); + else if (!group) + error = _("You must provide a group."); + else if (!account) + error = _("You must select an account."); + + if (error) + { + gaim_notify_error(NULL, _("Error"), _("Error adding buddy"), error); + return; + } + + grp = gaim_find_group(group); + if (!grp) + { + grp = gaim_group_new(group); + gaim_blist_add_group(grp, NULL); + } + + buddy = gaim_buddy_new(account, username, alias); + gaim_blist_add_buddy(buddy, NULL, grp, NULL); + gaim_account_add_buddy(account, buddy); +} + +static void +gg_request_add_buddy(GaimAccount *account, const char *username, const char *grp, const char *alias) +{ + GaimRequestFields *fields = gaim_request_fields_new(); + GaimRequestFieldGroup *group = gaim_request_field_group_new(NULL); + GaimRequestField *field; + + gaim_request_fields_add_group(fields, group); + + field = gaim_request_field_string_new("screenname", _("Screen Name"), username, FALSE); + gaim_request_field_group_add_field(group, field); + + field = gaim_request_field_string_new("alias", _("Alias"), alias, FALSE); + gaim_request_field_group_add_field(group, field); + + field = gaim_request_field_string_new("group", _("Group"), grp, FALSE); + gaim_request_field_group_add_field(group, field); + + field = gaim_request_field_account_new("account", _("Account"), NULL); + gaim_request_field_account_set_show_all(field, FALSE); + if (account) + gaim_request_field_account_set_value(field, account); + gaim_request_field_group_add_field(group, field); + + gaim_request_fields(NULL, _("Add Buddy"), NULL, _("Please enter buddy information."), + fields, _("Add"), G_CALLBACK(add_buddy_cb), _("Cancel"), NULL, NULL); +} + +static void +add_group_cb(gpointer null, const char *group) +{ + GaimGroup *grp; + + if (!group || !*group) + { + gaim_notify_error(NULL, _("Error"), _("Error adding group"), + _("You must give a name for the group to add.")); + return; + } + + grp = gaim_find_group(group); + if (!grp) + { + grp = gaim_group_new(group); + gaim_blist_add_group(grp, NULL); + } + else + { + gaim_notify_error(NULL, _("Error"), _("Error adding group"), + _("A group with the name already exists.")); + } +} + +static void +gg_request_add_group() +{ + gaim_request_input(NULL, _("Add Group"), NULL, _("Enter the name of the group"), + NULL, FALSE, FALSE, NULL, + _("Add"), G_CALLBACK(add_group_cb), _("Cancel"), NULL, NULL); +} + static GaimBlistUiOps blist_ui_ops = { new_list, @@ -150,9 +247,9 @@ node_remove, NULL, NULL, + .request_add_buddy = gg_request_add_buddy, NULL, - NULL, - NULL + .request_add_group = gg_request_add_group }; static gpointer @@ -360,8 +457,24 @@ } static void +gg_add_buddy(GaimGroup *grp, GaimBlistNode *node) +{ + gaim_blist_request_add_buddy(NULL, NULL, grp->name, NULL); +} + +static void +gg_add_group(GaimGroup *grp, GaimBlistNode *node) +{ + gaim_blist_request_add_group(); +} + +static void create_group_menu(GntTree *tree, GaimGroup *group) { + add_custom_action(tree, _("Add Buddy"), + GAIM_CALLBACK(gg_add_buddy), group); + add_custom_action(tree, _("Add Group"), + GAIM_CALLBACK(gg_add_group), group); } static void @@ -476,26 +589,91 @@ g_free(prompt); } -/* XXX: This still doesn't do anything, because request doesn't have a ui yet */ +/* Xeroxed from gtkdialogs.c:gaim_gtkdialogs_remove_group_cb*/ static void +remove_group(GaimGroup *group) +{ + GaimBlistNode *cnode, *bnode; + + cnode = ((GaimBlistNode*)group)->child; + + while (cnode) { + if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { + bnode = cnode->child; + cnode = cnode->next; + while (bnode) { + GaimBuddy *buddy; + if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { + buddy = (GaimBuddy*)bnode; + bnode = bnode->next; + if (gaim_account_is_connected(buddy->account)) { + gaim_account_remove_buddy(buddy->account, buddy, group); + gaim_blist_remove_buddy(buddy); + } + } else { + bnode = bnode->next; + } + } + } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { + GaimChat *chat = (GaimChat *)cnode; + cnode = cnode->next; + if (gaim_account_is_connected(chat->account)) + gaim_blist_remove_chat(chat); + } else { + cnode = cnode->next; + } + } + + gaim_blist_remove_group(group); +} + +static void +gg_blist_remove_node(GaimBlistNode *node) +{ + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + { + GaimBuddy *buddy = (GaimBuddy*)node; + GaimGroup *group = gaim_buddy_get_group(buddy); + gaim_account_remove_buddy(gaim_buddy_get_account(buddy), buddy, group); + gaim_blist_remove_buddy(buddy); + } + else if (GAIM_BLIST_NODE_IS_CHAT(node)) + { + gaim_blist_remove_chat((GaimChat*)node); + } + else if (GAIM_BLIST_NODE_IS_GROUP(node)) + { + remove_group((GaimGroup*)node); + } +} + +static void gg_blist_remove_node_cb(GaimBlistNode *node, GaimBlistNode *null) { - void (*callback)(gpointer); + char *primary, *sec = NULL; + const char *name; if (GAIM_BLIST_NODE_IS_BUDDY(node)) - callback = (void(*)(gpointer))gaim_blist_remove_buddy; + name = gaim_buddy_get_name((GaimBuddy*)node); else if (GAIM_BLIST_NODE_IS_CHAT(node)) - callback = (void(*)(gpointer))gaim_blist_remove_chat; + name = gaim_chat_get_name((GaimChat*)node); else if (GAIM_BLIST_NODE_IS_GROUP(node)) - callback = (void(*)(gpointer))gaim_blist_remove_group; + { + name = ((GaimGroup*)node)->name; + sec = _("Removing this group will also remove all the buddies in the group"); + } + else + return; + primary = g_strdup_printf(_("Are you sure you want to remove %s?"), name); + /* XXX: anything to do with the returned ui-handle? */ gaim_request_action(node, _("Confirm Remove"), - _("Are you sure you want to remove ..."), NULL, /* XXX: tidy up */ + primary, sec, 1, node, 2, - _("Remove"), callback, - _("No"), NULL); - + _("Remove"), gg_blist_remove_node, + _("Cancel"), NULL); + g_free(primary); } static void @@ -555,6 +733,7 @@ GAIM_CALLBACK(gg_blist_remove_node_cb), node); window = gnt_vbox_new(FALSE); + GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT); gnt_box_set_toplevel(GNT_BOX(window), TRUE); gnt_box_set_title(GNT_BOX(window), title); @@ -634,6 +813,18 @@ g_free(br); } + if (gaim_prefs_get_bool("/gaim/gnt/blist/idletime")) + { + GaimPresence *pre = gaim_buddy_get_presence(buddy); + if (gaim_presence_is_idle(pre)) + { + time_t idle = gaim_presence_get_idle_time(pre); + char *st = gaim_str_seconds_to_string(time(NULL) - idle); + g_string_append_printf(str, _("\nIdle: %s"), st); + g_free(st); + } + } + title = g_strdup(gaim_buddy_get_name(buddy)); } else if (GAIM_BLIST_NODE_IS_GROUP(node)) Modified: branches/soc-2006-file-loggers/console/gntconv.c =================================================================== --- branches/soc-2006-file-loggers/console/gntconv.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/gntconv.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -123,6 +123,7 @@ } g_free(escape); } + gnt_entry_add_to_history(GNT_ENTRY(ggconv->entry), text); gnt_entry_clear(GNT_ENTRY(ggconv->entry)); return TRUE; } @@ -198,8 +199,11 @@ ggc->entry = gnt_entry_new(NULL); gnt_box_add_widget(GNT_BOX(ggc->window), ggc->entry); gnt_widget_set_name(ggc->entry, "conversation-window-entry"); + gnt_entry_set_history_length(GNT_ENTRY(ggc->entry), -1); + gnt_entry_set_word_suggest(GNT_ENTRY(ggc->entry), TRUE); + gnt_entry_set_always_suggest(GNT_ENTRY(ggc->entry), FALSE); - g_signal_connect(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc); + g_signal_connect_after(G_OBJECT(ggc->entry), "key_pressed", G_CALLBACK(entry_key_pressed), ggc); g_signal_connect(G_OBJECT(ggc->window), "destroy", G_CALLBACK(closing_window), ggc); gnt_widget_set_position(ggc->window, gaim_prefs_get_int(PREF_ROOT "/position/x"), @@ -229,6 +233,9 @@ g_return_if_fail(ggconv != NULL); + if (gaim_prefs_get_bool("/gaim/gnt/conversations/timestamps")) + gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(ggconv->tv), + gaim_utf8_strftime("(%H:%M:%S) ", localtime(&mtime)), GNT_TEXT_FLAG_DIM); if (who && *who && (flags & (GAIM_MESSAGE_SEND | GAIM_MESSAGE_RECV))) { char * name = g_strdup_printf("%s: ", who); @@ -312,6 +319,9 @@ static void gg_chat_add_users(GaimConversation *conv, GList *users, gboolean new_arrivals) { + GGConv *ggc = conv->ui_data; + GntEntry *entry = GNT_ENTRY(ggc->entry); + if (!new_arrivals) { /* Print the list of users in the room */ @@ -332,25 +342,39 @@ GAIM_MESSAGE_SYSTEM, time(NULL)); g_string_free(string, TRUE); } - /* XXX: Add the names for string completion */ + + for (; users; users = users->next) + { + GaimConvChatBuddy *cbuddy = users->data; + gnt_entry_add_suggest(entry, cbuddy->name); + gnt_entry_add_suggest(entry, cbuddy->alias); + } } static void gg_chat_rename_user(GaimConversation *conv, const char *old, const char *new_n, const char *new_a) { /* XXX: Update the name for string completion */ + GGConv *ggc = conv->ui_data; + GntEntry *entry = GNT_ENTRY(ggc->entry); + gnt_entry_remove_suggest(entry, old); + gnt_entry_add_suggest(entry, new_n); + gnt_entry_add_suggest(entry, new_a); } static void gg_chat_remove_user(GaimConversation *conv, GList *list) { /* XXX: Remove the name from string completion */ + GGConv *ggc = conv->ui_data; + GntEntry *entry = GNT_ENTRY(ggc->entry); + for (; list; list = list->next) + gnt_entry_remove_suggest(entry, list->data); } static void gg_chat_update_user(GaimConversation *conv, const char *user) { - /* XXX: This probably will not require updating the string completion */ } static GaimConversationUiOps conv_ui_ops = Modified: branches/soc-2006-file-loggers/console/gntprefs.c =================================================================== --- branches/soc-2006-file-loggers/console/gntprefs.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/gntprefs.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -14,9 +14,12 @@ gaim_prefs_add_none("/gaim/gnt/plugins"); gaim_prefs_add_string_list("/gaim/gnt/plugins/loaded", NULL); + gaim_prefs_add_none("/gaim/gnt/blist"); + gaim_prefs_add_bool("/gaim/gnt/blist/idletime", TRUE); + gaim_prefs_add_none("/gaim/gnt/conversations"); gaim_prefs_add_bool("/gaim/gnt/conversations/timestamps", TRUE); - gaim_prefs_add_bool("/gaim/gnt/conversations/notify_typing", FALSE); + gaim_prefs_add_bool("/gaim/gnt/conversations/notify_typing", FALSE); /* XXX: Not functional yet */ } typedef struct @@ -93,6 +96,12 @@ return field; } +static Prefs blist[] = +{ + {GAIM_PREF_BOOLEAN, "/gaim/gnt/blist/idletime", _("Show Idle Time"), NULL}, + {GAIM_PREF_NONE, NULL, NULL, NULL} +}; + static Prefs convs[] = { {GAIM_PREF_BOOLEAN, "/gaim/gnt/conversations/timestamps", _("Show Timestamps"), NULL}, @@ -163,31 +172,32 @@ } } -void gg_prefs_show_all() +static void +add_pref_group(GaimRequestFields *fields, const char *title, Prefs *prefs) { - GaimRequestFields *fields; GaimRequestField *field; GaimRequestFieldGroup *group; int i; - fields = gaim_request_fields_new(); - - group = gaim_request_field_group_new(_("Conversations")); + group = gaim_request_field_group_new(title); gaim_request_fields_add_group(fields, group); - for (i = 0; convs[i].pref; i++) + for (i = 0; prefs[i].pref; i++) { - field = get_pref_field(convs + i); + field = get_pref_field(prefs + i); gaim_request_field_group_add_field(group, field); } +} - group = gaim_request_field_group_new(_("Logging")); - gaim_request_fields_add_group(fields, group); - for (i = 0; logging[i].pref; i++) - { - field = get_pref_field(logging + i); - gaim_request_field_group_add_field(group, field); - } +void gg_prefs_show_all() +{ + GaimRequestFields *fields; + fields = gaim_request_fields_new(); + + add_pref_group(fields, _("Buddy List"), blist); + add_pref_group(fields, _("Conversations"), convs); + add_pref_group(fields, _("Logging"), logging); + gaim_request_fields(NULL, _("Preferences"), NULL, NULL, fields, _("Save"), G_CALLBACK(save_cb), _("Cancel"), NULL, NULL); } Modified: branches/soc-2006-file-loggers/console/gntrequest.c =================================================================== --- branches/soc-2006-file-loggers/console/gntrequest.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/gntrequest.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -182,7 +182,7 @@ window = setup_request_window(title, primary, secondary, GAIM_REQUEST_ACTION); - box = gnt_hbox_new(TRUE); + box = gnt_hbox_new(FALSE); gnt_box_add_widget(GNT_BOX(window), box); for (i = 0; i < actioncount; i++) { @@ -234,7 +234,8 @@ else if (type == GAIM_REQUEST_FIELD_STRING) { GntWidget *entry = field->ui_data; - gaim_request_field_string_set_value(field, gnt_entry_get_text(GNT_ENTRY(entry))); + const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); + gaim_request_field_string_set_value(field, (text && *text) ? text : NULL); } else if (type == GAIM_REQUEST_FIELD_INTEGER) { @@ -278,6 +279,9 @@ } else if (type == GAIM_REQUEST_FIELD_ACCOUNT) { + GntWidget *combo = field->ui_data; + GaimAccount *acc = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)); + gaim_request_field_account_set_value(field, acc); } } } @@ -293,13 +297,13 @@ static void * gg_request_fields(const char *title, const char *primary, - const char *secondary, GaimRequestFields *fields, + const char *secondary, GaimRequestFields *allfields, const char *ok, GCallback ok_cb, const char *cancel, GCallback cancel_cb, void *userdata) { GntWidget *window, *box; - GList *list; + GList *grlist; window = setup_request_window(title, primary, secondary, GAIM_REQUEST_FIELDS); @@ -309,27 +313,28 @@ box = gnt_vbox_new(FALSE); gnt_box_set_pad(GNT_BOX(box), 0); gnt_box_set_fill(GNT_BOX(box), TRUE); - for (list = gaim_request_fields_get_groups(fields); list; list = list->next) + for (grlist = gaim_request_fields_get_groups(allfields); grlist; grlist = grlist->next) { - GaimRequestFieldGroup *group = list->data; + GaimRequestFieldGroup *group = grlist->data; GList *fields = gaim_request_field_group_get_fields(group); GntWidget *hbox; - - gnt_box_add_widget(GNT_BOX(box), - gnt_label_new_with_format(gaim_request_field_group_get_title(group), - GNT_TEXT_FLAG_BOLD)); + const char *title = gaim_request_field_group_get_title(group); + if (title) + gnt_box_add_widget(GNT_BOX(box), + gnt_label_new_with_format(title, GNT_TEXT_FLAG_BOLD)); + for (; fields ; fields = fields->next) { + /* XXX: Break each of the fields into a separate function? */ GaimRequestField *field = fields->data; GaimRequestFieldType type = gaim_request_field_get_type(field); const char *label = gaim_request_field_get_label(field); - hbox = gnt_hbox_new(FALSE); - gnt_box_set_pad(GNT_BOX(hbox), 0); + hbox = gnt_hbox_new(TRUE); /* hrm */ gnt_box_add_widget(GNT_BOX(box), hbox); - if (type != GAIM_REQUEST_FIELD_BOOLEAN) + if (type != GAIM_REQUEST_FIELD_BOOLEAN && label) { GntWidget *l = gnt_label_new(label); gnt_widget_set_size(l, 0, 1); @@ -417,12 +422,44 @@ } } } -#if 0 else if (type == GAIM_REQUEST_FIELD_ACCOUNT) { - /* XXX: remember to set the field->ui_data */ + gboolean all; + GaimAccount *def; + GList *list; + GntWidget *combo = gnt_combo_box_new(); + gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); + gnt_box_add_widget(GNT_BOX(hbox), combo); + field->ui_data = combo; + + all = gaim_request_field_account_get_show_all(field); + def = gaim_request_field_account_get_default_value(field); + + if (all) + list = gaim_accounts_get_all(); + else + list = gaim_connections_get_all(); + + for (; list; list = list->next) + { + GaimAccount *account; + char *text; + + if (all) + account = list->data; + else + account = gaim_connection_get_account(list->data); + + text = g_strdup_printf("%s (%s)", + gaim_account_get_username(account), + gaim_account_get_protocol_name(account)); + gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text); + g_free(text); + if (account == def) + gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account); + } + gnt_widget_set_size(combo, 20, 3); /* ew */ } -#endif else { gnt_box_add_widget(GNT_BOX(hbox), @@ -430,12 +467,12 @@ GNT_TEXT_FLAG_BOLD)); } } - if (list->next) + if (grlist->next) gnt_box_add_widget(GNT_BOX(box), gnt_hline_new()); } gnt_box_add_widget(GNT_BOX(window), box); - box = setup_button_box(userdata, request_fields_cb, fields, + box = setup_button_box(userdata, request_fields_cb, allfields, ok, ok_cb, cancel, cancel_cb, NULL); gnt_box_add_widget(GNT_BOX(window), box); Modified: branches/soc-2006-file-loggers/console/libgnt/Makefile.am =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/Makefile.am 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/Makefile.am 2006-08-13 17:38:25 UTC (rev 16738) @@ -11,6 +11,7 @@ gntcolors.c \ gntcombobox.c \ gntentry.c \ + gntkeys.c \ gntlabel.c \ gntline.c \ gntmarshal.c \ Modified: branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/gntcombobox.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -74,8 +74,13 @@ static void gnt_combo_box_size_request(GntWidget *widget) { - widget->priv.height = 3; /* For now, a combobox will have border */ - widget->priv.width = 15; + if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_MAPPED)) + { + GntWidget *dd = GNT_COMBO_BOX(widget)->dropdown; + gnt_widget_size_request(dd); + widget->priv.height = 3; /* For now, a combobox will have border */ + widget->priv.width = MIN(10, dd->priv.width + 4); + } } static void Modified: branches/soc-2006-file-loggers/console/libgnt/gntentry.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntentry.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/gntentry.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -1,7 +1,9 @@ #include <ctype.h> #include <string.h> +#include "gntbox.h" #include "gntentry.h" +#include "gnttree.h" enum { @@ -12,6 +14,92 @@ static guint signals[SIGS] = { 0 }; static void +destroy_suggest(GntEntry *entry) +{ + if (entry->ddown) + { + gnt_widget_destroy(entry->ddown->parent); + entry->ddown = NULL; + } +} + +static char * +get_beginning_of_word(GntEntry *entry) +{ + char *s = entry->cursor; + while (s > entry->start) + { + char *t = g_utf8_find_prev_char(entry->start, s); + if ((*t < 'A' || *t > 'Z') && (*t < 'a' || *t > 'z')) + break; + s = t; + } + return s; +} + +static gboolean +show_suggest_dropdown(GntEntry *entry) +{ + char *suggest = NULL; + int len; + int offset = 0, x, y; + int count = 0; + GList *iter; + + if (entry->word) + { + char *s = get_beginning_of_word(entry); + suggest = g_strndup(s, entry->cursor - s); + if (entry->scroll < s) + offset = g_utf8_pointer_to_offset(entry->scroll, s); + } + else + suggest = g_strdup(entry->start); + len = strlen(suggest); /* Don't need to use the utf8-function here */ + + if (entry->ddown == NULL) + { + GntWidget *box = gnt_vbox_new(FALSE); + entry->ddown = gnt_tree_new(); + gnt_box_add_widget(GNT_BOX(box), entry->ddown); + + GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT); + + gnt_widget_get_position(GNT_WIDGET(entry), &x, &y); + x += offset; + y++; + if (y + 10 >= getmaxy(stdscr)) + y -= 11; + gnt_widget_set_position(box, x, y); + + gnt_widget_draw(box); + } + else + gnt_tree_remove_all(GNT_TREE(entry->ddown)); + + for (count = 0, iter = entry->suggests; iter; iter = iter->next) + { + const char *text = iter->data; + if (g_ascii_strncasecmp(suggest, text, len) == 0 && strlen(text) >= len) + { + gnt_tree_add_row_after(GNT_TREE(entry->ddown), (gpointer)text, + gnt_tree_create_row(GNT_TREE(entry->ddown), text), + NULL, NULL); + count++; + } + } + g_free(suggest); + + if (count == 0) + { + destroy_suggest(entry); + return FALSE; + } + + return TRUE; +} + +static void gnt_entry_draw(GntWidget *widget) { GntEntry *entry = GNT_ENTRY(widget); @@ -80,6 +168,11 @@ memmove(entry->cursor, entry->cursor + len, entry->end - entry->cursor - len + 1); entry->end -= len; entry_redraw(widget); + + if (entry->ddown) + show_suggest_dropdown(entry); + + return TRUE; } else if (strcmp(text + 1, GNT_KEY_LEFT) == 0 && entry->cursor > entry->start) { @@ -87,6 +180,8 @@ if (entry->cursor < entry->scroll) entry->scroll = entry->cursor; entry_redraw(widget); + + return TRUE; } else if (strcmp(text + 1, GNT_KEY_RIGHT) == 0 && entry->cursor < entry->end) { @@ -94,15 +189,89 @@ if (g_utf8_pointer_to_offset(entry->scroll, entry->cursor) >= widget->priv.width) entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); entry_redraw(widget); + + return TRUE; } + else if (strcmp(text + 1, GNT_KEY_CTRL_DOWN) == 0 && entry->histlength) + { + if (entry->history->prev) + { + entry->history = entry->history->prev; + gnt_entry_set_text(entry, entry->history->data); + destroy_suggest(entry); + + return TRUE; + } + } + else if (strcmp(text + 1, GNT_KEY_UP) == 0 || + strcmp(text + 1, GNT_KEY_DOWN) == 0) + { + if (entry->ddown) + { + gnt_widget_key_pressed(entry->ddown, text); + return TRUE; + } + } + else if (strcmp(text + 1, GNT_KEY_CTRL_UP) == 0 && entry->histlength) + { + if (entry->history->next) + { + if (entry->history->prev == NULL) + { + /* Save the current contents */ + char *text = g_strdup(gnt_entry_get_text(entry)); + g_free(entry->history->data); + entry->history->data = text; + } + + entry->history = entry->history->next; + gnt_entry_set_text(entry, entry->history->data); + destroy_suggest(entry); + + return TRUE; + } + } /* XXX: handle other keys, like home/end, and ctrl+ goodness */ - else - return FALSE; + else if (text[1] == 0) + { + destroy_suggest(entry); + } - return TRUE; + return FALSE; } else { + if (text[0] == '\t') + { + if (entry->ddown) + destroy_suggest(entry); + else if (entry->suggests) + return show_suggest_dropdown(entry); + + return FALSE; + } + else if (text[0] == '\r' && entry->ddown) + { + char *text = g_strdup(gnt_tree_get_selection_data(GNT_TREE(entry->ddown))); + destroy_suggest(entry); + if (entry->word) + { + char *s = get_beginning_of_word(entry); + char *iter = text; + while (toupper(*s) == toupper(*iter)) + { + *s++ = *iter++; + } + gnt_entry_key_pressed(widget, iter); + } + else + { + gnt_entry_set_text(entry, text); + } + g_free(text); + return TRUE; + } + if (!iscntrl(text[0])) { const char *str, *next; @@ -143,6 +312,9 @@ while (g_utf8_pointer_to_offset(entry->scroll, entry->cursor) >= widget->priv.width) entry->scroll = g_utf8_find_next_char(entry->scroll, NULL); + + if (entry->ddown) + show_suggest_dropdown(entry); } entry_redraw(widget); return TRUE; @@ -161,6 +333,8 @@ entry->scroll = g_utf8_find_prev_char(entry->start, entry->scroll); entry_redraw(widget); + if (entry->ddown) + show_suggest_dropdown(entry); return TRUE; } } @@ -174,9 +348,35 @@ { GntEntry *entry = GNT_ENTRY(widget); g_free(entry->start); + + if (entry->history) + { + entry->history = g_list_first(entry->history); + g_list_foreach(entry->history, (GFunc)g_free, NULL); + g_list_free(entry->history); + } + + if (entry->suggests) + { + g_list_foreach(entry->suggests, (GFunc)g_free, NULL); + g_list_free(entry->suggests); + } + + if (entry->ddown) + { + gnt_widget_destroy(entry->ddown->parent); + } } static void +gnt_entry_lost_focus(GntWidget *widget) +{ + GntEntry *entry = GNT_ENTRY(widget); + destroy_suggest(entry); + entry_redraw(widget); +} + +static void gnt_entry_class_init(GntEntryClass *klass) { parent_class = GNT_WIDGET_CLASS(klass); @@ -185,6 +385,7 @@ parent_class->map = gnt_entry_map; parent_class->size_request = gnt_entry_size_request; parent_class->key_pressed = gnt_entry_key_pressed; + parent_class->lost_focus = gnt_entry_lost_focus; DEBUG; } @@ -197,7 +398,14 @@ entry->flag = GNT_ENTRY_FLAG_ALL; entry->max = 0; + + entry->histlength = 0; + entry->history = NULL; + entry->word = TRUE; + entry->always = FALSE; + entry->suggests = NULL; + GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW | GNT_WIDGET_CAN_TAKE_FOCUS); GNT_WIDGET_SET_FLAGS(GNT_WIDGET(entry), GNT_WIDGET_GROW_X); @@ -302,6 +510,7 @@ gnt_entry_set_text(entry, NULL); entry->scroll = entry->cursor = entry->end = entry->start; entry_redraw(GNT_WIDGET(entry)); + destroy_suggest(entry); } void gnt_entry_set_masked(GntEntry *entry, gboolean set) @@ -309,3 +518,90 @@ entry->masked = set; } +void gnt_entry_add_to_history(GntEntry *entry, const char *text) +{ + g_return_if_fail(entry->history != NULL); /* Need to set_history_length first */ + + if (g_list_length(entry->history) >= entry->histlength) + return; + + entry->history = g_list_first(entry->history); + g_free(entry->history->data); + entry->history->data = g_strdup(text); + entry->history = g_list_prepend(entry->history, NULL); +} + +void gnt_entry_set_history_length(GntEntry *entry, int num) +{ + if (num == 0) + { + entry->histlength = num; + if (entry->history) + { + entry->history = g_list_first(entry->history); + g_list_foreach(entry->history, (GFunc)g_free, NULL); + g_list_free(entry->history); + entry->history = NULL; + } + return; + } + + if (entry->histlength == 0) + { + entry->histlength = num; + entry->history = g_list_append(NULL, NULL); + return; + } + + if (num > 0 && num < entry->histlength) + { + GList *first, *iter; + int index = 0; + for (first = entry->history, index = 0; first->prev; first = first->prev, index++); + while ((iter = g_list_nth(first, num)) != NULL) + { + g_free(iter->data); + first = g_list_delete_link(first, iter); + } + entry->histlength = num; + if (index >= num) + entry->history = g_list_last(first); + return; + } + + entry->histlength = num; +} + +void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word) +{ + entry->word = word; +} + +void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always) +{ + entry->always = always; +} + +void gnt_entry_add_suggest(GntEntry *entry, const char *text) +{ + GList *find; + + if (!text || !*text) + return; + + find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate); + if (find) + return; + entry->suggests = g_list_append(entry->suggests, g_strdup(text)); +} + +void gnt_entry_remove_suggest(GntEntry *entry, const char *text) +{ + GList *find = g_list_find_custom(entry->suggests, text, (GCompareFunc)g_utf8_collate); + if (find) + { + g_free(find->data); + entry->suggests = g_list_delete_link(entry->suggests, find); + } +} + Modified: branches/soc-2006-file-loggers/console/libgnt/gntentry.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntentry.h 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/gntentry.h 2006-08-13 17:38:25 UTC (rev 16738) @@ -50,6 +50,14 @@ int max; /* 0 means infinite */ gboolean masked; + + GList *history; /* History of the strings. User can use this by pressing ctrl+up/down */ + int histlength; /* How long can the history be? */ + + GList *suggests; /* List of suggestions */ + gboolean word; /* Are the suggestions for only a word, or for the whole thing? */ + gboolean always; /* Should the list of suggestions show at all times, or only on tab-press? */ + GntWidget *ddown; /* The dropdown with the suggested list */ }; struct _GnEntryClass @@ -70,7 +78,6 @@ void gnt_entry_set_max(GntEntry *entry, int max); -/* XXX: For now, call gnt_entry_clear before calling this */ void gnt_entry_set_text(GntEntry *entry, const char *text); void gnt_entry_set_flag(GntEntry *entry, GntEntryFlag flag); @@ -81,6 +88,18 @@ void gnt_entry_set_masked(GntEntry *entry, gboolean set); +void gnt_entry_add_to_history(GntEntry *entry, const char *text); + +void gnt_entry_set_history_length(GntEntry *entry, int num); + +void gnt_entry_set_word_suggest(GntEntry *entry, gboolean word); + +void gnt_entry_set_always_suggest(GntEntry *entry, gboolean always); + +void gnt_entry_add_suggest(GntEntry *entry, const char *text); + +void gnt_entry_remove_suggest(GntEntry *entry, const char *text); + G_END_DECLS #endif /* GNT_ENTRY_H */ Copied: branches/soc-2006-file-loggers/console/libgnt/gntkeys.c (from rev 16737, trunk/console/libgnt/gntkeys.c) =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntkeys.c (rev 0) +++ branches/soc-2006-file-loggers/console/libgnt/gntkeys.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -0,0 +1,29 @@ +#include "gntkeys.h" + +#include <string.h> + +void gnt_keys_refine(char *text) +{ + if (text[0] == 27) + { + /* These are for urxvt */ + if (strcmp(text + 1, "Oa") == 0) + { + strcpy(text + 1, GNT_KEY_CTRL_UP); + } + else if (strcmp(text + 1, "Ob") == 0) + { + strcpy(text + 1, GNT_KEY_CTRL_DOWN); + } + } + else if ((unsigned char)text[0] == 195) + { + /* These for xterm */ + if (text[2] == 0) + { + text[0] = 27; + text[1] -= 64; + } + } +} + Modified: branches/soc-2006-file-loggers/console/libgnt/gntkeys.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntkeys.h 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/gntkeys.h 2006-08-13 17:38:25 UTC (rev 16738) @@ -9,6 +9,11 @@ #define GNT_KEY_UP "[A" #define GNT_KEY_DOWN "[B" +#define GNT_KEY_CTRL_UP "[1;5A" +#define GNT_KEY_CTRL_DOWN "[1;5B" +#define GNT_KEY_CTRL_RIGHT "[1;5C" +#define GNT_KEY_CTRL_LEFT "[1;5D" + #define GNT_KEY_PGUP "[5~" #define GNT_KEY_PGDOWN "[6~" @@ -17,4 +22,9 @@ #define GNT_KEY_BACKSPACE "\177" #define GNT_KEY_DEL "[3~" +/** + * This will do stuff with the terminal settings and stuff. + */ +void gnt_keys_refine(char *text); + #endif Modified: branches/soc-2006-file-loggers/console/libgnt/gntmain.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntmain.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/gntmain.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -13,6 +13,11 @@ #include <unistd.h> #include <string.h> +/** + * Notes: Interesting functions to look at: + * scr_dump, scr_init, scr_restore: for workspaces + */ + static int lock_focus_list; static GList *focus_list; @@ -52,6 +57,14 @@ static void draw_taskbar(); static void bring_on_top(GntWidget *widget); +static gboolean +update_screen(gpointer null) +{ + update_panels(); + doupdate(); + return TRUE; +} + void gnt_screen_take_focus(GntWidget *widget) { GntWidget *w = NULL; @@ -119,8 +132,7 @@ GntNode *nd = g_hash_table_lookup(nodes, window_list.window); top_panel(nd->panel); } - update_panels(); - doupdate(); + update_screen(NULL); draw_taskbar(); } @@ -437,6 +449,8 @@ dump_screen(); } + gnt_keys_refine(buffer); + if (mode == GNT_KP_MODE_NORMAL) { if (focus_list) @@ -499,6 +513,14 @@ { shift_window(focus_list->data, 1); } + else if (strcmp(buffer + 1, "l") == 0) + { + touchwin(stdscr); + touchwin(newscr); + wrefresh(newscr); + update_screen(NULL); + draw_taskbar(); + } } } } @@ -557,8 +579,7 @@ GntNode *node = g_hash_table_lookup(nodes, widget); gnt_widget_set_position(widget, x, y); move_panel(node->panel, y, x); - update_panels(); - doupdate(); + update_screen(NULL); } } else if (*buffer == '\r') @@ -656,6 +677,10 @@ ascii_only = TRUE; initscr(); + typeahead(-1); + noecho(); + curs_set(0); + gnt_init_colors(); gnt_init_styles(); @@ -671,7 +696,6 @@ nodes = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_node); wbkgdset(stdscr, '\0' | COLOR_PAIR(GNT_COLOR_NORMAL)); - noecho(); refresh(); #if 0 mousemask(NCURSES_BUTTON_PRESSED | NCURSES_BUTTON_RELEASED | REPORT_MOUSE_POSITION, NULL); @@ -729,8 +753,7 @@ } } - update_panels(); - doupdate(); + update_screen(NULL); } void gnt_screen_release(GntWidget *widget) @@ -750,8 +773,7 @@ gnt_tree_remove(GNT_TREE(window_list.tree), widget); } - update_panels(); - doupdate(); + update_screen(NULL); } void gnt_screen_update(GntWidget *widget) @@ -779,8 +801,7 @@ top_panel(nd->panel); } - update_panels(); - doupdate(); + update_screen(NULL); } gboolean gnt_widget_has_focus(GntWidget *widget) @@ -844,8 +865,7 @@ gnt_widget_draw(widget); replace_panel(node->panel, widget->window); show_panel(node->panel); - update_panels(); - doupdate(); + update_screen(NULL); } } Modified: branches/soc-2006-file-loggers/console/libgnt/gnttree.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gnttree.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/gnttree.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -770,6 +770,15 @@ } } +void gnt_tree_remove_all(GntTree *tree) +{ + tree->root = NULL; + g_hash_table_remove_all(tree->hash); + g_list_free(tree->list); + tree->list = NULL; + tree->current = tree->top = tree->bottom = NULL; +} + int gnt_tree_get_selection_visible_line(GntTree *tree) { return get_distance(tree->top, tree->current) + Modified: branches/soc-2006-file-loggers/console/libgnt/gnttree.h =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gnttree.h 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/gnttree.h 2006-08-13 17:38:25 UTC (rev 16738) @@ -85,6 +85,8 @@ void gnt_tree_remove(GntTree *tree, gpointer key); +void gnt_tree_remove_all(GntTree *tree); + /* Returns the visible line number of the selected row */ int gnt_tree_get_selection_visible_line(GntTree *tree); Modified: branches/soc-2006-file-loggers/console/libgnt/gntutils.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntutils.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/gntutils.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -8,23 +8,26 @@ /* XXX: ew ... everyone look away */ last = s; - while (*s) + if (s) { - if (*s == '\n' || *s == '\r') + while (*s) { - count++; - len = g_utf8_pointer_to_offset(last, s); - if (max < len) - max = len; - last = s + 1; + if (*s == '\n' || *s == '\r') + { + count++; + len = g_utf8_pointer_to_offset(last, s); + if (max < len) + max = len; + last = s + 1; + } + s++; } - s++; + + len = g_utf8_pointer_to_offset(last, s); + if (max < len) + max = len; } - len = g_utf8_pointer_to_offset(last, s); - if (max < len) - max = len; - if (height) *height = count; if (width) Modified: branches/soc-2006-file-loggers/console/libgnt/gntwidget.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/gntwidget.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/gntwidget.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -80,6 +80,23 @@ return TRUE; } +static gboolean +gnt_boolean_handled_accumulator(GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer dummy) +{ + gboolean continue_emission; + gboolean signal_handled; + + signal_handled = g_value_get_boolean (handler_return); + g_value_set_boolean (return_accu, signal_handled); + continue_emission = !signal_handled; + + return continue_emission; +} + + static void gnt_widget_class_init(GntWidgetClass *klass) { @@ -194,7 +211,7 @@ G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(GntWidgetClass, key_pressed), - NULL, NULL, + gnt_boolean_handled_accumulator, NULL, gnt_closure_marshal_BOOLEAN__STRING, G_TYPE_BOOLEAN, 1, G_TYPE_STRING); DEBUG; Modified: branches/soc-2006-file-loggers/console/libgnt/test/tv.c =================================================================== --- branches/soc-2006-file-loggers/console/libgnt/test/tv.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/console/libgnt/test/tv.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -14,19 +14,24 @@ gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), gnt_entry_get_text(GNT_ENTRY(w)), GNT_TEXT_FLAG_HIGHLIGHT); + gnt_entry_add_to_history(GNT_ENTRY(w), gnt_entry_get_text(GNT_ENTRY(w))); gnt_text_view_next_line(GNT_TEXT_VIEW(view)); gnt_entry_clear(GNT_ENTRY(w)); if (gnt_text_view_get_lines_below(GNT_TEXT_VIEW(view)) <= 1) gnt_text_view_scroll(GNT_TEXT_VIEW(view), 0); + gnt_entry_remove_suggest(GNT_ENTRY(w), "acb"); return TRUE; } else if (key[0] == 27) { - if (strcmp(key+1, GNT_KEY_UP)) + if (strcmp(key+1, GNT_KEY_UP) == 0) + gnt_text_view_scroll(GNT_TEXT_VIEW(view), -1); + else if (strcmp(key+1, GNT_KEY_DOWN) == 0) gnt_text_view_scroll(GNT_TEXT_VIEW(view), 1); - else if (strcmp(key+1, GNT_KEY_DOWN)) - gnt_text_view_scroll(GNT_TEXT_VIEW(view), -1); + else + return FALSE; + return TRUE; } return FALSE; @@ -53,6 +58,15 @@ gnt_widget_set_name(entry, "entry"); GNT_WIDGET_SET_FLAGS(entry, GNT_WIDGET_CAN_TAKE_FOCUS); + gnt_entry_set_word_suggest(GNT_ENTRY(entry), TRUE); + gnt_entry_set_always_suggest(GNT_ENTRY(entry), FALSE); + gnt_entry_add_suggest(GNT_ENTRY(entry), "a"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "ab"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "abc"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "abcd"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "abcde"); + gnt_entry_add_suggest(GNT_ENTRY(entry), "acb"); + view = gnt_text_view_new(); gnt_widget_set_name(view, "view"); @@ -65,7 +79,8 @@ gnt_widget_show(hbox); - g_signal_connect(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view); + gnt_entry_set_history_length(GNT_ENTRY(entry), -1); + g_signal_connect_after(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view); #ifdef STANDALONE gnt_main(); Modified: branches/soc-2006-file-loggers/gaim.apspec.in =================================================================== --- branches/soc-2006-file-loggers/gaim.apspec.in 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/gaim.apspec.in 2006-08-13 17:38:25 UTC (rev 16738) @@ -15,7 +15,7 @@ [Description] Gaim allows you to talk to anyone using a variety of messaging protocols, including AIM (Oscar and TOC), ICQ, IRC, Yahoo!, MSN Messenger, Jabber, -Gadu-Gadu, Napster, and Zephyr. These protocols are implemented using a +Gadu-Gadu, and Zephyr. These protocols are implemented using a modular, easy to use design. To use a protocol, just add an account using the account editor. Modified: branches/soc-2006-file-loggers/plugins/ChangeLog.API =================================================================== --- branches/soc-2006-file-loggers/plugins/ChangeLog.API 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/plugins/ChangeLog.API 2006-08-13 17:38:25 UTC (rev 16738) @@ -114,6 +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_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/soc-2006-file-loggers/plugins/log_reader.c =================================================================== --- branches/soc-2006-file-loggers/plugins/log_reader.c 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/plugins/log_reader.c 2006-08-13 17:38:25 UTC (rev 16738) @@ -796,6 +796,7 @@ time_t time_unix; struct tm *tm_new; char *timestamp; + char *tmp; const char *style; new_session_id = xmlnode_get_attrib(message, "SessionID"); @@ -906,7 +907,7 @@ !isalnum(*(from_name + alias_length))); - to_name_matches = (gaim_str_has_prefix( + to_name_matches = to_name && (gaim_str_has_prefix( to_name, alias) && !isalnum(*(to_name + alias_length))); @@ -988,16 +989,18 @@ style = xmlnode_get_attrib(text_node, "Style"); + tmp = xmlnode_get_data(text_node); if (style && *style) { text = g_string_append(text, "<span style=\""); text = g_string_append(text, style); text = g_string_append(text, "\">"); - text = g_string_append(text, xmlnode_get_data(text_node)); + text = g_string_append(text, tmp); text = g_string_append(text, "</span>\n"); } else { - text = g_string_append(text, xmlnode_get_data(text_node)); + text = g_string_append(text, tmp); text = g_string_append(text, "\n"); } + g_free(tmp); } data->text = text; @@ -1493,7 +1496,7 @@ g_string_append(formatted, "<span style=\"color: #ff0000;\">"); - + if (gaim_str_has_prefix(line, "Your previous message has not been sent. " "Reason: Maximum length exceeded.")) { @@ -1713,10 +1716,11 @@ char buffer[1024] = ""; DWORD size = (sizeof(buffer) - 1); DWORD type; + gboolean found = FALSE; path = NULL; /* TODO: Test this after removing the trailing "\\". */ - if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", + if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", 0, KEY_QUERY_VALUE, &hKey)) { if(ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) { @@ -1751,20 +1755,18 @@ if (!path) { char *folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES); - if (folder) + if (folder) { path = g_build_filename(folder, "Trillian", "users", "default", "talk.ini", NULL); g_free(folder); } } - gboolean found = FALSE; - if (path) { /* Read talk.ini file to find the log directory. */ GError *error = NULL; -#if 0 && GTK_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */ +#if 0 && GLIB_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */ GKeyFile *key_file; gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", @@ -1791,9 +1793,9 @@ g_key_file_free(key_file); } -#else /* !GTK_CHECK_VERSION(2,6,0) */ - GError *error = NULL; +#else /* !GLIB_CHECK_VERSION(2,6,0) */ gsize length; + gchar *contents = NULL; gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", "Reading %s\n", path); Modified: branches/soc-2006-file-loggers/po/ChangeLog =================================================================== --- branches/soc-2006-file-loggers/po/ChangeLog 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/po/ChangeLog 2006-08-13 17:38:25 UTC (rev 16738) @@ -23,13 +23,16 @@ * German translation updated (Bjoern Voigt) * German win32 translation updated (Bjoern Voigt) * Greek translation added (Bouklis Panos) + * Gujarati translation updated (Ankit Patel) * Hebrew translation updated (Shalom Craimer) * Hungarian translation updated (Gabor Kelemen) + * Italian translation updated (Claudio Satriano) * Japanese translation updated (Takeshi Aihana) * Kurdish translation added (Erdal Ronahi and Amed Ç. Jiyan) * Kurdish win32 installer translation added (Erdal Ronahi) * Lithuanian translation updated (Andrius Štikonas, Laurynas Biveinis) * Lithuanian win32 translation added (Laurynas Biveinis) + * Nepali translation added (Shyam Krishna Bal) * Persian translation added (Elnaz Sarbar, Meelad Zakaria) * Polish translation updated (Emil Nowak) * Portuguese translation updated (Duarte Henriques) Modified: branches/soc-2006-file-loggers/po/de.po =================================================================== --- branches/soc-2006-file-loggers/po/de.po 2006-08-13 16:01:52 UTC (rev 16737) +++ branches/soc-2006-file-loggers/po/de.po 2006-08-13 17:38:25 UTC (rev 16738) @@ -10,8 +10,8 @@ msgstr "" "Project-Id-Version: Gaim\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2006-04-29 23:34+0200\n" -"PO-Revision-Date: 2006-04-29 23:33+0200\n" +"POT-Creation-Date: 2006-06-20 10:30+0200\n" +"PO-Revision-Date: 2006-06-20 10:38+0200\n" "Last-Translator: Björn Voigt <bj...@cs...>\n" "Language-Team: de <de...@li...>\n" "MIME-Version: 1.0\n" @@ -196,7 +196,7 @@ msgid "Right-click for more unread messages...\n" msgstr "Rechtsklicken für weitere ungelesene Nachrichten...\n" -#: ../plugins/docklet/docklet.c:157 ../src/gtkblist.c:3230 +#: ../plugins/docklet/docklet.c:157 ../src/gtkblist.c:3246 #, c-format msgid "%d unread message from %s\n" msgid_plural "%d unread messages from %s\n" @@ -208,10 +208,10 @@ msgstr "Ändere Status" #: ../plugins/docklet/docklet.c:435 ../src/gtkstatusbox.c:673 -#: ../src/protocols/gg/gg.c:996 ../src/protocols/jabber/buddy.c:1104 +#: ../src/protocols/gg/gg.c:996 ../src/protocols/jabber/buddy.c:1363 #: ../src/protocols/msn/state.c:29 ../src/protocols/msn/state.c:30 #: ../src/protocols/msn/state.c:37 ../src/protocols/msn/state.c:38 -#: ../src/protocols/novell/novell.c:2845 ../src/protocols/yahoo/yahoo.c:2733 +#: ../src/protocols/novell/novell.c:2843 ../src/protocols/yahoo/yahoo.c:2731 #: ../src/status.c:155 msgid "Available" msgstr "Verfügbar" @@ -222,25 +222,25 @@ #: ../plugins/docklet/docklet.c:439 ../src/gtkprefs.c:1774 #: ../src/gtkstatusbox.c:674 ../src/protocols/gg/gg.c:999 #: ../src/protocols/irc/irc.c:520 ../src/protocols/irc/msgs.c:223 -#: ../src/protocols/jabber/buddy.c:1108 ../src/protocols/novell/novell.c:2848 -#: ../src/protocols/oscar/oscar.c:719 ../src/protocols/oscar/oscar.c:4391 -#: ../src/protocols/oscar/oscar.c:5434 ../src/protocols/silc/buddy.c:1469 -#: ../src/protocols/yahoo/yahoo.c:3187 ../src/protocols/yahoo/yahoo.c:3260 +#: ../src/protocols/jabber/buddy.c:1367 ../src/protocols/novell/novell.c:2846 +#: ../src/protocols/oscar/oscar.c:719 ../src/protocols/oscar/oscar.c:4397 +#: ../src/protocols/oscar/oscar.c:5440 ../src/protocols/silc/buddy.c:1469 +#: ../src/protocols/yahoo/yahoo.c:3185 ../src/protocols/yahoo/yahoo.c:3258 #: ../src/status.c:158 msgid "Away" msgstr "Abwesend" #: ../plugins/docklet/docklet.c:443 ../src/gtkstatusbox.c:675 -#: ../src/protocols/oscar/oscar.c:723 ../src/protocols/yahoo/yahoo.c:2727 +#: ../src/protocols/oscar/oscar.c:723 ../src/protocols/yahoo/yahoo.c:2725 #: ../src/status.c:157 msgid "Invisible" msgstr "Unsichtbar" -#: ../plugins/docklet/docklet.c:447 ../src/gtkblist.c:2960 +#: ../plugins/docklet/docklet.c:447 ../src/gtkblist.c:2976 #: ../src/gtkstatusbox.c:676 ../src/protocols/gg/gg.c:993 -#: ../src/protocols/jabber/buddy.c:1102 ../src/protocols/novell/novell.c:2857 -#: ../src/protocols/oscar/oscar.c:785 ../src/protocols/oscar/oscar.c:5406 -#: ../src/protocols/yahoo/yahoo.c:2731 ../src/status.c:154 +#: ../src/protocols/jabber/buddy.c:1361 ../src/protocols/novell/novell.c:2855 +#: ../src/protocols/oscar/oscar.c:785 ../src/protocols/oscar/oscar.c:5412 +#: ../src/protocols/yahoo/yahoo.c:2729 ../src/status.c:154 msgid "Offline" msgstr "Offline" @@ -256,7 +256,7 @@ msgid "Show Buddy List" msgstr "Buddy-Liste anzeigen" -#: ../plugins/docklet/docklet.c:489 ../src/gtkconv.c:5626 +#: ../plugins/docklet/docklet.c:489 ../src/gtkconv.c:5675 msgid "Unread Messages" msgstr "Ungelesene Nachrichten" @@ -296,7 +296,7 @@ msgstr "_Sofortnachrichten:" #: ../plugins/docklet/docklet.c:684 ../plugins/docklet/docklet.c:692 -#: ../plugins/win32/winprefs/winprefs.c:424 ../src/gtkprefs.c:823 +#: ../plugins/win32/winprefs/winprefs.c:462 ../src/gtkprefs.c:823 #: ../src/gtkprefs.c:1764 ../src/gtkprefs.c:1778 msgid "Never" msgstr "Niemals" @@ -307,7 +307,7 @@ #: ../plugins/docklet/docklet.c:686 ../plugins/docklet/docklet.c:694 #: ../plugins/timestamp_format.c:39 ../plugins/timestamp_format.c:48 -#: ../plugins/win32/winprefs/winprefs.c:425 ../src/gtkprefs.c:825 +#: ../plugins/win32/winprefs/winprefs.c:463 ../src/gtkprefs.c:825 msgid "Always" msgstr "Immer" @@ -617,7 +617,7 @@ #. Business #: ../plugins/gevolution/add_buddy_dialog.c:131 #: ../plugins/gevolution/assoc-buddy.c:119 ../src/gtkplugin.c:587 -#: ../src/gtkroomlist.c:604 ../src/protocols/jabber/jabber.c:755 +#: ../src/gtkroomlist.c:604 ../src/protocols/jabber/jabber.c:759 #: ../src/protocols/msn/msn.c:1532 ../src/protocols/msn/msn.c:1585 #: ../src/protocols/msn/msn.c:1606 msgid "Name" @@ -627,10 +627,10 @@ msgid "Instant Messaging" msgstr "Sofortnachrichten" -#: ../plugins/gevolution/add_buddy_dialog.c:442 ../src/gtkblist.c:4526 +#: ../plugins/gevolution/add_buddy_dialog.c:442 ../src/gtkblist.c:4532 #: ../src/protocols/silc/buddy.c:736 ../src/protocols/silc/buddy.c:1030 #: ../src/protocols/silc/buddy.c:1075 ../src/protocols/silc/buddy.c:1174 -#: ../src/protocols/yahoo/yahoo.c:2976 +#: ../src/protocols/yahoo/yahoo.c:2974 msgid "Add Buddy" msgstr "Buddy hinzufügen" @@ -644,14 +644,14 @@ #. "Search" #: ../plugins/gevolution/add_buddy_dialog.c:468 #: ../plugins/gevolution/assoc-buddy.c:353 -#: ../src/protocols/jabber/buddy.c:1460 ../src/protocols/oscar/oscar.c:6014 -#: ../src/protocols/sametime/sametime.c:5531 +#: ../src/protocols/jabber/buddy.c:1720 ../src/protocols/oscar/oscar.c:6020 +#: ../src/protocols/sametime/sametime.c:5529 msgid "Search" msgstr "Suchen" #: ../plugins/gevolution/add_buddy_dialog.c:549 -#: ../plugins/gevolution/new_person_dialog.c:307 ../src/gtkblist.c:4610 -#: ../src/gtkblist.c:4974 +#: ../plugins/gevolution/new_person_dialog.c:307 ../src/gtkblist.c:4616 +#: ../src/gtkblist.c:4980 msgid "Group:" msgstr "Gruppe:" @@ -687,13 +687,13 @@ msgstr "_Assoziiere den Buddy" #: ../plugins/gevolution/eds-utils.c:73 ../plugins/gevolution/eds-utils.c:86 -#: ../src/protocols/jabber/jabber.c:1122 +#: ../src/protocols/jabber/jabber.c:1125 msgid "None" msgstr "Kein" #: ../plugins/gevolution/gevo-util.c:64 ../plugins/gevolution/gevolution.c:96 #: ../src/blist.c:516 ../src/blist.c:1278 ../src/blist.c:1505 -#: ../src/gtkblist.c:4419 ../src/protocols/jabber/roster.c:65 +#: ../src/gtkblist.c:4425 ../src/protocols/jabber/roster.c:66 msgid "Buddies" msgstr "Buddys" @@ -730,8 +730,8 @@ "Wählen Sie alle Konten, zu denen Buddys automatisch hinzugefügt werden " "sollen." -#: ../plugins/gevolution/gevolution.c:450 ../plugins/idle.c:150 -#: ../plugins/idle.c:186 ../src/gtknotify.c:399 ../src/gtkpounce.c:1262 +#: ../plugins/gevolution/gevolution.c:450 ../plugins/idle.c:153 +#: ../plugins/idle.c:189 ../src/gtknotify.c:399 ../src/gtkpounce.c:1255 msgid "Account" msgstr "Konto" @@ -768,7 +768,7 @@ msgstr "Kontotyp:" #: ../plugins/gevolution/new_person_dialog.c:295 ../src/gtkaccount.c:784 -#: ../src/gtkblist.c:4572 +#: ../src/gtkblist.c:4578 msgid "Screen name:" msgstr "Benutzername:" @@ -870,50 +870,50 @@ msgid "Iconifies the buddy list and your conversations when you go away." msgstr "Minimiert die Buddy-Liste und die Gesprächsfenster, wenn Sie weggehen." -#: ../plugins/idle.c:155 ../plugins/idle.c:213 +#: ../plugins/idle.c:158 ../plugins/idle.c:216 msgid "Minutes" msgstr "Minuten" #. This is a cultural reference. Dy'er Mak'er is a song by Led Zeppelin. #. If that doesn't translate well into your language, drop the 's before translating. -#: ../plugins/idle.c:162 ../plugins/idle.c:195 ../plugins/idle.c:220 -#: ../plugins/idle.c:312 +#: ../plugins/idle.c:165 ../plugins/idle.c:198 ../plugins/idle.c:223 +#: ../plugins/idle.c:315 msgid "I'dle Mak'er" msgstr "Untätigkeitsmarker" -#: ../plugins/idle.c:163 ../plugins/idle.c:252 +#: ../plugins/idle.c:166 ../plugins/idle.c:255 msgid "Set Account Idle Time" msgstr "Setze Konto-Untätigkeitszeit" -#: ../plugins/idle.c:166 ../plugins/idle.c:224 +#: ../plugins/idle.c:169 ../plugins/idle.c:227 msgid "_Set" msgstr "_Setzen" -#: ../plugins/idle.c:167 ../plugins/idle.c:200 ../plugins/idle.c:225 +#: ../plugins/idle.c:170 ../plugins/idle.c:203 ../plugins/idle.c:228 msgid "_Cancel" msgstr "A_bbrechen" -#: ../plugins/idle.c:180 +#: ../plugins/idle.c:183 msgid "None of your accounts are idle." msgstr "Keine ihrer Konten sind untätig." -#: ../... [truncated message content] |
From: <may...@us...> - 2006-08-13 16:02:07
|
Revision: 16737 Author: mayuan2006 Date: 2006-08-13 09:01:52 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16737&view=rev Log Message: ----------- can send Message to Yahoo Messenger can receive the Yahoo Message, Need to post it to the conversation committed by Ma Yuan<may...@gm...> Modified Paths: -------------- branches/soc-2006-msnp13/src/protocols/msn/command.c branches/soc-2006-msnp13/src/protocols/msn/contact.c branches/soc-2006-msnp13/src/protocols/msn/msg.c branches/soc-2006-msnp13/src/protocols/msn/msn.c branches/soc-2006-msnp13/src/protocols/msn/notification.c branches/soc-2006-msnp13/src/protocols/msn/notification.h branches/soc-2006-msnp13/src/protocols/msn/switchboard.c branches/soc-2006-msnp13/src/protocols/msn/user.c branches/soc-2006-msnp13/src/protocols/msn/userlist.c branches/soc-2006-msnp13/src/protocols/msn/userlist.h Modified: branches/soc-2006-msnp13/src/protocols/msn/command.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/command.c 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/command.c 2006-08-13 16:01:52 UTC (rev 16737) @@ -51,6 +51,8 @@ (!strcmp(str,"RML")) || (!strcmp(str,"UBX")) || (!strcmp(str,"UBN")) || + (!strcmp(str,"UUM")) || + (!strcmp(str,"UBM")) || (!strcmp(str,"UUN")) || (!strcmp(str,"UUX"))){ return TRUE; @@ -66,6 +68,11 @@ if(!(strcmp(str,"MSG"))|| (!strcmp(str,"UBX")) ){ return 2; } + /*Yahoo User Message UBM + * Format UBM em...@ya... 32 1 [payload length]*/ + if(!(strcmp(str,"UBM"))|| (!strcmp(str,"UUM")) ){ + return 3; + } return 1; } Modified: branches/soc-2006-msnp13/src/protocols/msn/contact.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/contact.c 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/contact.c 2006-08-13 16:01:52 UTC (rev 16737) @@ -112,14 +112,13 @@ msn_parse_contact_list(MsnContact * contact) { MsnSession * session; - MsnUser *user; int list_op =0; char * passport; xmlnode * node,*body,*response,*result,*services,*service,*memberships; xmlnode *membershipnode,*members,*member,*passportNode,*role; session = contact->session; -// gaim_debug_misc("xml","parse contact list:{%s}\nsize:%d\n",contact->soapconn->body,contact->soapconn->body_len); + gaim_debug_misc("xml","parse contact list:{%s}\nsize:%d\n",contact->soapconn->body,contact->soapconn->body_len); node = xmlnode_from_str(contact->soapconn->body, contact->soapconn->body_len); // node = xmlnode_from_str(contact->soapconn->body, -1); @@ -148,6 +147,7 @@ members = xmlnode_get_child(membershipnode,"Members"); for(member = xmlnode_get_child(members, "Member"); member; member = xmlnode_get_next_twin(member)){ + MsnUser *user; xmlnode * typeNode; char * type; @@ -158,17 +158,20 @@ typeNode = xmlnode_get_child(member,"Type"); type = xmlnode_get_data(typeNode); gaim_debug_misc("Passport","name:%s,type:%s\n",passport,type); - user = msn_userlist_find_user(session->userlist, passport); - if (user == NULL){ - user = msn_user_new(session->userlist, passport, ""); - msn_userlist_add_user(session->userlist, user); - } -// user->list_op |= list_op; + + user = msn_userlist_find_add_user(session->userlist,passport,NULL); msn_got_lst_user(session, user, list_op, NULL); } if(!g_strcasecmp(xmlnode_get_attrib(member,"type"),"PhoneMember")){ } if(!g_strcasecmp(xmlnode_get_attrib(member,"type"),"EmailMember")){ + xmlnode *emailNode; + + emailNode = xmlnode_get_child(member,"Email"); + passport = xmlnode_get_data(emailNode); + gaim_debug_info("Email","name:%s,list_op:%d\n",passport,list_op); + user = msn_userlist_find_add_user(session->userlist,passport,NULL); + msn_got_lst_user(session,user,list_op,NULL); } } } @@ -306,10 +309,27 @@ passportName = xmlnode_get_child(contactInfo,"passportName"); if(passportName == NULL){ + xmlnode *emailsNode, *contactEmailNode, *emailNode; + xmlnode *messengerEnabledNode; + char *msnEnabled; + /*TODO: add it to the none-instant Messenger group and recognize as email Membership*/ - continue; + /*Yahoo User?*/ + emailsNode = xmlnode_get_child(contactInfo,"emails"); + for(contactEmailNode = xmlnode_get_child(emailsNode,"ContactEmail");contactEmailNode; + contactEmailNode = xmlnode_get_next_twin(contactEmailNode) ){ + messengerEnabledNode = xmlnode_get_child(contactEmailNode,"isMessengerEnabled"); + msnEnabled = xmlnode_get_data(messengerEnabledNode); + if(!strcmp(msnEnabled,"true")){ + emailNode = xmlnode_get_child(contactEmailNode,"email"); + passport = xmlnode_get_data(emailNode); + gaim_debug_info("Ma Yuan","Yahoo User %s\n",passport); + break; + } + } + }else{ + passport = xmlnode_get_data(passportName); } - passport = xmlnode_get_data(passportName); displayName = xmlnode_get_child(contactInfo,"displayName"); Name =xmlnode_get_data(displayName); @@ -319,11 +339,7 @@ xmlnode_get_data(contactId), Name); - user = msn_userlist_find_user(session->userlist, passport); - if (user == NULL){ - user = msn_user_new(session->userlist, passport, Name); - msn_userlist_add_user(session->userlist, user); - } + user = msn_userlist_find_add_user(session->userlist, passport,Name); msn_user_set_uid(user,uid); msn_user_set_type(user,msn_get_user_type(type)); user->list_op |= MSN_LIST_FL_OP; Modified: branches/soc-2006-msnp13/src/protocols/msn/msg.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/msg.c 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/msg.c 2006-08-13 16:01:52 UTC (rev 16737) @@ -471,6 +471,7 @@ { memcpy(n, body, body_len); n += body_len; + n = "\0"; } } Modified: branches/soc-2006-msnp13/src/protocols/msn/msn.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/msn.c 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/msn.c 2006-08-13 16:01:52 UTC (rev 16737) @@ -780,7 +780,7 @@ char *msgformat; char *msgtext; - gaim_debug_info("MaYuan","send IM {%s}\n",message); + gaim_debug_info("MaYuan","send IM {%s} to %s\n",message,who); account = gaim_connection_get_account(gc); msn_import_html(message, &msgformat, &msgtext); @@ -794,20 +794,27 @@ } msg = msn_message_new_plain(msgtext); + msg->remote_user = g_strdup(who); msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); g_free(msgformat); g_free(msgtext); + gaim_debug_info("MaYuan","prepare to send...\n"); if (g_ascii_strcasecmp(who, gaim_account_get_username(account))) { MsnSession *session; MsnSwitchBoard *swboard; session = gc->proto_data; - swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); - - msn_switchboard_send_msg(swboard, msg, TRUE); + if(strstr(who,"yahoo") != NULL){ + gaim_debug_info("MaYuan","send to Yahoo!\n"); + uum_send_msg(session,msg); + }else{ + gaim_debug_info("MaYuan","send via switchboard\n"); + swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); + msn_switchboard_send_msg(swboard, msg, TRUE); + } } else { Modified: branches/soc-2006-msnp13/src/protocols/msn/notification.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-13 16:01:52 UTC (rev 16737) @@ -161,7 +161,7 @@ **************************************************************************/ static void -group_error_helper(MsnSession *session, const char *msg, int group_id, int error) +group_error_helper(MsnSession *session, const char *msg, const char *group_id, int error) { GaimAccount *account; GaimConnection *gc; @@ -400,6 +400,94 @@ } } +/*send Message to Yahoo Messenger*/ +void +uum_send_msg(MsnSession *session,MsnMessage *msg) +{ + MsnCmdProc *cmdproc; + MsnTransaction *trans; + char *payload; + gsize payload_len; + int type; + + cmdproc = session->notification->cmdproc; + g_return_if_fail(msg != NULL); + payload = msn_message_gen_payload(msg, &payload_len); + gaim_debug_info("MaYuan","send UUM,payload{%s}\n",payload); + type = msg->type; + trans = msn_transaction_new(cmdproc, "UUM","%s 32 %d %d",msg->remote_user,type,strlen(payload)); + msn_transaction_set_payload(trans, payload, strlen(payload)); + msn_cmdproc_send_trans(cmdproc, trans); +} + +static void +ubm_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, + size_t len) +{ + MsnMessage *msg; + GaimConnection *gc; + + gaim_debug_info("MaYuan","Process UBM payload:%s\n",payload); + msg = msn_message_new_from_cmd(cmdproc->session, cmd); + + msn_message_parse_payload(msg, payload, len); +#ifdef MSN_DEBUG_NS + msn_message_show_readable(msg, "Notification", TRUE); +#endif + + gaim_debug_info("MaYuan","type:%d\n",msg->type); + if(msg->type == MSN_MSG_TEXT){ + const char *value; + const char *body; + char *body_str; + char *body_enc; + char *body_final; + size_t body_len; + const char *passport; + + body = msn_message_get_bin_data(msg, &body_len); + body_str = g_strndup(body, body_len); + body_enc = g_markup_escape_text(body_str, -1); + g_free(body_str); + + passport = msg->remote_user; + gc = cmdproc->session->account->gc; + if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) { + char *pre, *post; + + msn_parse_format(value, &pre, &post); + body_final = g_strdup_printf("%s%s%s", pre ? pre : "", + body_enc ? body_enc : "", post ? post : ""); + g_free(pre); + g_free(post); + g_free(body_enc); + } + serv_got_im(gc, passport, body_final, 0, time(NULL)); + } + msn_message_destroy(msg); +} + +/*Yahoo msg process*/ +static void +ubm_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) +{ + gaim_debug_info("MaYuan","Processing UBM... \n"); + if(cmd->payload_len == 0){ + return; + } + /* NOTE: cmd is not always cmdproc->last_cmd, sometimes cmd is a queued + * command and we are processing it */ + if (cmd->payload == NULL){ + cmdproc->last_cmd->payload_cb = ubm_cmd_post; + cmdproc->servconn->payload_len = atoi(cmd->params[2]); + }else{ + g_return_if_fail(cmd->payload_cb != NULL); + + gaim_debug_info("MaYuan","UBM payload:{%s}\n",cmd->payload); + ubm_cmd_post(cmdproc, cmd, cmd->payload, cmd->payload_len); + } +} + /************************************************************************** * Challenges * we use MD5 to caculate the Chanllenges @@ -481,12 +569,12 @@ gaim_debug_info("MaYuan","list_op:%d\n",list_op_str); xmlnode_set_attrib(c_node,"l",list_op_str); g_free(list_op_str); -#if 1 +#if 0 type_str = g_strdup_printf("%d",type); xmlnode_set_attrib(c_node,"t",type_str); #else if(g_strrstr(domain,"yahoo") != NULL){ - type_str = g_strdup_printf("31"); + type_str = g_strdup_printf("32"); }else{ /*passport*/ type_str = g_strdup_printf("1"); @@ -932,12 +1020,12 @@ static void reg_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) { - int group_id; + const char * group_id; char **params; params = g_strsplit(trans->params, " ", 0); - group_id = atoi(params[0]); + group_id = params[0]; group_error_helper(cmdproc->session, _("Unable to rename group"), group_id, error); @@ -1640,6 +1728,7 @@ /* Asynchronous */ msn_table_add_cmd(cbs_table, NULL, "IPG", ipg_cmd); msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd); + msn_table_add_cmd(cbs_table, NULL, "UBM", ubm_cmd); msn_table_add_cmd(cbs_table, NULL, "GCF", gcf_cmd); msn_table_add_cmd(cbs_table, NULL, "SBS", sbs_cmd); msn_table_add_cmd(cbs_table, NULL, "NOT", not_cmd); Modified: branches/soc-2006-msnp13/src/protocols/msn/notification.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/notification.h 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/notification.h 2006-08-13 16:01:52 UTC (rev 16737) @@ -48,6 +48,7 @@ }; #include "state.h" +void uum_send_msg(MsnSession *session,MsnMessage *msg); void msn_notification_end(void); void msn_notification_init(void); Modified: branches/soc-2006-msnp13/src/protocols/msn/switchboard.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/switchboard.c 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/switchboard.c 2006-08-13 16:01:52 UTC (rev 16737) @@ -742,6 +742,14 @@ } static void +ubm_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) +{ + gaim_debug_misc("MaYuan","get UBM...\n"); + cmdproc->servconn->payload_len = atoi(cmd->params[4]); + cmdproc->last_cmd->payload_cb = msg_cmd_post; +} + +static void nak_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnMessage *msg; @@ -1236,6 +1244,7 @@ msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd); msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd); + msn_table_add_cmd(cbs_table, NULL, "UBM", ubm_cmd); msn_table_add_cmd(cbs_table, NULL, "JOI", joi_cmd); msn_table_add_cmd(cbs_table, NULL, "BYE", bye_cmd); msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); Modified: branches/soc-2006-msnp13/src/protocols/msn/user.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/user.c 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/user.c 2006-08-13 16:01:52 UTC (rev 16737) @@ -142,8 +142,10 @@ { g_return_if_fail(user != NULL); - g_free(user->store_name); - user->store_name = g_strdup(name); + if (name != NULL){ + g_free(user->store_name); + user->store_name = g_strdup(name); + } } void Modified: branches/soc-2006-msnp13/src/protocols/msn/userlist.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/userlist.c 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/userlist.c 2006-08-13 16:01:52 UTC (rev 16737) @@ -448,6 +448,19 @@ g_free(userlist); } +MsnUser * +msn_userlist_find_add_user(MsnUserList *userlist,const char *passport,const char *userName) +{ + MsnUser *user; + + user = msn_userlist_find_user(userlist, passport); + if (user == NULL){ + user = msn_user_new(userlist, passport, userName); + msn_userlist_add_user(userlist, user); + } + return user; +} + void msn_userlist_add_user(MsnUserList *userlist, MsnUser *user) { Modified: branches/soc-2006-msnp13/src/protocols/msn/userlist.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/userlist.h 2006-08-13 08:45:09 UTC (rev 16736) +++ branches/soc-2006-msnp13/src/protocols/msn/userlist.h 2006-08-13 16:01:52 UTC (rev 16737) @@ -75,10 +75,14 @@ MsnUserList *msn_userlist_new(MsnSession *session); void msn_userlist_destroy(MsnUserList *userlist); + void msn_userlist_add_user(MsnUserList *userlist, MsnUser *user); void msn_userlist_remove_user(MsnUserList *userlist, MsnUser *user); MsnUser *msn_userlist_find_user(MsnUserList *userlist, - const char *passport); + const char *passport); +MsnUser *msn_userlist_find_add_user(MsnUserList *userlist, + const char *passport,const char *userName); + void msn_userlist_add_group(MsnUserList *userlist, MsnGroup *group); void msn_userlist_remove_group(MsnUserList *userlist, MsnGroup *group); MsnGroup *msn_userlist_find_group_with_id(MsnUserList *userlist, const char *id); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-13 08:45:14
|
Revision: 16736 Author: thekingant Date: 2006-08-13 01:45:09 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16736&view=rev Log Message: ----------- Backport a few SVN revisions from HEAD to v2_0_0 Original commit messages: 16730 (from datallah): Fix the documentation to indicate that the result of xmlnode_get_data() needs to be g_free'd 16731: Uh, I THINK this is what was intended...? 16732: Jabber crashed when getting info from someone on your buddy list if the JID consists only of the domain identifer. For example, add "quser.alpha.qunu.com" to your buddy list then get their info. This fixes the crashing. I'm not really sure if the fix is correct. Can someone familiar with Jabber please look over this? 16734: gaim_proxy_connect()ion attemps can now be canceled. So there is no longer a need to do that GAIM_CONNECTION_IS_VALID() crap at the top of gaim_proxy_connect() callback functions. All of the callers of gaim_proxy_connect() still need to be updated, though. 16735: Oscar peer connections now use the proxy_connect_cancel() function, so they don't need to use GAIM_CONNECTION_IS_VALID() anymore. Also, peer connection attempts will time out after 15 seconds. Yay. Modified Paths: -------------- branches/v2_0_0/src/protocols/jabber/JEPS branches/v2_0_0/src/protocols/jabber/buddy.c 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/proxy.c branches/v2_0_0/src/proxy.h branches/v2_0_0/src/xmlnode.h Modified: branches/v2_0_0/src/protocols/jabber/JEPS =================================================================== --- branches/v2_0_0/src/protocols/jabber/JEPS 2006-08-13 08:41:07 UTC (rev 16735) +++ branches/v2_0_0/src/protocols/jabber/JEPS 2006-08-13 08:45:09 UTC (rev 16736) @@ -22,6 +22,6 @@ Gateway Interaction (Transports) 0115: WATCH Client Capabilities -0017: NEED - Advanced IM Protocol Suite +0117: NEED + Intermediate IM Protocol Suite Modified: branches/v2_0_0/src/protocols/jabber/buddy.c =================================================================== --- branches/v2_0_0/src/protocols/jabber/buddy.c 2006-08-13 08:41:07 UTC (rev 16735) +++ branches/v2_0_0/src/protocols/jabber/buddy.c 2006-08-13 08:45:09 UTC (rev 16736) @@ -1119,15 +1119,20 @@ for(resources = jb->resources; resources; resources = resources->next) { JabberBuddyResource *jbr = resources->data; - JabberBuddyInfoResource *jbir = g_new0(JabberBuddyInfoResource, 1); + JabberBuddyInfoResource *jbir; char *full_jid; - if(strrchr(jid, '/')) { + + if ((strchr(jid, '/') == NULL) && (jbr->name != NULL)) { + full_jid = g_strdup_printf("%s/%s", jid, jbr->name); + } else { full_jid = g_strdup(jid); - } else { - full_jid = g_strdup_printf("%s/%s", jid, jbr->name); } - g_hash_table_insert(jbi->resources, g_strdup(jbr->name), jbir); + if (jbr->name != NULL) + { + jbir = g_new0(JabberBuddyInfoResource, 1); + g_hash_table_insert(jbi->resources, g_strdup(jbr->name), jbir); + } if(!jbr->client.name) { iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:version"); Modified: branches/v2_0_0/src/protocols/oscar/peer.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer.c 2006-08-13 08:41:07 UTC (rev 16735) +++ branches/v2_0_0/src/protocols/oscar/peer.c 2006-08-13 08:45:09 UTC (rev 16736) @@ -139,6 +139,18 @@ else if (conn->type == OSCAR_CAPABILITY_SENDFILE) peer_oft_close(conn); + if (conn->connect_info != NULL) + { + gaim_proxy_connect_cancel(conn->connect_info); + conn->connect_info = NULL; + } + + if (conn->connect_timeout_timer != 0) + { + gaim_timeout_remove(conn->connect_timeout_timer); + conn->connect_timeout_timer = 0; + } + if (conn->watcher_incoming != 0) { gaim_input_remove(conn->watcher_incoming); @@ -472,21 +484,13 @@ static void peer_connection_established_cb(gpointer data, gint source) { - NewPeerConnectionData *new_conn_data; - GaimConnection *gc; PeerConnection *conn; - new_conn_data = data; - gc = new_conn_data->gc; - conn = new_conn_data->conn; - g_free(new_conn_data); + conn = data; - if (!GAIM_CONNECTION_IS_VALID(gc)) - { - if (source >= 0) - close(source); - return; - } + conn->connect_info = NULL; + gaim_timeout_remove(conn->connect_timeout_timer); + conn->connect_timeout_timer = 0; if (source < 0) { @@ -627,21 +631,54 @@ } /** + * This is a callback function used when we're connecting to a peer + * using either the client IP or the verified IP and the connection + * took longer than 15 seconds to complete. We do this because + * waiting for the OS to time out the connection attempt is not + * practical--the default timeout on many OSes can be 3 minutes or + * more, and users are impatient. + * + * Worst case scenario: the user is connected to the Internet using + * a modem with severe lag. The peer connections fail and Gaim falls + * back to using a proxied connection. The lower bandwidth + * limitations imposed by the proxied connection won't matter because + * the user is using a modem. + * + * I suppose this line of thinking is discriminatory against people + * with very high lag but decent throughput who are transferring + * large files. But we don't care about those people. + */ +static gboolean +peer_connection_tooktoolong(gpointer data) +{ + PeerConnection *conn; + + conn = data; + + 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_trynext(conn); + + /* Cancel this timer. It'll be added again, if needed. */ + return FALSE; +} + +/** * Try to establish the given PeerConnection using a defined * sequence of steps. */ void peer_connection_trynext(PeerConnection *conn) { - NewPeerConnectionData *new_conn_data; GaimAccount *account; - new_conn_data = g_new(NewPeerConnectionData, 1); - new_conn_data->gc = conn->od->gc; - new_conn_data->conn = conn; + account = gaim_connection_get_account(conn->od->gc); - account = gaim_connection_get_account(new_conn_data->gc); - /* * Close any remnants of a previous failed connection attempt. */ @@ -667,10 +704,14 @@ g_free(tmp); } - if (gaim_proxy_connect(account, conn->verifiedip, conn->port, - peer_connection_established_cb, NULL, new_conn_data) != NULL) + conn->connect_info = gaim_proxy_connect(account, + conn->verifiedip, conn->port, + peer_connection_established_cb, NULL, conn); + if (conn->connect_info != NULL) { /* Connecting... */ + conn->connect_timeout_timer = gaim_timeout_add(15000, + peer_connection_tooktoolong, conn); return; } } @@ -698,10 +739,14 @@ g_free(tmp); } - if (gaim_proxy_connect(account, conn->clientip, conn->port, - peer_connection_established_cb, NULL, new_conn_data) != NULL) + conn->connect_info = gaim_proxy_connect(account, + conn->clientip, conn->port, + peer_connection_established_cb, NULL, conn); + if (conn->connect_info != NULL) { /* Connecting... */ + conn->connect_timeout_timer = gaim_timeout_add(15000, + peer_connection_tooktoolong, conn); return; } } @@ -714,6 +759,12 @@ if (!(conn->flags & PEER_CONNECTION_FLAG_TRIED_INCOMING) && (!conn->use_proxy)) { + NewPeerConnectionData *new_conn_data; + + new_conn_data = g_new(NewPeerConnectionData, 1); + new_conn_data->gc = conn->od->gc; + new_conn_data->conn = conn; + conn->flags |= PEER_CONNECTION_FLAG_TRIED_INCOMING; /* @@ -728,6 +779,8 @@ /* Opening listener socket... */ return; } + + g_free(new_conn_data); } /* @@ -757,18 +810,17 @@ g_free(tmp); } - if (gaim_proxy_connect(account, + conn->connect_info = gaim_proxy_connect(account, (conn->proxyip != NULL) ? conn->proxyip : PEER_PROXY_SERVER, PEER_PROXY_PORT, - peer_proxy_connection_established_cb, NULL, new_conn_data) != NULL) + peer_proxy_connection_established_cb, NULL, conn); + if (conn->connect_info != NULL) { /* Connecting... */ return; } } - g_free(new_conn_data); - /* Give up! */ peer_connection_destroy(conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); } Modified: branches/v2_0_0/src/protocols/oscar/peer.h =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer.h 2006-08-13 08:41:07 UTC (rev 16735) +++ branches/v2_0_0/src/protocols/oscar/peer.h 2006-08-13 08:45:09 UTC (rev 16736) @@ -159,10 +159,21 @@ gpointer frame; /** + * This is only used when the peer connection is being established. + */ + GaimProxyConnectInfo *connect_info; + + /** + * This is only used when the peer connection is being established. + */ + guint connect_timeout_timer; + + /** * This is only used while the remote user is attempting to * connect to us. */ int listenerfd; + int fd; guint watcher_incoming; Modified: branches/v2_0_0/src/protocols/oscar/peer_proxy.c =================================================================== --- branches/v2_0_0/src/protocols/oscar/peer_proxy.c 2006-08-13 08:41:07 UTC (rev 16735) +++ branches/v2_0_0/src/protocols/oscar/peer_proxy.c 2006-08-13 08:45:09 UTC (rev 16736) @@ -328,21 +328,11 @@ void peer_proxy_connection_established_cb(gpointer data, gint source) { - NewPeerConnectionData *new_conn_data; - GaimConnection *gc; PeerConnection *conn; - new_conn_data = data; - gc = new_conn_data->gc; - conn = new_conn_data->conn; - g_free(new_conn_data); + conn = data; - if (!GAIM_CONNECTION_IS_VALID(gc)) - { - if (source >= 0) - close(source); - return; - } + conn->connect_info = NULL; if (source < 0) { Modified: branches/v2_0_0/src/proxy.c =================================================================== --- branches/v2_0_0/src/proxy.c 2006-08-13 08:41:07 UTC (rev 16735) +++ branches/v2_0_0/src/proxy.c 2006-08-13 08:45:09 UTC (rev 16736) @@ -44,6 +44,7 @@ gpointer data; char *host; int port; + int fd; guint inpa; GaimProxyInfo *gpi; @@ -53,6 +54,10 @@ */ GSList *hosts; + /* + * All of the following variables are used when establishing a + * connection through a proxy. + */ guchar *write_buffer; gsize write_buf_len; gsize written_len; @@ -75,9 +80,15 @@ }; static GaimProxyInfo *global_proxy_info = NULL; + +/* + * TODO: Once all callers of gaim_proxy_connect() are keeping track + * of the return value from that function this linked list + * will no longer be needed. + */ static GSList *connect_infos = NULL; -static void try_connect(GaimProxyConnectInfo *); +static void try_connect(GaimProxyConnectInfo *connect_info); /************************************************************************** * Proxy structure API @@ -262,14 +273,41 @@ * Proxy API **************************************************************************/ +/* + * This is used when the connection attempt to one particular IP + * address fails. We close the socket, remove the watcher and get + * rid of input and output buffers. Normally try_connect() will + * be called immediately after this. + */ static void +gaim_proxy_connect_info_disconnect(GaimProxyConnectInfo *connect_info) +{ + if (connect_info->inpa > 0) + { + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + } + + if (connect_info->fd >= 0) + { + close(connect_info->fd); + connect_info->fd = -1; + } + + g_free(connect_info->write_buffer); + connect_info->write_buffer = NULL; + + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; +} + +static void gaim_proxy_connect_info_destroy(GaimProxyConnectInfo *connect_info) { + gaim_proxy_connect_info_disconnect(connect_info); + connect_infos = g_slist_remove(connect_infos, connect_info); - if (connect_info->inpa > 0) - gaim_input_remove(connect_info->inpa); - while (connect_info->hosts != NULL) { /* Discard the length... */ @@ -280,15 +318,21 @@ } g_free(connect_info->host); - g_free(connect_info->write_buffer); - g_free(connect_info->read_buffer); g_free(connect_info); } static void -gaim_proxy_connect_info_connected(GaimProxyConnectInfo *connect_info, int fd) +gaim_proxy_connect_info_connected(GaimProxyConnectInfo *connect_info) { - connect_info->connect_cb(connect_info->data, fd); + connect_info->connect_cb(connect_info->data, connect_info->fd); + + /* + * We've passed the file descriptor to the protocol, so it's no longer + * our responsibility, and we should be careful not to free it when + * we destroy the connect_info. + */ + connect_info->fd = -1; + gaim_proxy_connect_info_destroy(connect_info); } @@ -1019,19 +1063,17 @@ * be overly optimistic sometimes. select is just a hint that you might be * able to do something.) */ - ret = getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len); + ret = getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len); if (ret == 0 && error == EINPROGRESS) return; /* we'll be called again later */ if (ret < 0 || error != 0) { if (ret!=0) error = errno; - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; gaim_debug_error("proxy", "getsockopt SO_ERROR check: %s\n", strerror(error)); + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1039,71 +1081,77 @@ gaim_input_remove(connect_info->inpa); connect_info->inpa = 0; - gaim_proxy_connect_info_connected(connect_info, source); + gaim_proxy_connect_info_connected(connect_info); } -static gboolean clean_connect(gpointer data) +static gboolean +clean_connect(gpointer data) { - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info; - gaim_proxy_connect_info_connected(connect_info, connect_info->port); + connect_info = data; + gaim_proxy_connect_info_connected(connect_info); return FALSE; } - static int proxy_connect_none(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { - int fd = -1; + gaim_debug_info("proxy", "Connecting to %s:%d with no proxy\n", + connect_info->host, connect_info->port); - gaim_debug_info("proxy", - "Connecting to %s:%d with no proxy\n", connect_info->host, connect_info->port); - - if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { + connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_info->fd < 0) + { gaim_debug_error("proxy", "Unable to create socket: %s\n", strerror(errno)); return -1; } - fcntl(fd, F_SETFL, O_NONBLOCK); + fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, (struct sockaddr *)addr, addrlen) != 0) + if (connect(connect_info->fd, (struct sockaddr *)addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - /* This just confuses people. */ - /* gaim_debug_warning("proxy", - "Connect would have blocked.\n"); */ - connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, connect_info); + gaim_debug_info("proxy", "Connection in progress\n"); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, no_one_calls, connect_info); } else { gaim_debug_error("proxy", "Connect failed: %s\n", strerror(errno)); - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } } - else { + else + { + /* + * The connection happened IMMEDIATELY... strange, but whatever. + */ socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("proxy", "Connect didn't block.\n"); + gaim_debug_info("proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { gaim_debug_error("proxy", "getsockopt failed.\n"); - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } - /* TODO: Why is the following line so strange? */ - connect_info->port = fd; /* bleh */ - gaim_timeout_add(10, clean_connect, connect_info); /* we do this because we never - want to call our callback - before we return. */ + + /* + * We want to call the "connected" callback eventually, but we + * don't want to call it before we return, just in case. + */ + gaim_timeout_add(10, clean_connect, connect_info); } - return fd; + return connect_info->fd; } static void @@ -1113,16 +1161,12 @@ const guchar *request = connect_info->write_buffer + connect_info->written_len; gsize request_len = connect_info->write_buf_len - connect_info->written_len; - int ret = write(source, request, request_len); + int ret = write(connect_info->fd, request, request_len); if(ret < 0 && errno == EAGAIN) return; else if(ret < 0) { - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - close(source); - g_free(connect_info->write_buffer); - connect_info->write_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } else if (ret < request_len) { @@ -1135,7 +1179,7 @@ connect_info->write_buffer = NULL; /* register the response handler for the response */ - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_READ, connect_info->read_cb, connect_info); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_READ, connect_info->read_cb, connect_info); } #define HTTP_GOODSTRING "HTTP/1.0 200" @@ -1161,11 +1205,10 @@ p = connect_info->read_buffer + connect_info->read_len; max_read = connect_info->read_buf_len - connect_info->read_len - 1; - len = read(source, p, max_read); + len = read(connect_info->fd, p, max_read); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - close(source); gaim_proxy_connect_info_error(connect_info, _("Lost connection with server for an unknown reason.")); return; } else { @@ -1222,14 +1265,13 @@ complaining / breaking since we don't read the whole page */ while(len--) { /* TODO: deal with EAGAIN (and other errors) better */ - if (read(source, &tmpc, 1) < 0 && errno != EAGAIN) + if (read(connect_info->fd, &tmpc, 1) < 0 && errno != EAGAIN) break; } } if (error) { - close(source); msg = g_strdup_printf("Unable to parse response from HTTP proxy: %s\n", connect_info->read_buffer); gaim_proxy_connect_info_error(connect_info, msg); @@ -1255,7 +1297,6 @@ username = strchr(domain, '\\'); if (username == NULL) { - close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); @@ -1292,10 +1333,10 @@ connect_info->read_cb = http_canread; - connect_info->inpa = gaim_input_add(source, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, cond); + proxy_do_write(connect_info, connect_info->fd, cond); return; } else if((ntlm = g_strrstr((const char *)connect_info->read_buffer, "Proxy-Authenticate: NTLM"))) { /* Empty message */ gchar request[2048]; @@ -1305,7 +1346,6 @@ username = strchr(domain, '\\'); if (username == NULL) { - close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); @@ -1339,13 +1379,12 @@ connect_info->read_cb = http_canread; - connect_info->inpa = gaim_input_add(source, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, cond); + proxy_do_write(connect_info, connect_info->fd, cond); return; } else { - close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); @@ -1367,7 +1406,7 @@ g_free(connect_info->read_buffer); connect_info->read_buffer = NULL; gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_connect_info_connected(connect_info, source); + gaim_proxy_connect_info_connected(connect_info); return; } } @@ -1393,9 +1432,8 @@ len = sizeof(error); - if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - close(source); - + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1435,48 +1473,46 @@ connect_info->read_cb = http_canread; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, cond); + proxy_do_write(connect_info, connect_info->fd, cond); } static int proxy_connect_http(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { - int fd = -1; - gaim_debug_info("http proxy", "Connecting to %s:%d via %s:%d using HTTP\n", (connect_info->host ? connect_info->host : "(null)"), connect_info->port, (gaim_proxy_info_get_host(connect_info->gpi) ? gaim_proxy_info_get_host(connect_info->gpi) : "(null)"), gaim_proxy_info_get_port(connect_info->gpi)); - if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { + connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_info->fd < 0) return -1; - } - fcntl(fd, F_SETFL, O_NONBLOCK); + fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) != 0) + if (connect(connect_info->fd, addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - gaim_debug_warning("http proxy", - "Connect would have blocked.\n"); + gaim_debug_info("http proxy", "Connection in progress\n"); if (connect_info->port != 80) { /* we need to do CONNECT first */ - connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, http_canwrite, connect_info); } else { gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_connect_info_connected(connect_info, fd); + gaim_proxy_connect_info_connected(connect_info); } } else { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } } @@ -1484,19 +1520,19 @@ socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("http proxy", - "Connect didn't block.\n"); + gaim_debug_info("http proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } - http_canwrite(connect_info, fd, GAIM_INPUT_WRITE); + http_canwrite(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } - return fd; + return connect_info->fd; } @@ -1519,24 +1555,18 @@ buf = connect_info->read_buffer + connect_info->read_len; max_read = connect_info->read_buf_len - connect_info->read_len; - len = read(source, buf, max_read); + len = read(connect_info->fd, buf, max_read); if ((len < 0 && errno == EAGAIN) || (len > 0 && len + connect_info->read_len < 4)) return; else if (len + connect_info->read_len >= 4) { if (connect_info->read_buffer[1] == 90) { - gaim_proxy_connect_info_connected(connect_info, source); + gaim_proxy_connect_info_connected(connect_info); return; } } - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; - - close(source); - + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); } @@ -1559,9 +1589,8 @@ len = sizeof(error); - if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - close(source); - + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1574,9 +1603,10 @@ * with an option, or some detection mechanism - in the * meantime, stick with plain old SOCKS4. */ - if (!(hp = gethostbyname(connect_info->host))) { - close(source); - + /* TODO: This needs to be non-blocking! */ + hp = gethostbyname(connect_info->host); + if (hp == NULL) { + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1596,60 +1626,59 @@ connect_info->written_len = 0; connect_info->read_cb = s4_canread; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, cond); + proxy_do_write(connect_info, connect_info->fd, cond); } static int proxy_connect_socks4(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { - int fd = -1; - gaim_debug_info("socks4 proxy", "Connecting to %s:%d via %s:%d using SOCKS4\n", connect_info->host, connect_info->port, gaim_proxy_info_get_host(connect_info->gpi), gaim_proxy_info_get_port(connect_info->gpi)); - if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) + connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_info->fd < 0) return -1; - fcntl(fd, F_SETFL, O_NONBLOCK); + fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) != 0) + if (connect(connect_info->fd, addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - gaim_debug_warning("socks4 proxy", - "Connect would have blocked.\n"); - connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s4_canwrite, connect_info); + gaim_debug_info("socks4 proxy", "Connection in progress.\n"); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, s4_canwrite, connect_info); } else { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } } else { socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("socks4 proxy", - "Connect didn't block.\n"); + gaim_debug_info("socks4 proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } - s4_canwrite(connect_info, fd, GAIM_INPUT_WRITE); + s4_canwrite(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } - return fd; + return connect_info->fd; } static void @@ -1670,16 +1699,12 @@ gaim_debug_info("socks5 proxy", "Able to read again.\n"); - len = read(source, dest, (connect_info->read_buf_len - connect_info->read_len)); + len = read(connect_info->fd, dest, (connect_info->read_buf_len - connect_info->read_len)); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { gaim_debug_warning("socks5 proxy", "or not...\n"); - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1693,11 +1718,7 @@ gaim_debug_error("socks5 proxy", socks5errors[buf[1]]); else gaim_debug_error("socks5 proxy", "Bad data.\n"); - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1732,7 +1753,7 @@ /* Skip past BND.PORT */ buf += 2; - gaim_proxy_connect_info_connected(connect_info, source); + gaim_proxy_connect_info_connected(connect_info); } static void @@ -1755,8 +1776,8 @@ connect_info->read_cb = s5_canread_again; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } static void @@ -1773,16 +1794,12 @@ gaim_debug_info("socks5 proxy", "Got auth response.\n"); - len = read(source, connect_info->read_buffer + connect_info->read_len, + len = read(connect_info->fd, connect_info->read_buffer + connect_info->read_len, connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1795,9 +1812,7 @@ connect_info->inpa = 0; if ((connect_info->read_buffer[0] != 0x01) || (connect_info->read_buffer[1] != 0x00)) { - close(source); - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1805,7 +1820,7 @@ g_free(connect_info->read_buffer); connect_info->read_buffer = NULL; - s5_sendconnect(connect_info, source); + s5_sendconnect(connect_info, connect_info->fd); } static void @@ -1867,17 +1882,13 @@ connect_info->read_len = 0; } - len = read(source, connect_info->read_buffer + connect_info->read_len, + len = read(connect_info->fd, connect_info->read_buffer + connect_info->read_len, connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1889,11 +1900,7 @@ cmdbuf = connect_info->read_buffer; if (*cmdbuf != 0x01) { - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1917,18 +1924,14 @@ g_free(connect_info->read_buffer); connect_info->read_buffer = NULL; /* Success */ - s5_sendconnect(connect_info, source); + s5_sendconnect(connect_info, connect_info->fd); return; } else { /* Failure */ gaim_debug_warning("proxy", "socks5 CHAP authentication " "failed. Disconnecting..."); - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1954,10 +1957,10 @@ connect_info->read_cb = s5_readchap; - connect_info->inpa = gaim_input_add(source, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); break; case 0x11: /* Server wants to select an algorithm */ @@ -1969,11 +1972,7 @@ "as supporting. This is a violation " "of the socks5 CHAP specification. " "Disconnecting..."); - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -2000,16 +1999,12 @@ gaim_debug_info("socks5 proxy", "Able to read.\n"); - len = read(source, connect_info->read_buffer + connect_info->read_len, + len = read(connect_info->fd, connect_info->read_buffer + connect_info->read_len, connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -2022,9 +2017,7 @@ connect_info->inpa = 0; if ((connect_info->read_buffer[0] != 0x05) || (connect_info->read_buffer[1] == 0xff)) { - close(source); - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -2056,10 +2049,10 @@ connect_info->read_cb = s5_readauth; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); return; } else if (connect_info->read_buffer[1] == 0x03) { @@ -2085,17 +2078,17 @@ connect_info->read_cb = s5_readchap; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); return; } else { g_free(connect_info->read_buffer); connect_info->read_buffer = NULL; - s5_sendconnect(connect_info, source); + s5_sendconnect(connect_info, connect_info->fd); } } @@ -2117,9 +2110,8 @@ } len = sizeof(error); - if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - close(source); - + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -2146,39 +2138,37 @@ connect_info->read_cb = s5_canread; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } static int proxy_connect_socks5(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { - int fd = -1; - gaim_debug_info("socks5 proxy", "Connecting to %s:%d via %s:%d using SOCKS5\n", connect_info->host, connect_info->port, gaim_proxy_info_get_host(connect_info->gpi), gaim_proxy_info_get_port(connect_info->gpi)); - if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) + connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_info->fd < 0) return -1; - fcntl(fd, F_SETFL, O_NONBLOCK); + fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) != 0) + if (connect(connect_info->fd, addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - gaim_debug_warning("socks5 proxy", - "Connect would have blocked.\n"); - - connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s5_canwrite, connect_info); + gaim_debug_info("socks5 proxy", "Connection in progress\n"); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, s5_canwrite, connect_info); } else { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } } @@ -2186,22 +2176,28 @@ socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("socks5 proxy", "Connect didn't block.\n"); + gaim_debug_info("socks5 proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } - s5_canwrite(connect_info, fd, GAIM_INPUT_WRITE); + s5_canwrite(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } - return fd; + return connect_info->fd; } +/** + * This function iterates through a list of IP addresses and attempts + * to connect to each one. This is called after the hostname is + * resolved, and if a connection attempt fails. + */ static void try_connect(GaimProxyConnectInfo *connect_info) { size_t addrlen; @@ -2356,6 +2352,7 @@ /* 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; @@ -2418,6 +2415,7 @@ /* 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; @@ -2437,6 +2435,11 @@ return connect_info; } +void +gaim_proxy_connect_cancel(GaimProxyConnectInfo *connect_info) +{ + gaim_proxy_connect_info_destroy(connect_info); +} static void proxy_pref_cb(const char *name, GaimPrefType type, Modified: branches/v2_0_0/src/proxy.h =================================================================== --- branches/v2_0_0/src/proxy.h 2006-08-13 08:41:07 UTC (rev 16735) +++ branches/v2_0_0/src/proxy.h 2006-08-13 08:45:09 UTC (rev 16736) @@ -271,6 +271,17 @@ GaimProxyErrorFunction error_cb, gpointer data); /** + * Cancel an in-progress connection attempt. This should be called + * by the PRPL if the user disables an account while it is still + * performing the initial sign on. Or when establishing a file + * transfer, if we attempt to connect to a remote user but they + * are behind a firewall then the PRPL can cancel the connection + * attempt early rather than just letting the OS's TCP/IP stack + * time-out the connection. + */ +void gaim_proxy_connect_cancel(GaimProxyConnectInfo *connect_info); + +/** * Do an async dns query * * @param hostname The hostname to resolve Modified: branches/v2_0_0/src/xmlnode.h =================================================================== --- branches/v2_0_0/src/xmlnode.h 2006-08-13 08:41:07 UTC (rev 16735) +++ branches/v2_0_0/src/xmlnode.h 2006-08-13 08:45:09 UTC (rev 16736) @@ -31,7 +31,7 @@ typedef enum _XMLNodeType { XMLNODE_TYPE_TAG, /**< Just a tag */ - XMLNODE_TYPE_ATTRIB, /**< Has attributes */ + XMLNODE_TYPE_ATTRIB, /**< Has attributes */ XMLNODE_TYPE_DATA /**< Has data */ } XMLNodeType; @@ -40,13 +40,13 @@ */ typedef struct _xmlnode { - char *name; /**< The name of the node. */ + char *name; /**< The name of the node. */ #ifdef HAVE_LIBXML - char *namespace; /**< The namespace of the node */ + char *namespace; /**< The namespace of the node */ #endif - XMLNodeType type; /**< The type of the node. */ - char *data; /**< The data for the node. */ - size_t data_sz; /**< The size of the data. */ + XMLNodeType type; /**< The type of the node. */ + char *data; /**< The data for the node. */ + size_t data_sz; /**< The size of the data. */ struct _xmlnode *parent; /**< The parent node or @c NULL.*/ struct _xmlnode *child; /**< The child node or @c NULL.*/ struct _xmlnode *lastchild; /**< The last child node or @c NULL.*/ @@ -125,7 +125,8 @@ * * @param node The node to get data from. * - * @return The data from the node. + * @return The data from the node. You must g_free + * this string when finished using it. */ char *xmlnode_get_data(xmlnode *node); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-13 08:41:09
|
Revision: 16735 Author: thekingant Date: 2006-08-13 01:41:07 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16735&view=rev Log Message: ----------- Oscar peer connections now use the proxy_connect_cancel() function, so they don't need to use GAIM_CONNECTION_IS_VALID() anymore. Also, peer connection attempts will time out after 15 seconds. Yay. Modified Paths: -------------- trunk/src/protocols/oscar/peer.c trunk/src/protocols/oscar/peer.h trunk/src/protocols/oscar/peer_proxy.c Modified: trunk/src/protocols/oscar/peer.c =================================================================== --- trunk/src/protocols/oscar/peer.c 2006-08-13 08:38:02 UTC (rev 16734) +++ trunk/src/protocols/oscar/peer.c 2006-08-13 08:41:07 UTC (rev 16735) @@ -139,6 +139,18 @@ else if (conn->type == OSCAR_CAPABILITY_SENDFILE) peer_oft_close(conn); + if (conn->connect_info != NULL) + { + gaim_proxy_connect_cancel(conn->connect_info); + conn->connect_info = NULL; + } + + if (conn->connect_timeout_timer != 0) + { + gaim_timeout_remove(conn->connect_timeout_timer); + conn->connect_timeout_timer = 0; + } + if (conn->watcher_incoming != 0) { gaim_input_remove(conn->watcher_incoming); @@ -472,21 +484,13 @@ static void peer_connection_established_cb(gpointer data, gint source) { - NewPeerConnectionData *new_conn_data; - GaimConnection *gc; PeerConnection *conn; - new_conn_data = data; - gc = new_conn_data->gc; - conn = new_conn_data->conn; - g_free(new_conn_data); + conn = data; - if (!GAIM_CONNECTION_IS_VALID(gc)) - { - if (source >= 0) - close(source); - return; - } + conn->connect_info = NULL; + gaim_timeout_remove(conn->connect_timeout_timer); + conn->connect_timeout_timer = 0; if (source < 0) { @@ -627,21 +631,54 @@ } /** + * This is a callback function used when we're connecting to a peer + * using either the client IP or the verified IP and the connection + * took longer than 15 seconds to complete. We do this because + * waiting for the OS to time out the connection attempt is not + * practical--the default timeout on many OSes can be 3 minutes or + * more, and users are impatient. + * + * Worst case scenario: the user is connected to the Internet using + * a modem with severe lag. The peer connections fail and Gaim falls + * back to using a proxied connection. The lower bandwidth + * limitations imposed by the proxied connection won't matter because + * the user is using a modem. + * + * I suppose this line of thinking is discriminatory against people + * with very high lag but decent throughput who are transferring + * large files. But we don't care about those people. + */ +static gboolean +peer_connection_tooktoolong(gpointer data) +{ + PeerConnection *conn; + + conn = data; + + 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_trynext(conn); + + /* Cancel this timer. It'll be added again, if needed. */ + return FALSE; +} + +/** * Try to establish the given PeerConnection using a defined * sequence of steps. */ void peer_connection_trynext(PeerConnection *conn) { - NewPeerConnectionData *new_conn_data; GaimAccount *account; - new_conn_data = g_new(NewPeerConnectionData, 1); - new_conn_data->gc = conn->od->gc; - new_conn_data->conn = conn; + account = gaim_connection_get_account(conn->od->gc); - account = gaim_connection_get_account(new_conn_data->gc); - /* * Close any remnants of a previous failed connection attempt. */ @@ -667,10 +704,14 @@ g_free(tmp); } - if (gaim_proxy_connect(account, conn->verifiedip, conn->port, - peer_connection_established_cb, NULL, new_conn_data) != NULL) + conn->connect_info = gaim_proxy_connect(account, + conn->verifiedip, conn->port, + peer_connection_established_cb, NULL, conn); + if (conn->connect_info != NULL) { /* Connecting... */ + conn->connect_timeout_timer = gaim_timeout_add(15000, + peer_connection_tooktoolong, conn); return; } } @@ -698,10 +739,14 @@ g_free(tmp); } - if (gaim_proxy_connect(account, conn->clientip, conn->port, - peer_connection_established_cb, NULL, new_conn_data) != NULL) + conn->connect_info = gaim_proxy_connect(account, + conn->clientip, conn->port, + peer_connection_established_cb, NULL, conn); + if (conn->connect_info != NULL) { /* Connecting... */ + conn->connect_timeout_timer = gaim_timeout_add(15000, + peer_connection_tooktoolong, conn); return; } } @@ -714,6 +759,12 @@ if (!(conn->flags & PEER_CONNECTION_FLAG_TRIED_INCOMING) && (!conn->use_proxy)) { + NewPeerConnectionData *new_conn_data; + + new_conn_data = g_new(NewPeerConnectionData, 1); + new_conn_data->gc = conn->od->gc; + new_conn_data->conn = conn; + conn->flags |= PEER_CONNECTION_FLAG_TRIED_INCOMING; /* @@ -728,6 +779,8 @@ /* Opening listener socket... */ return; } + + g_free(new_conn_data); } /* @@ -757,18 +810,17 @@ g_free(tmp); } - if (gaim_proxy_connect(account, + conn->connect_info = gaim_proxy_connect(account, (conn->proxyip != NULL) ? conn->proxyip : PEER_PROXY_SERVER, PEER_PROXY_PORT, - peer_proxy_connection_established_cb, NULL, new_conn_data) != NULL) + peer_proxy_connection_established_cb, NULL, conn); + if (conn->connect_info != NULL) { /* Connecting... */ return; } } - g_free(new_conn_data); - /* Give up! */ peer_connection_destroy(conn, OSCAR_DISCONNECT_COULD_NOT_CONNECT); } Modified: trunk/src/protocols/oscar/peer.h =================================================================== --- trunk/src/protocols/oscar/peer.h 2006-08-13 08:38:02 UTC (rev 16734) +++ trunk/src/protocols/oscar/peer.h 2006-08-13 08:41:07 UTC (rev 16735) @@ -159,10 +159,21 @@ gpointer frame; /** + * This is only used when the peer connection is being established. + */ + GaimProxyConnectInfo *connect_info; + + /** + * This is only used when the peer connection is being established. + */ + guint connect_timeout_timer; + + /** * This is only used while the remote user is attempting to * connect to us. */ int listenerfd; + int fd; guint watcher_incoming; Modified: trunk/src/protocols/oscar/peer_proxy.c =================================================================== --- trunk/src/protocols/oscar/peer_proxy.c 2006-08-13 08:38:02 UTC (rev 16734) +++ trunk/src/protocols/oscar/peer_proxy.c 2006-08-13 08:41:07 UTC (rev 16735) @@ -328,21 +328,11 @@ void peer_proxy_connection_established_cb(gpointer data, gint source) { - NewPeerConnectionData *new_conn_data; - GaimConnection *gc; PeerConnection *conn; - new_conn_data = data; - gc = new_conn_data->gc; - conn = new_conn_data->conn; - g_free(new_conn_data); + conn = data; - if (!GAIM_CONNECTION_IS_VALID(gc)) - { - if (source >= 0) - close(source); - return; - } + conn->connect_info = NULL; if (source < 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-13 08:38:06
|
Revision: 16734 Author: thekingant Date: 2006-08-13 01:38:02 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16734&view=rev Log Message: ----------- gaim_proxy_connect()ion attemps can now be canceled. So there is no longer a need to do that GAIM_CONNECTION_IS_VALID() crap at the top of gaim_proxy_connect() callback functions. All of the callers of gaim_proxy_connect() still need to be updated, though. Modified Paths: -------------- trunk/src/proxy.c trunk/src/proxy.h Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-13 06:09:48 UTC (rev 16733) +++ trunk/src/proxy.c 2006-08-13 08:38:02 UTC (rev 16734) @@ -44,6 +44,7 @@ gpointer data; char *host; int port; + int fd; guint inpa; GaimProxyInfo *gpi; @@ -53,6 +54,10 @@ */ GSList *hosts; + /* + * All of the following variables are used when establishing a + * connection through a proxy. + */ guchar *write_buffer; gsize write_buf_len; gsize written_len; @@ -75,9 +80,15 @@ }; static GaimProxyInfo *global_proxy_info = NULL; + +/* + * TODO: Once all callers of gaim_proxy_connect() are keeping track + * of the return value from that function this linked list + * will no longer be needed. + */ static GSList *connect_infos = NULL; -static void try_connect(GaimProxyConnectInfo *); +static void try_connect(GaimProxyConnectInfo *connect_info); /************************************************************************** * Proxy structure API @@ -262,14 +273,41 @@ * Proxy API **************************************************************************/ +/* + * This is used when the connection attempt to one particular IP + * address fails. We close the socket, remove the watcher and get + * rid of input and output buffers. Normally try_connect() will + * be called immediately after this. + */ static void +gaim_proxy_connect_info_disconnect(GaimProxyConnectInfo *connect_info) +{ + if (connect_info->inpa > 0) + { + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + } + + if (connect_info->fd >= 0) + { + close(connect_info->fd); + connect_info->fd = -1; + } + + g_free(connect_info->write_buffer); + connect_info->write_buffer = NULL; + + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; +} + +static void gaim_proxy_connect_info_destroy(GaimProxyConnectInfo *connect_info) { + gaim_proxy_connect_info_disconnect(connect_info); + connect_infos = g_slist_remove(connect_infos, connect_info); - if (connect_info->inpa > 0) - gaim_input_remove(connect_info->inpa); - while (connect_info->hosts != NULL) { /* Discard the length... */ @@ -280,15 +318,21 @@ } g_free(connect_info->host); - g_free(connect_info->write_buffer); - g_free(connect_info->read_buffer); g_free(connect_info); } static void -gaim_proxy_connect_info_connected(GaimProxyConnectInfo *connect_info, int fd) +gaim_proxy_connect_info_connected(GaimProxyConnectInfo *connect_info) { - connect_info->connect_cb(connect_info->data, fd); + connect_info->connect_cb(connect_info->data, connect_info->fd); + + /* + * We've passed the file descriptor to the protocol, so it's no longer + * our responsibility, and we should be careful not to free it when + * we destroy the connect_info. + */ + connect_info->fd = -1; + gaim_proxy_connect_info_destroy(connect_info); } @@ -1019,19 +1063,17 @@ * be overly optimistic sometimes. select is just a hint that you might be * able to do something.) */ - ret = getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len); + ret = getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len); if (ret == 0 && error == EINPROGRESS) return; /* we'll be called again later */ if (ret < 0 || error != 0) { if (ret!=0) error = errno; - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; gaim_debug_error("proxy", "getsockopt SO_ERROR check: %s\n", strerror(error)); + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1039,71 +1081,77 @@ gaim_input_remove(connect_info->inpa); connect_info->inpa = 0; - gaim_proxy_connect_info_connected(connect_info, source); + gaim_proxy_connect_info_connected(connect_info); } -static gboolean clean_connect(gpointer data) +static gboolean +clean_connect(gpointer data) { - GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info; - gaim_proxy_connect_info_connected(connect_info, connect_info->port); + connect_info = data; + gaim_proxy_connect_info_connected(connect_info); return FALSE; } - static int proxy_connect_none(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { - int fd = -1; + gaim_debug_info("proxy", "Connecting to %s:%d with no proxy\n", + connect_info->host, connect_info->port); - gaim_debug_info("proxy", - "Connecting to %s:%d with no proxy\n", connect_info->host, connect_info->port); - - if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { + connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_info->fd < 0) + { gaim_debug_error("proxy", "Unable to create socket: %s\n", strerror(errno)); return -1; } - fcntl(fd, F_SETFL, O_NONBLOCK); + fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, (struct sockaddr *)addr, addrlen) != 0) + if (connect(connect_info->fd, (struct sockaddr *)addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - /* This just confuses people. */ - /* gaim_debug_warning("proxy", - "Connect would have blocked.\n"); */ - connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, connect_info); + gaim_debug_info("proxy", "Connection in progress\n"); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, no_one_calls, connect_info); } else { gaim_debug_error("proxy", "Connect failed: %s\n", strerror(errno)); - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } } - else { + else + { + /* + * The connection happened IMMEDIATELY... strange, but whatever. + */ socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("proxy", "Connect didn't block.\n"); + gaim_debug_info("proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { gaim_debug_error("proxy", "getsockopt failed.\n"); - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } - /* TODO: Why is the following line so strange? */ - connect_info->port = fd; /* bleh */ - gaim_timeout_add(10, clean_connect, connect_info); /* we do this because we never - want to call our callback - before we return. */ + + /* + * We want to call the "connected" callback eventually, but we + * don't want to call it before we return, just in case. + */ + gaim_timeout_add(10, clean_connect, connect_info); } - return fd; + return connect_info->fd; } static void @@ -1113,16 +1161,12 @@ const guchar *request = connect_info->write_buffer + connect_info->written_len; gsize request_len = connect_info->write_buf_len - connect_info->written_len; - int ret = write(source, request, request_len); + int ret = write(connect_info->fd, request, request_len); if(ret < 0 && errno == EAGAIN) return; else if(ret < 0) { - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - close(source); - g_free(connect_info->write_buffer); - connect_info->write_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } else if (ret < request_len) { @@ -1135,7 +1179,7 @@ connect_info->write_buffer = NULL; /* register the response handler for the response */ - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_READ, connect_info->read_cb, connect_info); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_READ, connect_info->read_cb, connect_info); } #define HTTP_GOODSTRING "HTTP/1.0 200" @@ -1161,11 +1205,10 @@ p = connect_info->read_buffer + connect_info->read_len; max_read = connect_info->read_buf_len - connect_info->read_len - 1; - len = read(source, p, max_read); + len = read(connect_info->fd, p, max_read); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - close(source); gaim_proxy_connect_info_error(connect_info, _("Lost connection with server for an unknown reason.")); return; } else { @@ -1222,14 +1265,13 @@ complaining / breaking since we don't read the whole page */ while(len--) { /* TODO: deal with EAGAIN (and other errors) better */ - if (read(source, &tmpc, 1) < 0 && errno != EAGAIN) + if (read(connect_info->fd, &tmpc, 1) < 0 && errno != EAGAIN) break; } } if (error) { - close(source); msg = g_strdup_printf("Unable to parse response from HTTP proxy: %s\n", connect_info->read_buffer); gaim_proxy_connect_info_error(connect_info, msg); @@ -1255,7 +1297,6 @@ username = strchr(domain, '\\'); if (username == NULL) { - close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); @@ -1292,10 +1333,10 @@ connect_info->read_cb = http_canread; - connect_info->inpa = gaim_input_add(source, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, cond); + proxy_do_write(connect_info, connect_info->fd, cond); return; } else if((ntlm = g_strrstr((const char *)connect_info->read_buffer, "Proxy-Authenticate: NTLM"))) { /* Empty message */ gchar request[2048]; @@ -1305,7 +1346,6 @@ username = strchr(domain, '\\'); if (username == NULL) { - close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); @@ -1339,13 +1379,12 @@ connect_info->read_cb = http_canread; - connect_info->inpa = gaim_input_add(source, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, cond); + proxy_do_write(connect_info, connect_info->fd, cond); return; } else { - close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); @@ -1367,7 +1406,7 @@ g_free(connect_info->read_buffer); connect_info->read_buffer = NULL; gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_connect_info_connected(connect_info, source); + gaim_proxy_connect_info_connected(connect_info); return; } } @@ -1393,9 +1432,8 @@ len = sizeof(error); - if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - close(source); - + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1435,48 +1473,46 @@ connect_info->read_cb = http_canread; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, cond); + proxy_do_write(connect_info, connect_info->fd, cond); } static int proxy_connect_http(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { - int fd = -1; - gaim_debug_info("http proxy", "Connecting to %s:%d via %s:%d using HTTP\n", (connect_info->host ? connect_info->host : "(null)"), connect_info->port, (gaim_proxy_info_get_host(connect_info->gpi) ? gaim_proxy_info_get_host(connect_info->gpi) : "(null)"), gaim_proxy_info_get_port(connect_info->gpi)); - if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { + connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_info->fd < 0) return -1; - } - fcntl(fd, F_SETFL, O_NONBLOCK); + fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) != 0) + if (connect(connect_info->fd, addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - gaim_debug_warning("http proxy", - "Connect would have blocked.\n"); + gaim_debug_info("http proxy", "Connection in progress\n"); if (connect_info->port != 80) { /* we need to do CONNECT first */ - connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, http_canwrite, connect_info); } else { gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_connect_info_connected(connect_info, fd); + gaim_proxy_connect_info_connected(connect_info); } } else { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } } @@ -1484,19 +1520,19 @@ socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("http proxy", - "Connect didn't block.\n"); + gaim_debug_info("http proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } - http_canwrite(connect_info, fd, GAIM_INPUT_WRITE); + http_canwrite(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } - return fd; + return connect_info->fd; } @@ -1519,24 +1555,18 @@ buf = connect_info->read_buffer + connect_info->read_len; max_read = connect_info->read_buf_len - connect_info->read_len; - len = read(source, buf, max_read); + len = read(connect_info->fd, buf, max_read); if ((len < 0 && errno == EAGAIN) || (len > 0 && len + connect_info->read_len < 4)) return; else if (len + connect_info->read_len >= 4) { if (connect_info->read_buffer[1] == 90) { - gaim_proxy_connect_info_connected(connect_info, source); + gaim_proxy_connect_info_connected(connect_info); return; } } - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; - - close(source); - + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); } @@ -1559,9 +1589,8 @@ len = sizeof(error); - if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - close(source); - + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1574,9 +1603,10 @@ * with an option, or some detection mechanism - in the * meantime, stick with plain old SOCKS4. */ - if (!(hp = gethostbyname(connect_info->host))) { - close(source); - + /* TODO: This needs to be non-blocking! */ + hp = gethostbyname(connect_info->host); + if (hp == NULL) { + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1596,60 +1626,59 @@ connect_info->written_len = 0; connect_info->read_cb = s4_canread; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, cond); + proxy_do_write(connect_info, connect_info->fd, cond); } static int proxy_connect_socks4(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { - int fd = -1; - gaim_debug_info("socks4 proxy", "Connecting to %s:%d via %s:%d using SOCKS4\n", connect_info->host, connect_info->port, gaim_proxy_info_get_host(connect_info->gpi), gaim_proxy_info_get_port(connect_info->gpi)); - if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) + connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_info->fd < 0) return -1; - fcntl(fd, F_SETFL, O_NONBLOCK); + fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) != 0) + if (connect(connect_info->fd, addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - gaim_debug_warning("socks4 proxy", - "Connect would have blocked.\n"); - connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s4_canwrite, connect_info); + gaim_debug_info("socks4 proxy", "Connection in progress.\n"); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, s4_canwrite, connect_info); } else { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } } else { socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("socks4 proxy", - "Connect didn't block.\n"); + gaim_debug_info("socks4 proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } - s4_canwrite(connect_info, fd, GAIM_INPUT_WRITE); + s4_canwrite(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } - return fd; + return connect_info->fd; } static void @@ -1670,16 +1699,12 @@ gaim_debug_info("socks5 proxy", "Able to read again.\n"); - len = read(source, dest, (connect_info->read_buf_len - connect_info->read_len)); + len = read(connect_info->fd, dest, (connect_info->read_buf_len - connect_info->read_len)); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { gaim_debug_warning("socks5 proxy", "or not...\n"); - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1693,11 +1718,7 @@ gaim_debug_error("socks5 proxy", socks5errors[buf[1]]); else gaim_debug_error("socks5 proxy", "Bad data.\n"); - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1732,7 +1753,7 @@ /* Skip past BND.PORT */ buf += 2; - gaim_proxy_connect_info_connected(connect_info, source); + gaim_proxy_connect_info_connected(connect_info); } static void @@ -1755,8 +1776,8 @@ connect_info->read_cb = s5_canread_again; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } static void @@ -1773,16 +1794,12 @@ gaim_debug_info("socks5 proxy", "Got auth response.\n"); - len = read(source, connect_info->read_buffer + connect_info->read_len, + len = read(connect_info->fd, connect_info->read_buffer + connect_info->read_len, connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1795,9 +1812,7 @@ connect_info->inpa = 0; if ((connect_info->read_buffer[0] != 0x01) || (connect_info->read_buffer[1] != 0x00)) { - close(source); - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1805,7 +1820,7 @@ g_free(connect_info->read_buffer); connect_info->read_buffer = NULL; - s5_sendconnect(connect_info, source); + s5_sendconnect(connect_info, connect_info->fd); } static void @@ -1867,17 +1882,13 @@ connect_info->read_len = 0; } - len = read(source, connect_info->read_buffer + connect_info->read_len, + len = read(connect_info->fd, connect_info->read_buffer + connect_info->read_len, connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1889,11 +1900,7 @@ cmdbuf = connect_info->read_buffer; if (*cmdbuf != 0x01) { - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1917,18 +1924,14 @@ g_free(connect_info->read_buffer); connect_info->read_buffer = NULL; /* Success */ - s5_sendconnect(connect_info, source); + s5_sendconnect(connect_info, connect_info->fd); return; } else { /* Failure */ gaim_debug_warning("proxy", "socks5 CHAP authentication " "failed. Disconnecting..."); - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -1954,10 +1957,10 @@ connect_info->read_cb = s5_readchap; - connect_info->inpa = gaim_input_add(source, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); break; case 0x11: /* Server wants to select an algorithm */ @@ -1969,11 +1972,7 @@ "as supporting. This is a violation " "of the socks5 CHAP specification. " "Disconnecting..."); - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -2000,16 +1999,12 @@ gaim_debug_info("socks5 proxy", "Able to read.\n"); - len = read(source, connect_info->read_buffer + connect_info->read_len, + len = read(connect_info->fd, connect_info->read_buffer + connect_info->read_len, connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { - close(source); - gaim_input_remove(connect_info->inpa); - connect_info->inpa = 0; - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -2022,9 +2017,7 @@ connect_info->inpa = 0; if ((connect_info->read_buffer[0] != 0x05) || (connect_info->read_buffer[1] == 0xff)) { - close(source); - g_free(connect_info->read_buffer); - connect_info->read_buffer = NULL; + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -2056,10 +2049,10 @@ connect_info->read_cb = s5_readauth; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); return; } else if (connect_info->read_buffer[1] == 0x03) { @@ -2085,17 +2078,17 @@ connect_info->read_cb = s5_readchap; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); return; } else { g_free(connect_info->read_buffer); connect_info->read_buffer = NULL; - s5_sendconnect(connect_info, source); + s5_sendconnect(connect_info, connect_info->fd); } } @@ -2117,9 +2110,8 @@ } len = sizeof(error); - if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { - close(source); - + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + gaim_proxy_connect_info_disconnect(connect_info); try_connect(connect_info); return; } @@ -2146,39 +2138,37 @@ connect_info->read_cb = s5_canread; - connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + proxy_do_write(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } static int proxy_connect_socks5(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { - int fd = -1; - gaim_debug_info("socks5 proxy", "Connecting to %s:%d via %s:%d using SOCKS5\n", connect_info->host, connect_info->port, gaim_proxy_info_get_host(connect_info->gpi), gaim_proxy_info_get_port(connect_info->gpi)); - if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) + connect_info->fd = socket(addr->sa_family, SOCK_STREAM, 0); + if (connect_info->fd < 0) return -1; - fcntl(fd, F_SETFL, O_NONBLOCK); + fcntl(connect_info->fd, F_SETFL, O_NONBLOCK); #ifndef _WIN32 - fcntl(fd, F_SETFD, FD_CLOEXEC); + fcntl(connect_info->fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) != 0) + if (connect(connect_info->fd, addr, addrlen) != 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { - gaim_debug_warning("socks5 proxy", - "Connect would have blocked.\n"); - - connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s5_canwrite, connect_info); + gaim_debug_info("socks5 proxy", "Connection in progress\n"); + connect_info->inpa = gaim_input_add(connect_info->fd, GAIM_INPUT_WRITE, s5_canwrite, connect_info); } else { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } } @@ -2186,22 +2176,28 @@ socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("socks5 proxy", "Connect didn't block.\n"); + gaim_debug_info("socks5 proxy", "Connected immediately.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + if (getsockopt(connect_info->fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) { - close(fd); + close(connect_info->fd); + connect_info->fd = -1; return -1; } - s5_canwrite(connect_info, fd, GAIM_INPUT_WRITE); + s5_canwrite(connect_info, connect_info->fd, GAIM_INPUT_WRITE); } - return fd; + return connect_info->fd; } +/** + * This function iterates through a list of IP addresses and attempts + * to connect to each one. This is called after the hostname is + * resolved, and if a connection attempt fails. + */ static void try_connect(GaimProxyConnectInfo *connect_info) { size_t addrlen; @@ -2356,6 +2352,7 @@ /* 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; @@ -2418,6 +2415,7 @@ /* 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; @@ -2437,6 +2435,11 @@ return connect_info; } +void +gaim_proxy_connect_cancel(GaimProxyConnectInfo *connect_info) +{ + gaim_proxy_connect_info_destroy(connect_info); +} static void proxy_pref_cb(const char *name, GaimPrefType type, Modified: trunk/src/proxy.h =================================================================== --- trunk/src/proxy.h 2006-08-13 06:09:48 UTC (rev 16733) +++ trunk/src/proxy.h 2006-08-13 08:38:02 UTC (rev 16734) @@ -271,6 +271,17 @@ GaimProxyErrorFunction error_cb, gpointer data); /** + * Cancel an in-progress connection attempt. This should be called + * by the PRPL if the user disables an account while it is still + * performing the initial sign on. Or when establishing a file + * transfer, if we attempt to connect to a remote user but they + * are behind a firewall then the PRPL can cancel the connection + * attempt early rather than just letting the OS's TCP/IP stack + * time-out the connection. + */ +void gaim_proxy_connect_cancel(GaimProxyConnectInfo *connect_info); + +/** * Do an async dns query * * @param hostname The hostname to resolve This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <may...@us...> - 2006-08-13 06:09:56
|
Revision: 16733 Author: mayuan2006 Date: 2006-08-12 23:09:48 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16733&view=rev Log Message: ----------- change the BL process method continue to debug This is an in progress version,continue to add support for send Yahoo Message committed by Ma Yuan <may...@gm...> Modified Paths: -------------- branches/soc-2006-msnp13/src/protocols/msn/contact.c branches/soc-2006-msnp13/src/protocols/msn/msn.h branches/soc-2006-msnp13/src/protocols/msn/notification.c branches/soc-2006-msnp13/src/protocols/msn/userlist.c Modified: branches/soc-2006-msnp13/src/protocols/msn/contact.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/contact.c 2006-08-13 05:50:19 UTC (rev 16732) +++ branches/soc-2006-msnp13/src/protocols/msn/contact.c 2006-08-13 06:09:48 UTC (rev 16733) @@ -91,8 +91,8 @@ return MSN_LIST_AL_OP; }else if(!strcmp(role,"Block")){ return MSN_LIST_BL_OP; -// }else if(!strcmp(role,"Reverse")){ -// return MSN_LIST_RL_OP; + }else if(!strcmp(role,"Reverse")){ + return MSN_LIST_RL_OP; } return 0; } @@ -326,7 +326,7 @@ } msn_user_set_uid(user,uid); msn_user_set_type(user,msn_get_user_type(type)); - user->list_op |= 1; + user->list_op |= MSN_LIST_FL_OP; gaim_debug_misc("MsnContact","\n"); groupIds = xmlnode_get_child(contactInfo,"groupIds"); Modified: branches/soc-2006-msnp13/src/protocols/msn/msn.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/msn.h 2006-08-13 05:50:19 UTC (rev 16732) +++ branches/soc-2006-msnp13/src/protocols/msn/msn.h 2006-08-13 06:09:48 UTC (rev 16733) @@ -100,6 +100,7 @@ MSN_LIST_RL_OP = 0x08 } MsnListOp; +#define MSN_LIST_OP_MASK 0x07 typedef enum { Modified: branches/soc-2006-msnp13/src/protocols/msn/notification.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-13 05:50:19 UTC (rev 16732) +++ branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-13 06:09:48 UTC (rev 16733) @@ -481,11 +481,18 @@ gaim_debug_info("MaYuan","list_op:%d\n",list_op_str); xmlnode_set_attrib(c_node,"l",list_op_str); g_free(list_op_str); -#if 0 +#if 1 type_str = g_strdup_printf("%d",type); xmlnode_set_attrib(c_node,"t",type_str); #else - type_str = g_strdup_printf("1"); + if(g_strrstr(domain,"yahoo") != NULL){ + type_str = g_strdup_printf("31"); + }else{ + /*passport*/ + type_str = g_strdup_printf("1"); + } + /*mobile*/ + //type_str = g_strdup_printf("4"); xmlnode_set_attrib(c_node,"t",type_str); g_free(type_str); #endif @@ -514,7 +521,7 @@ /*get the userlist*/ for (l = userlist->users; l != NULL; l = l->next){ user = l->data; - msn_add_contact_xml(adl_node,user->passport,user->list_op,user->type); + msn_add_contact_xml(adl_node,user->passport,user->list_op&MSN_LIST_OP_MASK,user->type); } payload = xmlnode_to_str(adl_node,&payload_len); @@ -739,6 +746,7 @@ state = cmd->params[1]; passport = cmd->params[2]; + /*if a contact is actually on the WLM part or the yahoo part*/ wlmclient = atoi(cmd->params[3]); friendly = gaim_url_decode(cmd->params[4]); Modified: branches/soc-2006-msnp13/src/protocols/msn/userlist.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/userlist.c 2006-08-13 05:50:19 UTC (rev 16732) +++ branches/soc-2006-msnp13/src/protocols/msn/userlist.c 2006-08-13 06:09:48 UTC (rev 16733) @@ -228,6 +228,7 @@ const char *passport; const char *friendly; + gaim_debug_info("MaYuan","got add user...\n"); account = session->account; passport = msn_user_get_passport(user); @@ -675,9 +676,8 @@ gaim_debug_info("MaYuan", "add user:{%s} to group id {%s}\n",store_name ,group_id); msn_add_contact(userlist->session->contact,who,group_id); -/* msn_notification_add_buddy(userlist->session->notification, list, who, + msn_notification_add_buddy(userlist->session->notification, list, who, store_name, group_id); - */ } void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-13 05:50:21
|
Revision: 16732 Author: thekingant Date: 2006-08-12 22:50:19 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16732&view=rev Log Message: ----------- Jabber crashed when getting info from someone on your buddy list if the JID consists only of the domain identifer. For example, add "quser.alpha.qunu.com" to your buddy list then get their info. This fixes the crashing. I'm not really sure if the fix is correct. Can someone familiar with Jabber please look over this? Modified Paths: -------------- trunk/src/protocols/jabber/buddy.c Modified: trunk/src/protocols/jabber/buddy.c =================================================================== --- trunk/src/protocols/jabber/buddy.c 2006-08-13 05:22:33 UTC (rev 16731) +++ trunk/src/protocols/jabber/buddy.c 2006-08-13 05:50:19 UTC (rev 16732) @@ -1119,15 +1119,20 @@ for(resources = jb->resources; resources; resources = resources->next) { JabberBuddyResource *jbr = resources->data; - JabberBuddyInfoResource *jbir = g_new0(JabberBuddyInfoResource, 1); + JabberBuddyInfoResource *jbir; char *full_jid; - if(strrchr(jid, '/')) { + + if ((strchr(jid, '/') == NULL) && (jbr->name != NULL)) { + full_jid = g_strdup_printf("%s/%s", jid, jbr->name); + } else { full_jid = g_strdup(jid); - } else { - full_jid = g_strdup_printf("%s/%s", jid, jbr->name); } - g_hash_table_insert(jbi->resources, g_strdup(jbr->name), jbir); + if (jbr->name != NULL) + { + jbir = g_new0(JabberBuddyInfoResource, 1); + g_hash_table_insert(jbi->resources, g_strdup(jbr->name), jbir); + } if(!jbr->client.name) { iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:version"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-13 05:22:36
|
Revision: 16731 Author: thekingant Date: 2006-08-12 22:22:33 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16731&view=rev Log Message: ----------- Uh, I THINK this is what was intended...? Modified Paths: -------------- trunk/src/protocols/jabber/JEPS Modified: trunk/src/protocols/jabber/JEPS =================================================================== --- trunk/src/protocols/jabber/JEPS 2006-08-13 02:18:28 UTC (rev 16730) +++ trunk/src/protocols/jabber/JEPS 2006-08-13 05:22:33 UTC (rev 16731) @@ -22,6 +22,6 @@ Gateway Interaction (Transports) 0115: WATCH Client Capabilities -0017: NEED - Advanced IM Protocol Suite +0117: NEED + Intermediate IM Protocol Suite This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dat...@us...> - 2006-08-13 02:18:32
|
Revision: 16730 Author: datallah Date: 2006-08-12 19:18:28 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16730&view=rev Log Message: ----------- Fix the documentation to indicate that the result of xmlnode_get_data() needs to be g_free'd Modified Paths: -------------- trunk/src/xmlnode.h Modified: trunk/src/xmlnode.h =================================================================== --- trunk/src/xmlnode.h 2006-08-12 22:18:28 UTC (rev 16729) +++ trunk/src/xmlnode.h 2006-08-13 02:18:28 UTC (rev 16730) @@ -31,7 +31,7 @@ typedef enum _XMLNodeType { XMLNODE_TYPE_TAG, /**< Just a tag */ - XMLNODE_TYPE_ATTRIB, /**< Has attributes */ + XMLNODE_TYPE_ATTRIB, /**< Has attributes */ XMLNODE_TYPE_DATA /**< Has data */ } XMLNodeType; @@ -40,13 +40,13 @@ */ typedef struct _xmlnode { - char *name; /**< The name of the node. */ + char *name; /**< The name of the node. */ #ifdef HAVE_LIBXML - char *namespace; /**< The namespace of the node */ + char *namespace; /**< The namespace of the node */ #endif - XMLNodeType type; /**< The type of the node. */ - char *data; /**< The data for the node. */ - size_t data_sz; /**< The size of the data. */ + XMLNodeType type; /**< The type of the node. */ + char *data; /**< The data for the node. */ + size_t data_sz; /**< The size of the data. */ struct _xmlnode *parent; /**< The parent node or @c NULL.*/ struct _xmlnode *child; /**< The child node or @c NULL.*/ struct _xmlnode *lastchild; /**< The last child node or @c NULL.*/ @@ -125,7 +125,8 @@ * * @param node The node to get data from. * - * @return The data from the node. + * @return The data from the node. You must g_free + * this string when finished using it. */ char *xmlnode_get_data(xmlnode *node); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 22:18:34
|
Revision: 16729 Author: thekingant Date: 2006-08-12 15:18:28 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16729&view=rev Log Message: ----------- Backport SVN revisions 16725 through 16728 from HEAD to v2_0_0 Original commit messages: 16725: Rename "phb" to "connect_info" everywhere 16726: Use the GaimProxyConnectInfo typedef instead of struct _GaimProxyConnectInfo. Sorry, I should have done this in one of my other commits 16727: I decided that it's probably not a good idea to enable_fatal_asserts when --enable-debug is passed to autogen.sh/configure. However, EVERY Gaim dev, summer of code student and crazy patch writer should pass "--enable-fatal-asserts" to Gaim's autogen.sh/configure (It causes Gaim to segfault when g_return_val_if_fail() fails) 16728: Extremely minor error message improvements Modified Paths: -------------- branches/v2_0_0/configure.ac branches/v2_0_0/plugins/ChangeLog.API branches/v2_0_0/src/proxy.c Modified: branches/v2_0_0/configure.ac =================================================================== --- branches/v2_0_0/configure.ac 2006-08-12 22:16:23 UTC (rev 16728) +++ branches/v2_0_0/configure.ac 2006-08-12 22:18:28 UTC (rev 16729) @@ -542,7 +542,6 @@ if test "x$enable_debug" = "xyes" ; then AC_DEFINE(DEBUG, 1, [Define if debugging is enabled.]) - enable_fatal_asserts="yes" fi if test "x$enable_fatal_asserts" = "xyes" ; then @@ -1816,9 +1815,10 @@ echo echo Use XScreenSaver Extension.... : $enable_xss echo Use X Session Management...... : $enable_sm -echo Use startup notification.......: $enable_startup_notification +echo Use startup notification...... : $enable_startup_notification echo echo Print debugging messages...... : $enable_debug +echo Assertions are fatal.......... : $enable_fatal_asserts echo eval eval echo Gaim will be installed in $bindir. if test "x$gaimpath" != "x" ; then Modified: branches/v2_0_0/plugins/ChangeLog.API =================================================================== --- branches/v2_0_0/plugins/ChangeLog.API 2006-08-12 22:16:23 UTC (rev 16728) +++ branches/v2_0_0/plugins/ChangeLog.API 2006-08-12 22:18:28 UTC (rev 16729) @@ -114,6 +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_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/proxy.c =================================================================== --- branches/v2_0_0/src/proxy.c 2006-08-12 22:16:23 UTC (rev 16728) +++ branches/v2_0_0/src/proxy.c 2006-08-12 22:18:28 UTC (rev 16729) @@ -38,7 +38,6 @@ #include "proxy.h" #include "util.h" -/* Does anyone know what PHB stands for? */ struct _GaimProxyConnectInfo { GaimProxyConnectFunction connect_cb; GaimProxyErrorFunction error_cb; @@ -47,7 +46,13 @@ int port; guint inpa; GaimProxyInfo *gpi; + + /** + * This contains alternating length/char* values. The char* + * values need to be freed when removed from the linked list. + */ GSList *hosts; + guchar *write_buffer; gsize write_buf_len; gsize written_len; @@ -70,9 +75,9 @@ }; static GaimProxyInfo *global_proxy_info = NULL; -static GSList *phbs = NULL; +static GSList *connect_infos = NULL; -static void try_connect(struct _GaimProxyConnectInfo *); +static void try_connect(GaimProxyConnectInfo *); /************************************************************************** * Proxy structure API @@ -258,33 +263,33 @@ **************************************************************************/ static void -gaim_proxy_phb_destroy(struct _GaimProxyConnectInfo *phb) +gaim_proxy_connect_info_destroy(GaimProxyConnectInfo *connect_info) { - phbs = g_slist_remove(phbs, phb); + connect_infos = g_slist_remove(connect_infos, connect_info); - if (phb->inpa > 0) - gaim_input_remove(phb->inpa); + if (connect_info->inpa > 0) + gaim_input_remove(connect_info->inpa); - while (phb->hosts != NULL) + while (connect_info->hosts != NULL) { /* Discard the length... */ - phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); /* Free the address... */ - g_free(phb->hosts->data); - phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + g_free(connect_info->hosts->data); + connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); } - g_free(phb->host); - g_free(phb->write_buffer); - g_free(phb->read_buffer); - g_free(phb); + g_free(connect_info->host); + g_free(connect_info->write_buffer); + g_free(connect_info->read_buffer); + g_free(connect_info); } static void -gaim_proxy_phb_connected(struct _GaimProxyConnectInfo *phb, int fd) +gaim_proxy_connect_info_connected(GaimProxyConnectInfo *connect_info, int fd) { - phb->connect_cb(phb->data, fd); - gaim_proxy_phb_destroy(phb); + connect_info->connect_cb(connect_info->data, fd); + gaim_proxy_connect_info_destroy(connect_info); } /** @@ -292,10 +297,14 @@ * failed. This will be passed to the callback function * specified in the call to gaim_proxy_connect(). */ +/* + * TODO: Make sure all callers of this function pass a really really + * good error_message. + */ static void -gaim_proxy_phb_error(struct _GaimProxyConnectInfo *phb, const gchar *error_message) +gaim_proxy_connect_info_error(GaimProxyConnectInfo *connect_info, const gchar *error_message) { - if (phb->error_cb == NULL) + if (connect_info->error_cb == NULL) { /* * TODO @@ -305,13 +314,13 @@ * an fd of -1 in the case of an error. Once all callers have * been changed this whole if statement should be removed. */ - phb->connect_cb(phb->data, -1); - gaim_proxy_phb_destroy(phb); + connect_info->connect_cb(connect_info->data, -1); + gaim_proxy_connect_info_destroy(connect_info); return; } - phb->error_cb(phb->data, error_message); - gaim_proxy_phb_destroy(phb); + connect_info->error_cb(connect_info->data, error_message); + gaim_proxy_connect_info_destroy(connect_info); } #if defined(__unix__) || defined(__APPLE__) @@ -991,7 +1000,7 @@ static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error=0, ret; @@ -1017,39 +1026,39 @@ if (ret!=0) error = errno; close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; gaim_debug_error("proxy", "getsockopt SO_ERROR check: %s\n", strerror(error)); - try_connect(phb); + try_connect(connect_info); return; } - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; - gaim_proxy_phb_connected(phb, source); + gaim_proxy_connect_info_connected(connect_info, source); } static gboolean clean_connect(gpointer data) { - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; - gaim_proxy_phb_connected(phb, phb->port); + gaim_proxy_connect_info_connected(connect_info, connect_info->port); return FALSE; } static int -proxy_connect_none(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_none(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; gaim_debug_info("proxy", - "Connecting to %s:%d with no proxy\n", phb->host, phb->port); + "Connecting to %s:%d with no proxy\n", connect_info->host, connect_info->port); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { gaim_debug_error("proxy", @@ -1061,12 +1070,13 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, (struct sockaddr *)addr, addrlen) < 0) { + if (connect(fd, (struct sockaddr *)addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { /* This just confuses people. */ /* gaim_debug_warning("proxy", "Connect would have blocked.\n"); */ - phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb); + connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, connect_info); } else { gaim_debug_error("proxy", @@ -1080,14 +1090,15 @@ int error = ETIMEDOUT; gaim_debug_misc("proxy", "Connect didn't block.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { gaim_debug_error("proxy", "getsockopt failed.\n"); close(fd); return -1; } /* TODO: Why is the following line so strange? */ - phb->port = fd; /* bleh */ - gaim_timeout_add(10, clean_connect, phb); /* we do this because we never + connect_info->port = fd; /* bleh */ + gaim_timeout_add(10, clean_connect, connect_info); /* we do this because we never want to call our callback before we return. */ } @@ -1098,33 +1109,33 @@ static void proxy_do_write(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; - const guchar *request = phb->write_buffer + phb->written_len; - gsize request_len = phb->write_buf_len - phb->written_len; + GaimProxyConnectInfo *connect_info = data; + const guchar *request = connect_info->write_buffer + connect_info->written_len; + gsize request_len = connect_info->write_buf_len - connect_info->written_len; int ret = write(source, request, request_len); if(ret < 0 && errno == EAGAIN) return; else if(ret < 0) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; close(source); - g_free(phb->write_buffer); - phb->write_buffer = NULL; - try_connect(phb); + g_free(connect_info->write_buffer); + connect_info->write_buffer = NULL; + try_connect(connect_info); return; } else if (ret < request_len) { - phb->written_len += ret; + connect_info->written_len += ret; return; } - gaim_input_remove(phb->inpa); - g_free(phb->write_buffer); - phb->write_buffer = NULL; + gaim_input_remove(connect_info->inpa); + g_free(connect_info->write_buffer); + connect_info->write_buffer = NULL; /* register the response handler for the response */ - phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, phb->read_cb, phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_READ, connect_info->read_cb, connect_info); } #define HTTP_GOODSTRING "HTTP/1.0 200" @@ -1136,45 +1147,45 @@ { int len, headers_len, status = 0; gboolean error; - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; guchar *p; gsize max_read; gchar *msg; - if(phb->read_buffer == NULL) { - phb->read_buf_len = 8192; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if(connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 8192; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } - p = phb->read_buffer + phb->read_len; - max_read = phb->read_buf_len - phb->read_len - 1; + p = connect_info->read_buffer + connect_info->read_len; + max_read = connect_info->read_buf_len - connect_info->read_len - 1; len = read(source, p, max_read); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { close(source); - gaim_proxy_phb_error(phb, _("Lost connection with server for an unknown reason.")); + gaim_proxy_connect_info_error(connect_info, _("Lost connection with server for an unknown reason.")); return; } else { - phb->read_len += len; + connect_info->read_len += len; } p[len] = '\0'; - if((p = (guchar *)g_strstr_len((const gchar *)phb->read_buffer, phb->read_len, "\r\n\r\n"))) { + if((p = (guchar *)g_strstr_len((const gchar *)connect_info->read_buffer, connect_info->read_len, "\r\n\r\n"))) { *p = '\0'; - headers_len = (p - phb->read_buffer) + 4; + headers_len = (p - connect_info->read_buffer) + 4; } else if(len == max_read) headers_len = len; else return; - error = strncmp((const char *)phb->read_buffer, "HTTP/", 5) != 0; + error = strncmp((const char *)connect_info->read_buffer, "HTTP/", 5) != 0; if (!error) { int major; - p = phb->read_buffer + 5; + p = connect_info->read_buffer + 5; major = strtol((const char *)p, (char **)&p, 10); error = (major == 0) || (*p != '.'); if(!error) { @@ -1191,7 +1202,7 @@ } /* Read the contents */ - p = (guchar *)g_strrstr((const gchar *)phb->read_buffer, "Content-Length: "); + p = (guchar *)g_strrstr((const gchar *)connect_info->read_buffer, "Content-Length: "); if (p != NULL) { gchar *tmp; @@ -1206,7 +1217,7 @@ *tmp = '\r'; /* Compensate for what has already been read */ - len -= phb->read_len - headers_len; + len -= connect_info->read_len - headers_len; /* I'm assuming that we're doing this to prevent the server from complaining / breaking since we don't read the whole page */ while(len--) { @@ -1220,8 +1231,8 @@ { close(source); msg = g_strdup_printf("Unable to parse response from HTTP proxy: %s\n", - phb->read_buffer); - gaim_proxy_phb_error(phb, msg); + connect_info->read_buffer); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); return; } @@ -1229,15 +1240,15 @@ { gaim_debug_error("proxy", "Proxy server replied with:\n%s\n", - phb->read_buffer); + connect_info->read_buffer); if(status == 407 /* Proxy Auth */) { gchar *ntlm; - if((ntlm = g_strrstr((const gchar *)phb->read_buffer, "Proxy-Authenticate: NTLM "))) { /* Check for Type-2 */ + if((ntlm = g_strrstr((const gchar *)connect_info->read_buffer, "Proxy-Authenticate: NTLM "))) { /* Check for Type-2 */ gchar *tmp = ntlm; guint8 *nonce; - gchar *domain = (gchar*)gaim_proxy_info_get_username(phb->gpi); + gchar *domain = (gchar*)gaim_proxy_info_get_username(connect_info->gpi); gchar *username; gchar *request; gchar *response; @@ -1246,7 +1257,7 @@ { close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_phb_error(phb, msg); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); return; } @@ -1257,8 +1268,8 @@ *tmp = '\0'; nonce = gaim_ntlm_parse_type2(ntlm, NULL); response = gaim_ntlm_gen_type3(username, - (gchar*) gaim_proxy_info_get_password(phb->gpi), - (gchar*) gaim_proxy_info_get_host(phb->gpi), + (gchar*) gaim_proxy_info_get_password(connect_info->gpi), + (gchar*) gaim_proxy_info_get_host(connect_info->gpi), domain, nonce, NULL); username--; *username = '\\'; @@ -1267,28 +1278,28 @@ "Host: %s:%d\r\n" "Proxy-Authorization: NTLM %s\r\n" "Proxy-Connection: Keep-Alive\r\n\r\n", - phb->host, phb->port, phb->host, - phb->port, response); + connect_info->host, connect_info->port, connect_info->host, + connect_info->port, response); g_free(response); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->write_buffer = (guchar *)request; - phb->write_buf_len = strlen(request); - phb->written_len = 0; + connect_info->write_buffer = (guchar *)request; + connect_info->write_buf_len = strlen(request); + connect_info->written_len = 0; - phb->read_cb = http_canread; + connect_info->read_cb = http_canread; - phb->inpa = gaim_input_add(source, - GAIM_INPUT_WRITE, proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, + GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(phb, source, cond); + proxy_do_write(connect_info, source, cond); return; - } else if((ntlm = g_strrstr((const char *)phb->read_buffer, "Proxy-Authenticate: NTLM"))) { /* Empty message */ + } else if((ntlm = g_strrstr((const char *)connect_info->read_buffer, "Proxy-Authenticate: NTLM"))) { /* Empty message */ gchar request[2048]; - gchar *domain = (gchar*) gaim_proxy_info_get_username(phb->gpi); + gchar *domain = (gchar*) gaim_proxy_info_get_username(connect_info->gpi); gchar *username; int request_len; username = strchr(domain, '\\'); @@ -1296,7 +1307,7 @@ { close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_phb_error(phb, msg); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); return; } @@ -1305,8 +1316,8 @@ request_len = g_snprintf(request, sizeof(request), "CONNECT %s:%d HTTP/1.1\r\n" "Host: %s:%d\r\n", - phb->host, phb->port, - phb->host, phb->port); + connect_info->host, connect_info->port, + connect_info->host, connect_info->port); g_return_if_fail(request_len < sizeof(request)); request_len += g_snprintf(request + request_len, @@ -1314,49 +1325,49 @@ "Proxy-Authorization: NTLM %s\r\n" "Proxy-Connection: Keep-Alive\r\n\r\n", gaim_ntlm_gen_type1( - (gchar*) gaim_proxy_info_get_host(phb->gpi), + (gchar*) gaim_proxy_info_get_host(connect_info->gpi), domain)); *username = '\\'; - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->write_buffer = g_memdup(request, request_len); - phb->write_buf_len = request_len; - phb->written_len = 0; + connect_info->write_buffer = g_memdup(request, request_len); + connect_info->write_buf_len = request_len; + connect_info->written_len = 0; - phb->read_cb = http_canread; + connect_info->read_cb = http_canread; - phb->inpa = gaim_input_add(source, - GAIM_INPUT_WRITE, proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, + GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(phb, source, cond); + proxy_do_write(connect_info, source, cond); return; } else { close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_phb_error(phb, msg); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); return; } } if(status == 403 /* Forbidden */ ) { - msg = g_strdup_printf(_("Access denied: HTTP proxy server forbids port %d tunnelling."), phb->port); - gaim_proxy_phb_error(phb, msg); + msg = g_strdup_printf(_("Access denied: HTTP proxy server forbids port %d tunnelling."), connect_info->port); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); } else { msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_phb_error(phb, msg); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); } } else { - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_phb_connected(phb, source); + gaim_proxy_connect_info_connected(connect_info, source); return; } } @@ -1368,16 +1379,16 @@ { char request[8192]; int request_len = 0; - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("http proxy", "Connected.\n"); - if (phb->inpa > 0) + if (connect_info->inpa > 0) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; } len = sizeof(error); @@ -1385,22 +1396,22 @@ if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { close(source); - try_connect(phb); + try_connect(connect_info); return; } gaim_debug_info("proxy", "using CONNECT tunnelling for %s:%d\n", - phb->host, phb->port); + connect_info->host, connect_info->port); request_len = g_snprintf(request, sizeof(request), "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n", - phb->host, phb->port, phb->host, phb->port); + connect_info->host, connect_info->port, connect_info->host, connect_info->port); - if (gaim_proxy_info_get_username(phb->gpi) != NULL) { + if (gaim_proxy_info_get_username(connect_info->gpi) != NULL) { char *t1, *t2; t1 = g_strdup_printf("%s:%s", - gaim_proxy_info_get_username(phb->gpi), - gaim_proxy_info_get_password(phb->gpi) ? - gaim_proxy_info_get_password(phb->gpi) : ""); + gaim_proxy_info_get_username(connect_info->gpi), + gaim_proxy_info_get_password(connect_info->gpi) ? + gaim_proxy_info_get_password(connect_info->gpi) : ""); t2 = gaim_base64_encode((const guchar *)t1, strlen(t1)); g_free(t1); g_return_if_fail(request_len < sizeof(request)); @@ -1411,35 +1422,35 @@ "Proxy-Authorization: NTLM %s\r\n" "Proxy-Connection: Keep-Alive\r\n", t2, gaim_ntlm_gen_type1( - (gchar*)gaim_proxy_info_get_host(phb->gpi),"")); + (gchar*)gaim_proxy_info_get_host(connect_info->gpi),"")); g_free(t2); } g_return_if_fail(request_len < sizeof(request)); strcpy(request + request_len, "\r\n"); request_len += 2; - phb->write_buffer = g_memdup(request, request_len); - phb->write_buf_len = request_len; - phb->written_len = 0; + connect_info->write_buffer = g_memdup(request, request_len); + connect_info->write_buf_len = request_len; + connect_info->written_len = 0; - phb->read_cb = http_canread; + connect_info->read_cb = http_canread; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, - phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, + connect_info); - proxy_do_write(phb, source, cond); + proxy_do_write(connect_info, source, cond); } static int -proxy_connect_http(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_http(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; gaim_debug_info("http proxy", "Connecting to %s:%d via %s:%d using HTTP\n", - (phb->host ? phb->host : "(null)"), phb->port, - (gaim_proxy_info_get_host(phb->gpi) ? gaim_proxy_info_get_host(phb->gpi) : "(null)"), - gaim_proxy_info_get_port(phb->gpi)); + (connect_info->host ? connect_info->host : "(null)"), connect_info->port, + (gaim_proxy_info_get_host(connect_info->gpi) ? gaim_proxy_info_get_host(connect_info->gpi) : "(null)"), + gaim_proxy_info_get_port(connect_info->gpi)); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { return -1; @@ -1450,18 +1461,19 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) < 0) { + if (connect(fd, addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("http proxy", "Connect would have blocked.\n"); - if (phb->port != 80) { + if (connect_info->port != 80) { /* we need to do CONNECT first */ - phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, - http_canwrite, phb); + connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, + http_canwrite, connect_info); } else { gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_phb_connected(phb, fd); + gaim_proxy_connect_info_connected(connect_info, fd); } } else { close(fd); @@ -1476,11 +1488,12 @@ "Connect didn't block.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { close(fd); return -1; } - http_canwrite(phb, fd, GAIM_INPUT_WRITE); + http_canwrite(connect_info, fd, GAIM_INPUT_WRITE); } return fd; @@ -1490,41 +1503,41 @@ static void s4_canread(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; guchar *buf; int len, max_read; /* This is really not going to block under normal circumstances, but to * be correct, we deal with the unlikely scenario */ - if (phb->read_buffer == NULL) { - phb->read_buf_len = 12; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 12; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } - buf = phb->read_buffer + phb->read_len; - max_read = phb->read_buf_len - phb->read_len; + buf = connect_info->read_buffer + connect_info->read_len; + max_read = connect_info->read_buf_len - connect_info->read_len; len = read(source, buf, max_read); - if ((len < 0 && errno == EAGAIN) || (len > 0 && len + phb->read_len < 4)) + if ((len < 0 && errno == EAGAIN) || (len > 0 && len + connect_info->read_len < 4)) return; - else if (len + phb->read_len >= 4) { - if (phb->read_buffer[1] == 90) { - gaim_proxy_phb_connected(phb, source); + else if (len + connect_info->read_len >= 4) { + if (connect_info->read_buffer[1] == 90) { + gaim_proxy_connect_info_connected(connect_info, source); return; } } - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; close(source); - try_connect(phb); + try_connect(connect_info); } static void @@ -1532,16 +1545,16 @@ { unsigned char packet[9]; struct hostent *hp; - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("socks4 proxy", "Connected.\n"); - if (phb->inpa > 0) + if (connect_info->inpa > 0) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; } len = sizeof(error); @@ -1549,7 +1562,7 @@ if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { close(source); - try_connect(phb); + try_connect(connect_info); return; } @@ -1561,43 +1574,43 @@ * with an option, or some detection mechanism - in the * meantime, stick with plain old SOCKS4. */ - if (!(hp = gethostbyname(phb->host))) { + if (!(hp = gethostbyname(connect_info->host))) { close(source); - try_connect(phb); + try_connect(connect_info); return; } packet[0] = 4; packet[1] = 1; - packet[2] = phb->port >> 8; - packet[3] = phb->port & 0xff; + packet[2] = connect_info->port >> 8; + packet[3] = connect_info->port & 0xff; packet[4] = (unsigned char)(hp->h_addr_list[0])[0]; packet[5] = (unsigned char)(hp->h_addr_list[0])[1]; packet[6] = (unsigned char)(hp->h_addr_list[0])[2]; packet[7] = (unsigned char)(hp->h_addr_list[0])[3]; packet[8] = 0; - phb->write_buffer = g_memdup(packet, sizeof(packet)); - phb->write_buf_len = sizeof(packet); - phb->written_len = 0; - phb->read_cb = s4_canread; + connect_info->write_buffer = g_memdup(packet, sizeof(packet)); + connect_info->write_buf_len = sizeof(packet); + connect_info->written_len = 0; + connect_info->read_cb = s4_canread; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(phb, source, cond); + proxy_do_write(connect_info, source, cond); } static int -proxy_connect_socks4(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks4(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; gaim_debug_info("socks4 proxy", "Connecting to %s:%d via %s:%d using SOCKS4\n", - phb->host, phb->port, - gaim_proxy_info_get_host(phb->gpi), - gaim_proxy_info_get_port(phb->gpi)); + connect_info->host, connect_info->port, + gaim_proxy_info_get_host(connect_info->gpi), + gaim_proxy_info_get_port(connect_info->gpi)); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) return -1; @@ -1607,11 +1620,12 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) < 0) { + if (connect(fd, addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("socks4 proxy", "Connect would have blocked.\n"); - phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s4_canwrite, phb); + connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s4_canwrite, connect_info); } else { close(fd); @@ -1626,12 +1640,13 @@ len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { close(fd); return -1; } - s4_canwrite(phb, fd, GAIM_INPUT_WRITE); + s4_canwrite(connect_info, fd, GAIM_INPUT_WRITE); } return fd; @@ -1641,36 +1656,36 @@ s5_canread_again(gpointer data, gint source, GaimInputCondition cond) { guchar *dest, *buf; - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; int len; - if (phb->read_buffer == NULL) { - phb->read_buf_len = 512; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 512; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } - dest = phb->read_buffer + phb->read_len; - buf = phb->read_buffer; + dest = connect_info->read_buffer + connect_info->read_len; + buf = connect_info->read_buffer; gaim_debug_info("socks5 proxy", "Able to read again.\n"); - len = read(source, dest, (phb->read_buf_len - phb->read_len)); + len = read(source, dest, (connect_info->read_buf_len - connect_info->read_len)); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { gaim_debug_warning("socks5 proxy", "or not...\n"); close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - phb->read_len += len; + connect_info->read_len += len; - if(phb->read_len < 4) + if(connect_info->read_len < 4) return; if ((buf[0] != 0x05) || (buf[1] != 0x00)) { @@ -1679,121 +1694,122 @@ else gaim_debug_error("socks5 proxy", "Bad data.\n"); close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } /* Skip past BND.ADDR */ switch(buf[3]) { case 0x01: /* the address is a version-4 IP address, with a length of 4 octets */ - if(phb->read_len < 4 + 4) + if(connect_info->read_len < 4 + 4) return; buf += 4 + 4; break; case 0x03: /* the address field contains a fully-qualified domain name. The first octet of the address field contains the number of octets of name that follow, there is no terminating NUL octet. */ - if(phb->read_len < 4 + 1) + if(connect_info->read_len < 4 + 1) return; buf += 4 + 1; - if(phb->read_len < 4 + 1 + buf[0]) + if(connect_info->read_len < 4 + 1 + buf[0]) return; buf += buf[0]; break; case 0x04: /* the address is a version-6 IP address, with a length of 16 octets */ - if(phb->read_len < 4 + 16) + if(connect_info->read_len < 4 + 16) return; buf += 4 + 16; break; } - if(phb->read_len < (buf - phb->read_buffer) + 2) + if(connect_info->read_len < (buf - connect_info->read_buffer) + 2) return; /* Skip past BND.PORT */ buf += 2; - gaim_proxy_phb_connected(phb, source); + gaim_proxy_connect_info_connected(connect_info, source); } static void s5_sendconnect(gpointer data, int source) { - struct _GaimProxyConnectInfo *phb = data; - int hlen = strlen(phb->host); - phb->write_buf_len = 5 + hlen + 2; - phb->write_buffer = g_malloc(phb->write_buf_len); - phb->written_len = 0; + GaimProxyConnectInfo *connect_info = data; + int hlen = strlen(connect_info->host); + connect_info->write_buf_len = 5 + hlen + 2; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + connect_info->written_len = 0; - phb->write_buffer[0] = 0x05; - phb->write_buffer[1] = 0x01; /* CONNECT */ - phb->write_buffer[2] = 0x00; /* reserved */ - phb->write_buffer[3] = 0x03; /* address type -- host name */ - phb->write_buffer[4] = hlen; - memcpy(phb->write_buffer + 5, phb->host, hlen); - phb->write_buffer[5 + hlen] = phb->port >> 8; - phb->write_buffer[5 + hlen + 1] = phb->port & 0xff; + connect_info->write_buffer[0] = 0x05; + connect_info->write_buffer[1] = 0x01; /* CONNECT */ + connect_info->write_buffer[2] = 0x00; /* reserved */ + connect_info->write_buffer[3] = 0x03; /* address type -- host name */ + connect_info->write_buffer[4] = hlen; + memcpy(connect_info->write_buffer + 5, connect_info->host, hlen); + connect_info->write_buffer[5 + hlen] = connect_info->port >> 8; + connect_info->write_buffer[5 + hlen + 1] = connect_info->port & 0xff; - phb->read_cb = s5_canread_again; + connect_info->read_cb = s5_canread_again; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, phb); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); } static void s5_readauth(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; int len; - if (phb->read_buffer == NULL) { - phb->read_buf_len = 2; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 2; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } gaim_debug_info("socks5 proxy", "Got auth response.\n"); - len = read(source, phb->read_buffer + phb->read_len, - phb->read_buf_len - phb->read_len); + len = read(source, connect_info->read_buffer + connect_info->read_len, + connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - phb->read_len += len; + connect_info->read_len += len; - if (phb->read_len < 2) + if (connect_info->read_len < 2) return; - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; - if ((phb->read_buffer[0] != 0x01) || (phb->read_buffer[1] != 0x00)) { + if ((connect_info->read_buffer[0] != 0x01) || (connect_info->read_buffer[1] != 0x00)) { close(source); - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - g_free(phb->read_buffer); - phb->read_buffer = NULL; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - s5_sendconnect(phb, source); + s5_sendconnect(connect_info, source); } -static void hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response) +static void +hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response) { GaimCipher *cipher; GaimCipherContext *ctx; @@ -1840,45 +1856,45 @@ s5_readchap(gpointer data, gint source, GaimInputCondition cond) { guchar *cmdbuf, *buf; - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; int len, navas, currentav; gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Got CHAP response.\n"); - if (phb->read_buffer == NULL) { - phb->read_buf_len = 20; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 20; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } - len = read(source, phb->read_buffer + phb->read_len, - phb->read_buf_len - phb->read_len); + len = read(source, connect_info->read_buffer + connect_info->read_len, + connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - phb->read_len += len; + connect_info->read_len += len; - if (phb->read_len < 2) + if (connect_info->read_len < 2) return; - cmdbuf = phb->read_buffer; + cmdbuf = connect_info->read_buffer; if (*cmdbuf != 0x01) { close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } cmdbuf++; @@ -1887,21 +1903,21 @@ cmdbuf++; for (currentav = 0; currentav < navas; currentav++) { - if (phb->read_len - (cmdbuf - phb->read_buffer) < 2) + if (connect_info->read_len - (cmdbuf - connect_info->read_buffer) < 2) return; - if (phb->read_len - (cmdbuf - phb->read_buffer) < cmdbuf[1]) + if (connect_info->read_len - (cmdbuf - connect_info->read_buffer) < cmdbuf[1]) return; buf = cmdbuf + 2; switch (cmdbuf[0]) { case 0x00: /* Did auth work? */ if (buf[0] == 0x00) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; /* Success */ - s5_sendconnect(phb, source); + s5_sendconnect(connect_info, source); return; } else { /* Failure */ @@ -1909,39 +1925,39 @@ "socks5 CHAP authentication " "failed. Disconnecting..."); close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } break; case 0x03: /* Server wants our credentials */ - phb->write_buf_len = 16 + 4; - phb->write_buffer = g_malloc(phb->write_buf_len); - phb->written_len = 0; + connect_info->write_buf_len = 16 + 4; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + connect_info->written_len = 0; hmacmd5_chap(buf, cmdbuf[1], - gaim_proxy_info_get_password(phb->gpi), - phb->write_buffer + 4); - phb->write_buffer[0] = 0x01; - phb->write_buffer[1] = 0x01; - phb->write_buffer[2] = 0x04; - phb->write_buffer[3] = 0x10; + gaim_proxy_info_get_password(connect_info->gpi), + connect_info->write_buffer + 4); + connect_info->write_buffer[0] = 0x01; + connect_info->write_buffer[1] = 0x01; + connect_info->write_buffer[2] = 0x04; + connect_info->write_buffer[3] = 0x10; - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->read_cb = s5_readchap; + connect_info->read_cb = s5_readchap; - phb->inpa = gaim_input_add(source, - GAIM_INPUT_WRITE, proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, + GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); break; case 0x11: /* Server wants to select an algorithm */ @@ -1954,11 +1970,11 @@ "of the socks5 CHAP specification. " "Disconnecting..."); close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } break; @@ -1973,113 +1989,113 @@ static void s5_canread(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; int len; - if (phb->read_buffer == NULL) { - phb->read_buf_len = 2; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 2; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } gaim_debug_info("socks5 proxy", "Able to read.\n"); - len = read(source, phb->read_buffer + phb->read_len, - phb->read_buf_len - phb->read_len); + len = read(source, connect_info->read_buffer + connect_info->read_len, + connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - phb->read_len += len; + connect_info->read_len += len; - if (phb->read_len < 2) + if (connect_info->read_len < 2) return; - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; - if ((phb->read_buffer[0] != 0x05) || (phb->read_buffer[1] == 0xff)) { + if ((connect_info->read_buffer[0] != 0x05) || (connect_info->read_buffer[1] == 0xff)) { close(source); - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - if (phb->read_buffer[1] == 0x02) { + if (connect_info->read_buffer[1] == 0x02) { gsize i, j; const char *u, *p; - u = gaim_proxy_info_get_username(phb->gpi); - p = gaim_proxy_info_get_password(phb->gpi); + u = gaim_proxy_info_get_username(connect_info->gpi); + p = gaim_proxy_info_get_password(connect_info->gpi); i = (u == NULL) ? 0 : strlen(u); j = (p == NULL) ? 0 : strlen(p); - phb->write_buf_len = 1 + 1 + i + 1 + j; - phb->write_buffer = g_malloc(phb->write_buf_len); - phb->written_len = 0; + connect_info->write_buf_len = 1 + 1 + i + 1 + j; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + connect_info->written_len = 0; - phb->write_buffer[0] = 0x01; /* version 1 */ - phb->write_buffer[1] = i; + connect_info->write_buffer[0] = 0x01; /* version 1 */ + connect_info->write_buffer[1] = i; if (u != NULL) - memcpy(phb->write_buffer + 2, u, i); - phb->write_buffer[2 + i] = j; + memcpy(connect_info->write_buffer + 2, u, i); + connect_info->write_buffer[2 + i] = j; if (p != NULL) - memcpy(phb->write_buffer + 2 + i + 1, p, j); + memcpy(connect_info->write_buffer + 2 + i + 1, p, j); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->read_cb = s5_readauth; + connect_info->read_cb = s5_readauth; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, - proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + proxy_do_write, connect_info); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); return; - } else if (phb->read_buffer[1] == 0x03) { + } else if (connect_info->read_buffer[1] == 0x03) { gsize userlen; - userlen = strlen(gaim_proxy_info_get_username(phb->gpi)); + userlen = strlen(gaim_proxy_info_get_username(connect_info->gpi)); - phb->write_buf_len = 7 + userlen; - phb->write_buffer = g_malloc(phb->write_buf_len); - phb->written_len = 0; + connect_info->write_buf_len = 7 + userlen; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + connect_info->written_len = 0; - phb->write_buffer[0] = 0x01; - phb->write_buffer[1] = 0x02; - phb->write_buffer[2] = 0x11; - phb->write_buffer[3] = 0x01; - phb->write_buffer[4] = 0x85; - phb->write_buffer[5] = 0x02; - phb->write_buffer[6] = userlen; - memcpy(phb->write_buffer + 7, - gaim_proxy_info_get_username(phb->gpi), userlen); + connect_info->write_buffer[0] = 0x01; + connect_info->write_buffer[1] = 0x02; + connect_info->write_buffer[2] = 0x11; + connect_info->write_buffer[3] = 0x01; + connect_info->write_buffer[4] = 0x85; + connect_info->write_buffer[5] = 0x02; + connect_info->write_buffer[6] = userlen; + memcpy(connect_info->write_buffer + 7, + gaim_proxy_info_get_username(connect_info->gpi), userlen); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->read_cb = s5_readchap; + connect_info->read_cb = s5_readchap; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, - proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + proxy_do_write, connect_info); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); return; } else { - g_free(phb->read_buffer); - phb->read_buffer = NULL; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - s5_sendconnect(phb, source); + s5_sendconnect(connect_info, source); } } @@ -2088,30 +2104,30 @@ { unsigned char buf[5]; int i; - struct _GaimProxyConnectInfo *phb = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("socks5 proxy", "Connected.\n"); - if (phb->inpa > 0) + if (connect_info->inpa > 0) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; } len = sizeof(error); if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { close(source); - try_connect(phb); + try_connect(connect_info); return; } i = 0; buf[0] = 0x05; /* SOCKS version 5 */ - if (gaim_proxy_info_get_username(phb->gpi) != NULL) { + if (gaim_proxy_info_get_username(connect_info->gpi) != NULL) { buf[1] = 0x03; /* three methods */ buf[2] = 0x00; /* no authentication */ buf[3] = 0x03; /* CHAP authentication */ @@ -2124,26 +2140,26 @@ i = 3; } - phb->write_buf_len = i; - phb->write_buffer = g_malloc(phb->write_buf_len); - memcpy(phb->write_buffer, buf, i); + connect_info->write_buf_len = i; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + memcpy(connect_info->write_buffer, buf, i); - phb->read_cb = s5_canread; + connect_info->read_cb = s5_canread; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, phb); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); } static int -proxy_connect_socks5(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks5(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; gaim_debug_info("socks5 proxy", "Connecting to %s:%d via %s:%d using SOCKS5\n", - phb->host, phb->port, - gaim_proxy_info_get_host(phb->gpi), - gaim_proxy_info_get_port(phb->gpi)); + connect_info->host, connect_info->port, + gaim_proxy_info_get_host(connect_info->gpi), + gaim_proxy_info_get_port(connect_info->gpi)); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) return -1; @@ -2153,12 +2169,13 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) < 0) { + if (connect(fd, addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("socks5 proxy", "Connect would have blocked.\n"); - phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s5_canwrite, phb); + connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s5_canwrite, connect_info); } else { close(fd); @@ -2169,53 +2186,60 @@ socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("socks5 proxy", - "Connect didn't block.\n"); + gaim_debug_misc("socks5 proxy", "Connect didn't block.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { close(fd); return -1; } - s5_canwrite(phb, fd, GAIM_INPUT_WRITE); + s5_canwrite(connect_info, fd, GAIM_INPUT_WRITE); } return fd; } -static void try_connect(struct _GaimProxyConnectInfo *phb) +static void try_connect(GaimProxyConnectInfo *connect_info) { size_t addrlen; struct sockaddr *addr; int ret = -1; - while (phb->hosts) { - addrlen = GPOINTER_TO_INT(phb->hosts->data); - phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); - addr = phb->hosts->data; - phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + if (connect_info->hosts == NULL) + { + gaim_proxy_connect_info_error(connect_info, _("Could not resolve host name")); + return; + } - switch (gaim_proxy_info_get_type(phb->gpi)) { + while (connect_info->hosts) + { + addrlen = GPOINTER_TO_INT(connect_info->hosts->data); + connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); + addr = connect_info->hosts->data; + connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); + + switch (gaim_proxy_info_get_type(connect_info->gpi)) { case GAIM_PROXY_NONE: - ret = proxy_connect_none(phb, addr, addrlen); + ret = proxy_connect_none(connect_info, addr, addrlen); break; case GAIM_PROXY_HTTP: - ret = proxy_connect_http(phb, addr, addrlen); + ret = proxy_connect_http(connect_info, addr, addrlen); break; case GAIM_PROXY_SOCKS4: - ret = proxy_connect_socks4(phb, addr, addrlen); + ret = proxy_connect_socks4(connect_info, addr, addrlen); break; case GAIM_PROXY_SOCKS5: - ret = proxy_connect_socks5(phb, addr, addrlen); + ret = proxy_connect_socks5(connect_info, addr, addrlen); break; case GAIM_PROXY_USE_ENVVAR: - ret = proxy_connect_http(phb, addr, addrlen); + ret = proxy_connect_http(connect_info, addr, addrlen); break; default: @@ -2224,12 +2248,12 @@ g_free(addr); - if (ret > 0) + if (ret >= 0) break; } if (ret < 0) { - gaim_proxy_phb_error(phb, _("TODO")); + gaim_proxy_connect_info_error(connect_info, _("Unable to establish a connection")); } } @@ -2237,11 +2261,18 @@ connection_host_resolved(GSList *hosts, gpointer data, const char *error_message) { - struct _GaimProxyConnectInfo *phb = (struct _GaimProxyConnectInfo*)data; + GaimProxyConnectInfo *connect_info; - phb->hosts = hosts; + if (error_message != NULL) + { + gaim_debug_info("proxy", "Error while resolving hostname: %s\n", error_message); + /* TODO: Destroy connect_info and return? */ + } - try_connect(phb); + connect_info = data; + connect_info->hosts = hosts; + + try_connect(connect_info); } GaimProxyInfo * @@ -2317,31 +2348,31 @@ { const char *connecthost = host; int connectport = port; - struct _GaimProxyConnectInfo *phb; + 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! */ - phb = g_new0(struct _GaimProxyConnectInfo, 1); - phb->connect_cb = connect_cb; - phb->error_cb = error_cb; - phb->data = data; - phb->host = g_strdup(host); - phb->port = port; - phb->gpi = gaim_proxy_get_setup(account); + connect_info = g_new0(GaimProxyConnectInfo, 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; + connect_info->gpi = gaim_proxy_get_setup(account); - if ((gaim_proxy_info_get_type(phb->gpi) != GAIM_PROXY_NONE) && - (gaim_proxy_info_get_host(phb->gpi) == NULL || - gaim_proxy_info_get_port(phb->gpi) <= 0)) { + if ((gaim_proxy_info_get_type(connect_info->gpi) != GAIM_PROXY_NONE) && + (gaim_proxy_info_get_host(connect_info->gpi) == NULL || + gaim_proxy_info_get_port(connect_info->gpi) <= 0)) { gaim_notify_error(NULL, NULL, _("Invalid proxy settings"), _("Either the host name or port number specified for your given proxy type is invalid.")); - gaim_proxy_phb_destroy(phb); + gaim_proxy_connect_info_destroy(connect_info); return NULL; } - switch (gaim_proxy_info_get_type(phb->gpi)) + switch (gaim_proxy_info_get_type(connect_info->gpi)) { case GAIM_PROXY_NONE: break; @@ -2350,25 +2381,25 @@ case GAIM_PROXY_SOCKS4: case GAIM_PROXY_SOCKS5: case GAIM_PROXY_USE_ENVVAR: - connecthost = gaim_proxy_info_get_host(phb->gpi); - connectport = gaim_proxy_info_get_port(phb->gpi); + connecthost = gaim_proxy_info_get_host(connect_info->gpi); + connectport = gaim_proxy_info_get_port(connect_info->gpi); break; default: - gaim_proxy_phb_destroy(phb); + gaim_proxy_connect_info_destroy(connect_info); return NULL; } if (gaim_gethostbyname_async(connecthost, - connectport, connection_host_resolved, phb) != 0) + connectport, connection_host_resolved, connect_info) != 0) { - gaim_proxy_phb_destroy(phb); + gaim_proxy_connect_info_destroy(connect_info); return NULL; } - phbs = g_slist_prepend(phbs, phb); + connect_infos = g_slist_prepend(connect_infos, connect_info); - return phb; + return connect_info; } /* @@ -2379,31 +2410,31 @@ GaimProxyConnectFunction connect_cb, GaimProxyErrorFunction error_cb, gpointer data) { - struct _GaimProxyConnectInfo *phb; + 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! */ - phb = g_new0(struct _GaimProxyConnectInfo, 1); - phb->connect_cb = connect_cb; - phb->error_cb = error_cb; - phb->data = data; - phb->host = g_strdup(host); - phb->port = port; - phb->gpi = gpi; + connect_info = g_new0(GaimProxyConnectInfo, 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; + connect_info->gpi = gpi; if (gaim_gethostbyname_async(gaim_proxy_info_get_host(gpi), - gaim_proxy_info_get_port(gpi), connection_host_resolved, phb) != 0) + gaim_proxy_info_get_port(gpi), connection_host_resolved, connect_info) != 0) { - gaim_proxy_phb_destroy(phb); + gaim_proxy_connect_info_destroy(connect_info); return NULL; } - phbs = g_slist_prepend(phbs, phb); + connect_infos = g_slist_prepend(connect_infos, connect_info); - return phb; + return connect_info; } @@ -2486,6 +2517,6 @@ void gaim_proxy_uninit(void) { - while (phbs != NULL) - gaim_proxy_phb_destroy(phbs->data); + while (connect_infos != NULL) + gaim_proxy_connect_info_destroy(connect_infos->data); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 22:16:26
|
Revision: 16728 Author: thekingant Date: 2006-08-12 15:16:23 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16728&view=rev Log Message: ----------- Extremely minor error message improvements Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-12 21:13:25 UTC (rev 16727) +++ trunk/src/proxy.c 2006-08-12 22:16:23 UTC (rev 16728) @@ -297,6 +297,10 @@ * failed. This will be passed to the callback function * specified in the call to gaim_proxy_connect(). */ +/* + * TODO: Make sure all callers of this function pass a really really + * good error_message. + */ static void gaim_proxy_connect_info_error(GaimProxyConnectInfo *connect_info, const gchar *error_message) { @@ -1066,7 +1070,8 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, (struct sockaddr *)addr, addrlen) < 0) { + if (connect(fd, (struct sockaddr *)addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { /* This just confuses people. */ /* gaim_debug_warning("proxy", @@ -1085,7 +1090,8 @@ int error = ETIMEDOUT; gaim_debug_misc("proxy", "Connect didn't block.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { gaim_debug_error("proxy", "getsockopt failed.\n"); close(fd); return -1; @@ -1455,7 +1461,8 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) < 0) { + if (connect(fd, addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("http proxy", "Connect would have blocked.\n"); @@ -1481,7 +1488,8 @@ "Connect didn't block.\n"); len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { close(fd); return -1; } @@ -1612,7 +1620,8 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) < 0) { + if (connect(fd, addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("socks4 proxy", "Connect would have blocked.\n"); @@ -1631,7 +1640,8 @@ len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { close(fd); return -1; } @@ -2159,7 +2169,8 @@ fcntl(fd, F_SETFD, FD_CLOEXEC); #endif - if (connect(fd, addr, addrlen) < 0) { + if (connect(fd, addr, addrlen) != 0) + { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("socks5 proxy", "Connect would have blocked.\n"); @@ -2179,7 +2190,8 @@ len = sizeof(error); - if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) != 0) + { close(fd); return -1; } @@ -2196,7 +2208,14 @@ struct sockaddr *addr; int ret = -1; - while (connect_info->hosts) { + if (connect_info->hosts == NULL) + { + gaim_proxy_connect_info_error(connect_info, _("Could not resolve host name")); + return; + } + + while (connect_info->hosts) + { addrlen = GPOINTER_TO_INT(connect_info->hosts->data); connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); addr = connect_info->hosts->data; @@ -2229,12 +2248,12 @@ g_free(addr); - if (ret > 0) + if (ret >= 0) break; } if (ret < 0) { - gaim_proxy_connect_info_error(connect_info, _("TODO")); + gaim_proxy_connect_info_error(connect_info, _("Unable to establish a connection")); } } @@ -2244,6 +2263,12 @@ { GaimProxyConnectInfo *connect_info; + if (error_message != NULL) + { + gaim_debug_info("proxy", "Error while resolving hostname: %s\n", error_message); + /* TODO: Destroy connect_info and return? */ + } + connect_info = data; connect_info->hosts = hosts; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 21:13:27
|
Revision: 16727 Author: thekingant Date: 2006-08-12 14:13:25 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16727&view=rev Log Message: ----------- I decided that it's probably not a good idea to enable_fatal_asserts when --enable-debug is passed to autogen.sh/configure. However, EVERY Gaim dev, summer of code student and crazy patch writer should pass "--enable-fatal-asserts" to Gaim's autogen.sh/configure (It causes Gaim to segfault when g_return_val_if_fail() fails) Modified Paths: -------------- trunk/configure.ac Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2006-08-12 21:07:34 UTC (rev 16726) +++ trunk/configure.ac 2006-08-12 21:13:25 UTC (rev 16727) @@ -546,7 +546,6 @@ if test "x$enable_debug" = "xyes" ; then AC_DEFINE(DEBUG, 1, [Define if debugging is enabled.]) - enable_fatal_asserts="yes" fi if test "x$enable_fatal_asserts" = "xyes" ; then @@ -1822,9 +1821,10 @@ echo echo Use XScreenSaver Extension.... : $enable_xss echo Use X Session Management...... : $enable_sm -echo Use startup notification.......: $enable_startup_notification +echo Use startup notification...... : $enable_startup_notification echo echo Print debugging messages...... : $enable_debug +echo Assertions are fatal.......... : $enable_fatal_asserts echo eval eval echo Gaim will be installed in $bindir. if test "x$gaimpath" != "x" ; then This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 21:07:36
|
Revision: 16726 Author: thekingant Date: 2006-08-12 14:07:34 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16726&view=rev Log Message: ----------- Use the GaimProxyConnectInfo typedef instead of struct _GaimProxyConnectInfo. Sorry, I should have done this in one of my other commits Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-12 20:40:07 UTC (rev 16725) +++ trunk/src/proxy.c 2006-08-12 21:07:34 UTC (rev 16726) @@ -46,7 +46,13 @@ int port; guint inpa; GaimProxyInfo *gpi; + + /** + * This contains alternating length/char* values. The char* + * values need to be freed when removed from the linked list. + */ GSList *hosts; + guchar *write_buffer; gsize write_buf_len; gsize written_len; @@ -71,7 +77,7 @@ static GaimProxyInfo *global_proxy_info = NULL; static GSList *connect_infos = NULL; -static void try_connect(struct _GaimProxyConnectInfo *); +static void try_connect(GaimProxyConnectInfo *); /************************************************************************** * Proxy structure API @@ -257,7 +263,7 @@ **************************************************************************/ static void -gaim_proxy_connect_info_destroy(struct _GaimProxyConnectInfo *connect_info) +gaim_proxy_connect_info_destroy(GaimProxyConnectInfo *connect_info) { connect_infos = g_slist_remove(connect_infos, connect_info); @@ -280,7 +286,7 @@ } static void -gaim_proxy_connect_info_connected(struct _GaimProxyConnectInfo *connect_info, int fd) +gaim_proxy_connect_info_connected(GaimProxyConnectInfo *connect_info, int fd) { connect_info->connect_cb(connect_info->data, fd); gaim_proxy_connect_info_destroy(connect_info); @@ -292,7 +298,7 @@ * specified in the call to gaim_proxy_connect(). */ static void -gaim_proxy_connect_info_error(struct _GaimProxyConnectInfo *connect_info, const gchar *error_message) +gaim_proxy_connect_info_error(GaimProxyConnectInfo *connect_info, const gchar *error_message) { if (connect_info->error_cb == NULL) { @@ -990,7 +996,7 @@ static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error=0, ret; @@ -1034,7 +1040,7 @@ static gboolean clean_connect(gpointer data) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; gaim_proxy_connect_info_connected(connect_info, connect_info->port); @@ -1043,7 +1049,7 @@ static int -proxy_connect_none(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_none(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1097,7 +1103,7 @@ static void proxy_do_write(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; const guchar *request = connect_info->write_buffer + connect_info->written_len; gsize request_len = connect_info->write_buf_len - connect_info->written_len; @@ -1135,7 +1141,7 @@ { int len, headers_len, status = 0; gboolean error; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; guchar *p; gsize max_read; gchar *msg; @@ -1367,7 +1373,7 @@ { char request[8192]; int request_len = 0; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; @@ -1430,7 +1436,7 @@ } static int -proxy_connect_http(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_http(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1489,7 +1495,7 @@ static void s4_canread(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; guchar *buf; int len, max_read; @@ -1531,7 +1537,7 @@ { unsigned char packet[9]; struct hostent *hp; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; @@ -1588,7 +1594,7 @@ } static int -proxy_connect_socks4(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks4(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -1640,7 +1646,7 @@ s5_canread_again(gpointer data, gint source, GaimInputCondition cond) { guchar *dest, *buf; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int len; if (connect_info->read_buffer == NULL) { @@ -1722,7 +1728,7 @@ static void s5_sendconnect(gpointer data, int source) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int hlen = strlen(connect_info->host); connect_info->write_buf_len = 5 + hlen + 2; connect_info->write_buffer = g_malloc(connect_info->write_buf_len); @@ -1746,7 +1752,7 @@ static void s5_readauth(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int len; if (connect_info->read_buffer == NULL) { @@ -1792,7 +1798,8 @@ s5_sendconnect(connect_info, source); } -static void hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response) +static void +hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response) { GaimCipher *cipher; GaimCipherContext *ctx; @@ -1839,7 +1846,7 @@ s5_readchap(gpointer data, gint source, GaimInputCondition cond) { guchar *cmdbuf, *buf; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int len, navas, currentav; gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Got CHAP response.\n"); @@ -1972,7 +1979,7 @@ static void s5_canread(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; int len; if (connect_info->read_buffer == NULL) { @@ -2087,7 +2094,7 @@ { unsigned char buf[5]; int i; - struct _GaimProxyConnectInfo *connect_info = data; + GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; @@ -2134,7 +2141,7 @@ } static int -proxy_connect_socks5(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks5(GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; @@ -2168,8 +2175,7 @@ socklen_t len; int error = ETIMEDOUT; - gaim_debug_misc("socks5 proxy", - "Connect didn't block.\n"); + gaim_debug_misc("socks5 proxy", "Connect didn't block.\n"); len = sizeof(error); @@ -2184,7 +2190,7 @@ return fd; } -static void try_connect(struct _GaimProxyConnectInfo *connect_info) +static void try_connect(GaimProxyConnectInfo *connect_info) { size_t addrlen; struct sockaddr *addr; @@ -2236,8 +2242,9 @@ connection_host_resolved(GSList *hosts, gpointer data, const char *error_message) { - struct _GaimProxyConnectInfo *connect_info = (struct _GaimProxyConnectInfo*)data; + GaimProxyConnectInfo *connect_info; + connect_info = data; connect_info->hosts = hosts; try_connect(connect_info); @@ -2316,14 +2323,14 @@ { const char *connecthost = host; int connectport = port; - struct _GaimProxyConnectInfo *connect_info; + 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(struct _GaimProxyConnectInfo, 1); + connect_info = g_new0(GaimProxyConnectInfo, 1); connect_info->connect_cb = connect_cb; connect_info->error_cb = error_cb; connect_info->data = data; @@ -2378,14 +2385,14 @@ GaimProxyConnectFunction connect_cb, GaimProxyErrorFunction error_cb, gpointer data) { - struct _GaimProxyConnectInfo *connect_info; + 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(struct _GaimProxyConnectInfo, 1); + connect_info = g_new0(GaimProxyConnectInfo, 1); connect_info->connect_cb = connect_cb; connect_info->error_cb = error_cb; connect_info->data = data; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2006-08-12 20:40:13
|
Revision: 16725 Author: thekingant Date: 2006-08-12 13:40:07 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16725&view=rev Log Message: ----------- Rename "phb" to "connect_info" everywhere Modified Paths: -------------- trunk/plugins/ChangeLog.API trunk/src/proxy.c Modified: trunk/plugins/ChangeLog.API =================================================================== --- trunk/plugins/ChangeLog.API 2006-08-12 20:01:35 UTC (rev 16724) +++ trunk/plugins/ChangeLog.API 2006-08-12 20:40:07 UTC (rev 16725) @@ -114,6 +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_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: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-12 20:01:35 UTC (rev 16724) +++ trunk/src/proxy.c 2006-08-12 20:40:07 UTC (rev 16725) @@ -69,7 +69,7 @@ }; static GaimProxyInfo *global_proxy_info = NULL; -static GSList *phbs = NULL; +static GSList *connect_infos = NULL; static void try_connect(struct _GaimProxyConnectInfo *); @@ -257,33 +257,33 @@ **************************************************************************/ static void -gaim_proxy_phb_destroy(struct _GaimProxyConnectInfo *phb) +gaim_proxy_connect_info_destroy(struct _GaimProxyConnectInfo *connect_info) { - phbs = g_slist_remove(phbs, phb); + connect_infos = g_slist_remove(connect_infos, connect_info); - if (phb->inpa > 0) - gaim_input_remove(phb->inpa); + if (connect_info->inpa > 0) + gaim_input_remove(connect_info->inpa); - while (phb->hosts != NULL) + while (connect_info->hosts != NULL) { /* Discard the length... */ - phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); /* Free the address... */ - g_free(phb->hosts->data); - phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + g_free(connect_info->hosts->data); + connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); } - g_free(phb->host); - g_free(phb->write_buffer); - g_free(phb->read_buffer); - g_free(phb); + g_free(connect_info->host); + g_free(connect_info->write_buffer); + g_free(connect_info->read_buffer); + g_free(connect_info); } static void -gaim_proxy_phb_connected(struct _GaimProxyConnectInfo *phb, int fd) +gaim_proxy_connect_info_connected(struct _GaimProxyConnectInfo *connect_info, int fd) { - phb->connect_cb(phb->data, fd); - gaim_proxy_phb_destroy(phb); + connect_info->connect_cb(connect_info->data, fd); + gaim_proxy_connect_info_destroy(connect_info); } /** @@ -292,9 +292,9 @@ * specified in the call to gaim_proxy_connect(). */ static void -gaim_proxy_phb_error(struct _GaimProxyConnectInfo *phb, const gchar *error_message) +gaim_proxy_connect_info_error(struct _GaimProxyConnectInfo *connect_info, const gchar *error_message) { - if (phb->error_cb == NULL) + if (connect_info->error_cb == NULL) { /* * TODO @@ -304,13 +304,13 @@ * an fd of -1 in the case of an error. Once all callers have * been changed this whole if statement should be removed. */ - phb->connect_cb(phb->data, -1); - gaim_proxy_phb_destroy(phb); + connect_info->connect_cb(connect_info->data, -1); + gaim_proxy_connect_info_destroy(connect_info); return; } - phb->error_cb(phb->data, error_message); - gaim_proxy_phb_destroy(phb); + connect_info->error_cb(connect_info->data, error_message); + gaim_proxy_connect_info_destroy(connect_info); } #if defined(__unix__) || defined(__APPLE__) @@ -990,7 +990,7 @@ static void no_one_calls(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; socklen_t len; int error=0, ret; @@ -1016,39 +1016,39 @@ if (ret!=0) error = errno; close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; gaim_debug_error("proxy", "getsockopt SO_ERROR check: %s\n", strerror(error)); - try_connect(phb); + try_connect(connect_info); return; } - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; - gaim_proxy_phb_connected(phb, source); + gaim_proxy_connect_info_connected(connect_info, source); } static gboolean clean_connect(gpointer data) { - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; - gaim_proxy_phb_connected(phb, phb->port); + gaim_proxy_connect_info_connected(connect_info, connect_info->port); return FALSE; } static int -proxy_connect_none(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_none(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; gaim_debug_info("proxy", - "Connecting to %s:%d with no proxy\n", phb->host, phb->port); + "Connecting to %s:%d with no proxy\n", connect_info->host, connect_info->port); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { gaim_debug_error("proxy", @@ -1065,7 +1065,7 @@ /* This just confuses people. */ /* gaim_debug_warning("proxy", "Connect would have blocked.\n"); */ - phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, phb); + connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, no_one_calls, connect_info); } else { gaim_debug_error("proxy", @@ -1085,8 +1085,8 @@ return -1; } /* TODO: Why is the following line so strange? */ - phb->port = fd; /* bleh */ - gaim_timeout_add(10, clean_connect, phb); /* we do this because we never + connect_info->port = fd; /* bleh */ + gaim_timeout_add(10, clean_connect, connect_info); /* we do this because we never want to call our callback before we return. */ } @@ -1097,33 +1097,33 @@ static void proxy_do_write(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; - const guchar *request = phb->write_buffer + phb->written_len; - gsize request_len = phb->write_buf_len - phb->written_len; + struct _GaimProxyConnectInfo *connect_info = data; + const guchar *request = connect_info->write_buffer + connect_info->written_len; + gsize request_len = connect_info->write_buf_len - connect_info->written_len; int ret = write(source, request, request_len); if(ret < 0 && errno == EAGAIN) return; else if(ret < 0) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; close(source); - g_free(phb->write_buffer); - phb->write_buffer = NULL; - try_connect(phb); + g_free(connect_info->write_buffer); + connect_info->write_buffer = NULL; + try_connect(connect_info); return; } else if (ret < request_len) { - phb->written_len += ret; + connect_info->written_len += ret; return; } - gaim_input_remove(phb->inpa); - g_free(phb->write_buffer); - phb->write_buffer = NULL; + gaim_input_remove(connect_info->inpa); + g_free(connect_info->write_buffer); + connect_info->write_buffer = NULL; /* register the response handler for the response */ - phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, phb->read_cb, phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_READ, connect_info->read_cb, connect_info); } #define HTTP_GOODSTRING "HTTP/1.0 200" @@ -1135,45 +1135,45 @@ { int len, headers_len, status = 0; gboolean error; - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; guchar *p; gsize max_read; gchar *msg; - if(phb->read_buffer == NULL) { - phb->read_buf_len = 8192; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if(connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 8192; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } - p = phb->read_buffer + phb->read_len; - max_read = phb->read_buf_len - phb->read_len - 1; + p = connect_info->read_buffer + connect_info->read_len; + max_read = connect_info->read_buf_len - connect_info->read_len - 1; len = read(source, p, max_read); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { close(source); - gaim_proxy_phb_error(phb, _("Lost connection with server for an unknown reason.")); + gaim_proxy_connect_info_error(connect_info, _("Lost connection with server for an unknown reason.")); return; } else { - phb->read_len += len; + connect_info->read_len += len; } p[len] = '\0'; - if((p = (guchar *)g_strstr_len((const gchar *)phb->read_buffer, phb->read_len, "\r\n\r\n"))) { + if((p = (guchar *)g_strstr_len((const gchar *)connect_info->read_buffer, connect_info->read_len, "\r\n\r\n"))) { *p = '\0'; - headers_len = (p - phb->read_buffer) + 4; + headers_len = (p - connect_info->read_buffer) + 4; } else if(len == max_read) headers_len = len; else return; - error = strncmp((const char *)phb->read_buffer, "HTTP/", 5) != 0; + error = strncmp((const char *)connect_info->read_buffer, "HTTP/", 5) != 0; if (!error) { int major; - p = phb->read_buffer + 5; + p = connect_info->read_buffer + 5; major = strtol((const char *)p, (char **)&p, 10); error = (major == 0) || (*p != '.'); if(!error) { @@ -1190,7 +1190,7 @@ } /* Read the contents */ - p = (guchar *)g_strrstr((const gchar *)phb->read_buffer, "Content-Length: "); + p = (guchar *)g_strrstr((const gchar *)connect_info->read_buffer, "Content-Length: "); if (p != NULL) { gchar *tmp; @@ -1205,7 +1205,7 @@ *tmp = '\r'; /* Compensate for what has already been read */ - len -= phb->read_len - headers_len; + len -= connect_info->read_len - headers_len; /* I'm assuming that we're doing this to prevent the server from complaining / breaking since we don't read the whole page */ while(len--) { @@ -1219,8 +1219,8 @@ { close(source); msg = g_strdup_printf("Unable to parse response from HTTP proxy: %s\n", - phb->read_buffer); - gaim_proxy_phb_error(phb, msg); + connect_info->read_buffer); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); return; } @@ -1228,15 +1228,15 @@ { gaim_debug_error("proxy", "Proxy server replied with:\n%s\n", - phb->read_buffer); + connect_info->read_buffer); if(status == 407 /* Proxy Auth */) { gchar *ntlm; - if((ntlm = g_strrstr((const gchar *)phb->read_buffer, "Proxy-Authenticate: NTLM "))) { /* Check for Type-2 */ + if((ntlm = g_strrstr((const gchar *)connect_info->read_buffer, "Proxy-Authenticate: NTLM "))) { /* Check for Type-2 */ gchar *tmp = ntlm; guint8 *nonce; - gchar *domain = (gchar*)gaim_proxy_info_get_username(phb->gpi); + gchar *domain = (gchar*)gaim_proxy_info_get_username(connect_info->gpi); gchar *username; gchar *request; gchar *response; @@ -1245,7 +1245,7 @@ { close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_phb_error(phb, msg); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); return; } @@ -1256,8 +1256,8 @@ *tmp = '\0'; nonce = gaim_ntlm_parse_type2(ntlm, NULL); response = gaim_ntlm_gen_type3(username, - (gchar*) gaim_proxy_info_get_password(phb->gpi), - (gchar*) gaim_proxy_info_get_host(phb->gpi), + (gchar*) gaim_proxy_info_get_password(connect_info->gpi), + (gchar*) gaim_proxy_info_get_host(connect_info->gpi), domain, nonce, NULL); username--; *username = '\\'; @@ -1266,28 +1266,28 @@ "Host: %s:%d\r\n" "Proxy-Authorization: NTLM %s\r\n" "Proxy-Connection: Keep-Alive\r\n\r\n", - phb->host, phb->port, phb->host, - phb->port, response); + connect_info->host, connect_info->port, connect_info->host, + connect_info->port, response); g_free(response); - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->write_buffer = (guchar *)request; - phb->write_buf_len = strlen(request); - phb->written_len = 0; + connect_info->write_buffer = (guchar *)request; + connect_info->write_buf_len = strlen(request); + connect_info->written_len = 0; - phb->read_cb = http_canread; + connect_info->read_cb = http_canread; - phb->inpa = gaim_input_add(source, - GAIM_INPUT_WRITE, proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, + GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(phb, source, cond); + proxy_do_write(connect_info, source, cond); return; - } else if((ntlm = g_strrstr((const char *)phb->read_buffer, "Proxy-Authenticate: NTLM"))) { /* Empty message */ + } else if((ntlm = g_strrstr((const char *)connect_info->read_buffer, "Proxy-Authenticate: NTLM"))) { /* Empty message */ gchar request[2048]; - gchar *domain = (gchar*) gaim_proxy_info_get_username(phb->gpi); + gchar *domain = (gchar*) gaim_proxy_info_get_username(connect_info->gpi); gchar *username; int request_len; username = strchr(domain, '\\'); @@ -1295,7 +1295,7 @@ { close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_phb_error(phb, msg); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); return; } @@ -1304,8 +1304,8 @@ request_len = g_snprintf(request, sizeof(request), "CONNECT %s:%d HTTP/1.1\r\n" "Host: %s:%d\r\n", - phb->host, phb->port, - phb->host, phb->port); + connect_info->host, connect_info->port, + connect_info->host, connect_info->port); g_return_if_fail(request_len < sizeof(request)); request_len += g_snprintf(request + request_len, @@ -1313,49 +1313,49 @@ "Proxy-Authorization: NTLM %s\r\n" "Proxy-Connection: Keep-Alive\r\n\r\n", gaim_ntlm_gen_type1( - (gchar*) gaim_proxy_info_get_host(phb->gpi), + (gchar*) gaim_proxy_info_get_host(connect_info->gpi), domain)); *username = '\\'; - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->write_buffer = g_memdup(request, request_len); - phb->write_buf_len = request_len; - phb->written_len = 0; + connect_info->write_buffer = g_memdup(request, request_len); + connect_info->write_buf_len = request_len; + connect_info->written_len = 0; - phb->read_cb = http_canread; + connect_info->read_cb = http_canread; - phb->inpa = gaim_input_add(source, - GAIM_INPUT_WRITE, proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, + GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(phb, source, cond); + proxy_do_write(connect_info, source, cond); return; } else { close(source); msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_phb_error(phb, msg); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); return; } } if(status == 403 /* Forbidden */ ) { - msg = g_strdup_printf(_("Access denied: HTTP proxy server forbids port %d tunnelling."), phb->port); - gaim_proxy_phb_error(phb, msg); + msg = g_strdup_printf(_("Access denied: HTTP proxy server forbids port %d tunnelling."), connect_info->port); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); } else { msg = g_strdup_printf(_("HTTP proxy connection error %d"), status); - gaim_proxy_phb_error(phb, msg); + gaim_proxy_connect_info_error(connect_info, msg); g_free(msg); } } else { - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_phb_connected(phb, source); + gaim_proxy_connect_info_connected(connect_info, source); return; } } @@ -1367,16 +1367,16 @@ { char request[8192]; int request_len = 0; - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("http proxy", "Connected.\n"); - if (phb->inpa > 0) + if (connect_info->inpa > 0) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; } len = sizeof(error); @@ -1384,22 +1384,22 @@ if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { close(source); - try_connect(phb); + try_connect(connect_info); return; } gaim_debug_info("proxy", "using CONNECT tunnelling for %s:%d\n", - phb->host, phb->port); + connect_info->host, connect_info->port); request_len = g_snprintf(request, sizeof(request), "CONNECT %s:%d HTTP/1.1\r\nHost: %s:%d\r\n", - phb->host, phb->port, phb->host, phb->port); + connect_info->host, connect_info->port, connect_info->host, connect_info->port); - if (gaim_proxy_info_get_username(phb->gpi) != NULL) { + if (gaim_proxy_info_get_username(connect_info->gpi) != NULL) { char *t1, *t2; t1 = g_strdup_printf("%s:%s", - gaim_proxy_info_get_username(phb->gpi), - gaim_proxy_info_get_password(phb->gpi) ? - gaim_proxy_info_get_password(phb->gpi) : ""); + gaim_proxy_info_get_username(connect_info->gpi), + gaim_proxy_info_get_password(connect_info->gpi) ? + gaim_proxy_info_get_password(connect_info->gpi) : ""); t2 = gaim_base64_encode((const guchar *)t1, strlen(t1)); g_free(t1); g_return_if_fail(request_len < sizeof(request)); @@ -1410,35 +1410,35 @@ "Proxy-Authorization: NTLM %s\r\n" "Proxy-Connection: Keep-Alive\r\n", t2, gaim_ntlm_gen_type1( - (gchar*)gaim_proxy_info_get_host(phb->gpi),"")); + (gchar*)gaim_proxy_info_get_host(connect_info->gpi),"")); g_free(t2); } g_return_if_fail(request_len < sizeof(request)); strcpy(request + request_len, "\r\n"); request_len += 2; - phb->write_buffer = g_memdup(request, request_len); - phb->write_buf_len = request_len; - phb->written_len = 0; + connect_info->write_buffer = g_memdup(request, request_len); + connect_info->write_buf_len = request_len; + connect_info->written_len = 0; - phb->read_cb = http_canread; + connect_info->read_cb = http_canread; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, - phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, + connect_info); - proxy_do_write(phb, source, cond); + proxy_do_write(connect_info, source, cond); } static int -proxy_connect_http(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_http(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; gaim_debug_info("http proxy", "Connecting to %s:%d via %s:%d using HTTP\n", - (phb->host ? phb->host : "(null)"), phb->port, - (gaim_proxy_info_get_host(phb->gpi) ? gaim_proxy_info_get_host(phb->gpi) : "(null)"), - gaim_proxy_info_get_port(phb->gpi)); + (connect_info->host ? connect_info->host : "(null)"), connect_info->port, + (gaim_proxy_info_get_host(connect_info->gpi) ? gaim_proxy_info_get_host(connect_info->gpi) : "(null)"), + gaim_proxy_info_get_port(connect_info->gpi)); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) { return -1; @@ -1454,13 +1454,13 @@ gaim_debug_warning("http proxy", "Connect would have blocked.\n"); - if (phb->port != 80) { + if (connect_info->port != 80) { /* we need to do CONNECT first */ - phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, - http_canwrite, phb); + connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, + http_canwrite, connect_info); } else { gaim_debug_info("proxy", "HTTP proxy connection established\n"); - gaim_proxy_phb_connected(phb, fd); + gaim_proxy_connect_info_connected(connect_info, fd); } } else { close(fd); @@ -1479,7 +1479,7 @@ close(fd); return -1; } - http_canwrite(phb, fd, GAIM_INPUT_WRITE); + http_canwrite(connect_info, fd, GAIM_INPUT_WRITE); } return fd; @@ -1489,41 +1489,41 @@ static void s4_canread(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; guchar *buf; int len, max_read; /* This is really not going to block under normal circumstances, but to * be correct, we deal with the unlikely scenario */ - if (phb->read_buffer == NULL) { - phb->read_buf_len = 12; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 12; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } - buf = phb->read_buffer + phb->read_len; - max_read = phb->read_buf_len - phb->read_len; + buf = connect_info->read_buffer + connect_info->read_len; + max_read = connect_info->read_buf_len - connect_info->read_len; len = read(source, buf, max_read); - if ((len < 0 && errno == EAGAIN) || (len > 0 && len + phb->read_len < 4)) + if ((len < 0 && errno == EAGAIN) || (len > 0 && len + connect_info->read_len < 4)) return; - else if (len + phb->read_len >= 4) { - if (phb->read_buffer[1] == 90) { - gaim_proxy_phb_connected(phb, source); + else if (len + connect_info->read_len >= 4) { + if (connect_info->read_buffer[1] == 90) { + gaim_proxy_connect_info_connected(connect_info, source); return; } } - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; close(source); - try_connect(phb); + try_connect(connect_info); } static void @@ -1531,16 +1531,16 @@ { unsigned char packet[9]; struct hostent *hp; - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("socks4 proxy", "Connected.\n"); - if (phb->inpa > 0) + if (connect_info->inpa > 0) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; } len = sizeof(error); @@ -1548,7 +1548,7 @@ if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { close(source); - try_connect(phb); + try_connect(connect_info); return; } @@ -1560,43 +1560,43 @@ * with an option, or some detection mechanism - in the * meantime, stick with plain old SOCKS4. */ - if (!(hp = gethostbyname(phb->host))) { + if (!(hp = gethostbyname(connect_info->host))) { close(source); - try_connect(phb); + try_connect(connect_info); return; } packet[0] = 4; packet[1] = 1; - packet[2] = phb->port >> 8; - packet[3] = phb->port & 0xff; + packet[2] = connect_info->port >> 8; + packet[3] = connect_info->port & 0xff; packet[4] = (unsigned char)(hp->h_addr_list[0])[0]; packet[5] = (unsigned char)(hp->h_addr_list[0])[1]; packet[6] = (unsigned char)(hp->h_addr_list[0])[2]; packet[7] = (unsigned char)(hp->h_addr_list[0])[3]; packet[8] = 0; - phb->write_buffer = g_memdup(packet, sizeof(packet)); - phb->write_buf_len = sizeof(packet); - phb->written_len = 0; - phb->read_cb = s4_canread; + connect_info->write_buffer = g_memdup(packet, sizeof(packet)); + connect_info->write_buf_len = sizeof(packet); + connect_info->written_len = 0; + connect_info->read_cb = s4_canread; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(phb, source, cond); + proxy_do_write(connect_info, source, cond); } static int -proxy_connect_socks4(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks4(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; gaim_debug_info("socks4 proxy", "Connecting to %s:%d via %s:%d using SOCKS4\n", - phb->host, phb->port, - gaim_proxy_info_get_host(phb->gpi), - gaim_proxy_info_get_port(phb->gpi)); + connect_info->host, connect_info->port, + gaim_proxy_info_get_host(connect_info->gpi), + gaim_proxy_info_get_port(connect_info->gpi)); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) return -1; @@ -1610,7 +1610,7 @@ if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug_warning("socks4 proxy", "Connect would have blocked.\n"); - phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s4_canwrite, phb); + connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s4_canwrite, connect_info); } else { close(fd); @@ -1630,7 +1630,7 @@ return -1; } - s4_canwrite(phb, fd, GAIM_INPUT_WRITE); + s4_canwrite(connect_info, fd, GAIM_INPUT_WRITE); } return fd; @@ -1640,36 +1640,36 @@ s5_canread_again(gpointer data, gint source, GaimInputCondition cond) { guchar *dest, *buf; - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; int len; - if (phb->read_buffer == NULL) { - phb->read_buf_len = 512; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 512; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } - dest = phb->read_buffer + phb->read_len; - buf = phb->read_buffer; + dest = connect_info->read_buffer + connect_info->read_len; + buf = connect_info->read_buffer; gaim_debug_info("socks5 proxy", "Able to read again.\n"); - len = read(source, dest, (phb->read_buf_len - phb->read_len)); + len = read(source, dest, (connect_info->read_buf_len - connect_info->read_len)); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { gaim_debug_warning("socks5 proxy", "or not...\n"); close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - phb->read_len += len; + connect_info->read_len += len; - if(phb->read_len < 4) + if(connect_info->read_len < 4) return; if ((buf[0] != 0x05) || (buf[1] != 0x00)) { @@ -1678,118 +1678,118 @@ else gaim_debug_error("socks5 proxy", "Bad data.\n"); close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } /* Skip past BND.ADDR */ switch(buf[3]) { case 0x01: /* the address is a version-4 IP address, with a length of 4 octets */ - if(phb->read_len < 4 + 4) + if(connect_info->read_len < 4 + 4) return; buf += 4 + 4; break; case 0x03: /* the address field contains a fully-qualified domain name. The first octet of the address field contains the number of octets of name that follow, there is no terminating NUL octet. */ - if(phb->read_len < 4 + 1) + if(connect_info->read_len < 4 + 1) return; buf += 4 + 1; - if(phb->read_len < 4 + 1 + buf[0]) + if(connect_info->read_len < 4 + 1 + buf[0]) return; buf += buf[0]; break; case 0x04: /* the address is a version-6 IP address, with a length of 16 octets */ - if(phb->read_len < 4 + 16) + if(connect_info->read_len < 4 + 16) return; buf += 4 + 16; break; } - if(phb->read_len < (buf - phb->read_buffer) + 2) + if(connect_info->read_len < (buf - connect_info->read_buffer) + 2) return; /* Skip past BND.PORT */ buf += 2; - gaim_proxy_phb_connected(phb, source); + gaim_proxy_connect_info_connected(connect_info, source); } static void s5_sendconnect(gpointer data, int source) { - struct _GaimProxyConnectInfo *phb = data; - int hlen = strlen(phb->host); - phb->write_buf_len = 5 + hlen + 2; - phb->write_buffer = g_malloc(phb->write_buf_len); - phb->written_len = 0; + struct _GaimProxyConnectInfo *connect_info = data; + int hlen = strlen(connect_info->host); + connect_info->write_buf_len = 5 + hlen + 2; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + connect_info->written_len = 0; - phb->write_buffer[0] = 0x05; - phb->write_buffer[1] = 0x01; /* CONNECT */ - phb->write_buffer[2] = 0x00; /* reserved */ - phb->write_buffer[3] = 0x03; /* address type -- host name */ - phb->write_buffer[4] = hlen; - memcpy(phb->write_buffer + 5, phb->host, hlen); - phb->write_buffer[5 + hlen] = phb->port >> 8; - phb->write_buffer[5 + hlen + 1] = phb->port & 0xff; + connect_info->write_buffer[0] = 0x05; + connect_info->write_buffer[1] = 0x01; /* CONNECT */ + connect_info->write_buffer[2] = 0x00; /* reserved */ + connect_info->write_buffer[3] = 0x03; /* address type -- host name */ + connect_info->write_buffer[4] = hlen; + memcpy(connect_info->write_buffer + 5, connect_info->host, hlen); + connect_info->write_buffer[5 + hlen] = connect_info->port >> 8; + connect_info->write_buffer[5 + hlen + 1] = connect_info->port & 0xff; - phb->read_cb = s5_canread_again; + connect_info->read_cb = s5_canread_again; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, phb); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); } static void s5_readauth(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; int len; - if (phb->read_buffer == NULL) { - phb->read_buf_len = 2; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 2; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } gaim_debug_info("socks5 proxy", "Got auth response.\n"); - len = read(source, phb->read_buffer + phb->read_len, - phb->read_buf_len - phb->read_len); + len = read(source, connect_info->read_buffer + connect_info->read_len, + connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - phb->read_len += len; + connect_info->read_len += len; - if (phb->read_len < 2) + if (connect_info->read_len < 2) return; - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; - if ((phb->read_buffer[0] != 0x01) || (phb->read_buffer[1] != 0x00)) { + if ((connect_info->read_buffer[0] != 0x01) || (connect_info->read_buffer[1] != 0x00)) { close(source); - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - g_free(phb->read_buffer); - phb->read_buffer = NULL; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - s5_sendconnect(phb, source); + s5_sendconnect(connect_info, source); } static void hmacmd5_chap(const unsigned char * challenge, int challen, const char * passwd, unsigned char * response) @@ -1839,45 +1839,45 @@ s5_readchap(gpointer data, gint source, GaimInputCondition cond) { guchar *cmdbuf, *buf; - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; int len, navas, currentav; gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Got CHAP response.\n"); - if (phb->read_buffer == NULL) { - phb->read_buf_len = 20; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 20; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } - len = read(source, phb->read_buffer + phb->read_len, - phb->read_buf_len - phb->read_len); + len = read(source, connect_info->read_buffer + connect_info->read_len, + connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - phb->read_len += len; + connect_info->read_len += len; - if (phb->read_len < 2) + if (connect_info->read_len < 2) return; - cmdbuf = phb->read_buffer; + cmdbuf = connect_info->read_buffer; if (*cmdbuf != 0x01) { close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } cmdbuf++; @@ -1886,21 +1886,21 @@ cmdbuf++; for (currentav = 0; currentav < navas; currentav++) { - if (phb->read_len - (cmdbuf - phb->read_buffer) < 2) + if (connect_info->read_len - (cmdbuf - connect_info->read_buffer) < 2) return; - if (phb->read_len - (cmdbuf - phb->read_buffer) < cmdbuf[1]) + if (connect_info->read_len - (cmdbuf - connect_info->read_buffer) < cmdbuf[1]) return; buf = cmdbuf + 2; switch (cmdbuf[0]) { case 0x00: /* Did auth work? */ if (buf[0] == 0x00) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; /* Success */ - s5_sendconnect(phb, source); + s5_sendconnect(connect_info, source); return; } else { /* Failure */ @@ -1908,39 +1908,39 @@ "socks5 CHAP authentication " "failed. Disconnecting..."); close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } break; case 0x03: /* Server wants our credentials */ - phb->write_buf_len = 16 + 4; - phb->write_buffer = g_malloc(phb->write_buf_len); - phb->written_len = 0; + connect_info->write_buf_len = 16 + 4; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + connect_info->written_len = 0; hmacmd5_chap(buf, cmdbuf[1], - gaim_proxy_info_get_password(phb->gpi), - phb->write_buffer + 4); - phb->write_buffer[0] = 0x01; - phb->write_buffer[1] = 0x01; - phb->write_buffer[2] = 0x04; - phb->write_buffer[3] = 0x10; + gaim_proxy_info_get_password(connect_info->gpi), + connect_info->write_buffer + 4); + connect_info->write_buffer[0] = 0x01; + connect_info->write_buffer[1] = 0x01; + connect_info->write_buffer[2] = 0x04; + connect_info->write_buffer[3] = 0x10; - gaim_input_remove(phb->inpa); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + gaim_input_remove(connect_info->inpa); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->read_cb = s5_readchap; + connect_info->read_cb = s5_readchap; - phb->inpa = gaim_input_add(source, - GAIM_INPUT_WRITE, proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, + GAIM_INPUT_WRITE, proxy_do_write, connect_info); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); break; case 0x11: /* Server wants to select an algorithm */ @@ -1953,11 +1953,11 @@ "of the socks5 CHAP specification. " "Disconnecting..."); close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } break; @@ -1972,113 +1972,113 @@ static void s5_canread(gpointer data, gint source, GaimInputCondition cond) { - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; int len; - if (phb->read_buffer == NULL) { - phb->read_buf_len = 2; - phb->read_buffer = g_malloc(phb->read_buf_len); - phb->read_len = 0; + if (connect_info->read_buffer == NULL) { + connect_info->read_buf_len = 2; + connect_info->read_buffer = g_malloc(connect_info->read_buf_len); + connect_info->read_len = 0; } gaim_debug_info("socks5 proxy", "Able to read.\n"); - len = read(source, phb->read_buffer + phb->read_len, - phb->read_buf_len - phb->read_len); + len = read(source, connect_info->read_buffer + connect_info->read_len, + connect_info->read_buf_len - connect_info->read_len); if(len < 0 && errno == EAGAIN) return; else if(len <= 0) { close(source); - gaim_input_remove(phb->inpa); - phb->inpa = 0; - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - phb->read_len += len; + connect_info->read_len += len; - if (phb->read_len < 2) + if (connect_info->read_len < 2) return; - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; - if ((phb->read_buffer[0] != 0x05) || (phb->read_buffer[1] == 0xff)) { + if ((connect_info->read_buffer[0] != 0x05) || (connect_info->read_buffer[1] == 0xff)) { close(source); - g_free(phb->read_buffer); - phb->read_buffer = NULL; - try_connect(phb); + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; + try_connect(connect_info); return; } - if (phb->read_buffer[1] == 0x02) { + if (connect_info->read_buffer[1] == 0x02) { gsize i, j; const char *u, *p; - u = gaim_proxy_info_get_username(phb->gpi); - p = gaim_proxy_info_get_password(phb->gpi); + u = gaim_proxy_info_get_username(connect_info->gpi); + p = gaim_proxy_info_get_password(connect_info->gpi); i = (u == NULL) ? 0 : strlen(u); j = (p == NULL) ? 0 : strlen(p); - phb->write_buf_len = 1 + 1 + i + 1 + j; - phb->write_buffer = g_malloc(phb->write_buf_len); - phb->written_len = 0; + connect_info->write_buf_len = 1 + 1 + i + 1 + j; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + connect_info->written_len = 0; - phb->write_buffer[0] = 0x01; /* version 1 */ - phb->write_buffer[1] = i; + connect_info->write_buffer[0] = 0x01; /* version 1 */ + connect_info->write_buffer[1] = i; if (u != NULL) - memcpy(phb->write_buffer + 2, u, i); - phb->write_buffer[2 + i] = j; + memcpy(connect_info->write_buffer + 2, u, i); + connect_info->write_buffer[2 + i] = j; if (p != NULL) - memcpy(phb->write_buffer + 2 + i + 1, p, j); + memcpy(connect_info->write_buffer + 2 + i + 1, p, j); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->read_cb = s5_readauth; + connect_info->read_cb = s5_readauth; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, - proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + proxy_do_write, connect_info); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); return; - } else if (phb->read_buffer[1] == 0x03) { + } else if (connect_info->read_buffer[1] == 0x03) { gsize userlen; - userlen = strlen(gaim_proxy_info_get_username(phb->gpi)); + userlen = strlen(gaim_proxy_info_get_username(connect_info->gpi)); - phb->write_buf_len = 7 + userlen; - phb->write_buffer = g_malloc(phb->write_buf_len); - phb->written_len = 0; + connect_info->write_buf_len = 7 + userlen; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + connect_info->written_len = 0; - phb->write_buffer[0] = 0x01; - phb->write_buffer[1] = 0x02; - phb->write_buffer[2] = 0x11; - phb->write_buffer[3] = 0x01; - phb->write_buffer[4] = 0x85; - phb->write_buffer[5] = 0x02; - phb->write_buffer[6] = userlen; - memcpy(phb->write_buffer + 7, - gaim_proxy_info_get_username(phb->gpi), userlen); + connect_info->write_buffer[0] = 0x01; + connect_info->write_buffer[1] = 0x02; + connect_info->write_buffer[2] = 0x11; + connect_info->write_buffer[3] = 0x01; + connect_info->write_buffer[4] = 0x85; + connect_info->write_buffer[5] = 0x02; + connect_info->write_buffer[6] = userlen; + memcpy(connect_info->write_buffer + 7, + gaim_proxy_info_get_username(connect_info->gpi), userlen); - g_free(phb->read_buffer); - phb->read_buffer = NULL; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - phb->read_cb = s5_readchap; + connect_info->read_cb = s5_readchap; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, - proxy_do_write, phb); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, + proxy_do_write, connect_info); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); return; } else { - g_free(phb->read_buffer); - phb->read_buffer = NULL; + g_free(connect_info->read_buffer); + connect_info->read_buffer = NULL; - s5_sendconnect(phb, source); + s5_sendconnect(connect_info, source); } } @@ -2087,30 +2087,30 @@ { unsigned char buf[5]; int i; - struct _GaimProxyConnectInfo *phb = data; + struct _GaimProxyConnectInfo *connect_info = data; socklen_t len; int error = ETIMEDOUT; gaim_debug_info("socks5 proxy", "Connected.\n"); - if (phb->inpa > 0) + if (connect_info->inpa > 0) { - gaim_input_remove(phb->inpa); - phb->inpa = 0; + gaim_input_remove(connect_info->inpa); + connect_info->inpa = 0; } len = sizeof(error); if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { close(source); - try_connect(phb); + try_connect(connect_info); return; } i = 0; buf[0] = 0x05; /* SOCKS version 5 */ - if (gaim_proxy_info_get_username(phb->gpi) != NULL) { + if (gaim_proxy_info_get_username(connect_info->gpi) != NULL) { buf[1] = 0x03; /* three methods */ buf[2] = 0x00; /* no authentication */ buf[3] = 0x03; /* CHAP authentication */ @@ -2123,26 +2123,26 @@ i = 3; } - phb->write_buf_len = i; - phb->write_buffer = g_malloc(phb->write_buf_len); - memcpy(phb->write_buffer, buf, i); + connect_info->write_buf_len = i; + connect_info->write_buffer = g_malloc(connect_info->write_buf_len); + memcpy(connect_info->write_buffer, buf, i); - phb->read_cb = s5_canread; + connect_info->read_cb = s5_canread; - phb->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, phb); - proxy_do_write(phb, source, GAIM_INPUT_WRITE); + connect_info->inpa = gaim_input_add(source, GAIM_INPUT_WRITE, proxy_do_write, connect_info); + proxy_do_write(connect_info, source, GAIM_INPUT_WRITE); } static int -proxy_connect_socks5(struct _GaimProxyConnectInfo *phb, struct sockaddr *addr, socklen_t addrlen) +proxy_connect_socks5(struct _GaimProxyConnectInfo *connect_info, struct sockaddr *addr, socklen_t addrlen) { int fd = -1; gaim_debug_info("socks5 proxy", "Connecting to %s:%d via %s:%d using SOCKS5\n", - phb->host, phb->port, - gaim_proxy_info_get_host(phb->gpi), - gaim_proxy_info_get_port(phb->gpi)); + connect_info->host, connect_info->port, + gaim_proxy_info_get_host(connect_info->gpi), + gaim_proxy_info_get_port(connect_info->gpi)); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) return -1; @@ -2157,7 +2157,7 @@ gaim_debug_warning("socks5 proxy", "Connect would have blocked.\n"); - phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s5_canwrite, phb); + connect_info->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, s5_canwrite, connect_info); } else { close(fd); @@ -2178,43 +2178,43 @@ return -1; } - s5_canwrite(phb, fd, GAIM_INPUT_WRITE); + s5_canwrite(connect_info, fd, GAIM_INPUT_WRITE); } return fd; } -static void try_connect(struct _GaimProxyConnectInfo *phb) +static void try_connect(struct _GaimProxyConnectInfo *connect_info) { size_t addrlen; struct sockaddr *addr; int ret = -1; - while (phb->hosts) { - addrlen = GPOINTER_TO_INT(phb->hosts->data); - phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); - addr = phb->hosts->data; - phb->hosts = g_slist_remove(phb->hosts, phb->hosts->data); + while (connect_info->hosts) { + addrlen = GPOINTER_TO_INT(connect_info->hosts->data); + connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); + addr = connect_info->hosts->data; + connect_info->hosts = g_slist_remove(connect_info->hosts, connect_info->hosts->data); - switch (gaim_proxy_info_get_type(phb->gpi)) { + switch (gaim_proxy_info_get_type(connect_info->gpi)) { case GAIM_PROXY_NONE: - ret = proxy_connect_none(phb, addr, addrlen); + ret = proxy_connect_none(connect_info, addr, addrlen); break; case GAIM_PROXY_HTTP: - ret = proxy_connect_http(phb, addr, addrlen); + ret = proxy_connect_http(connect_info, addr, addrlen); break; case GAIM_PROXY_SOCKS4: - ret = proxy_connect_socks4(phb, addr, addrlen); + ret = proxy_connect_socks4(connect_info, addr, addrlen); break; case GAIM_PROXY_SOCKS5: - ret = proxy_connect_socks5(phb, addr, addrlen); + ret = proxy_connect_socks5(connect_info, addr, addrlen); break; case GAIM_PROXY_USE_ENVVAR: - ret = proxy_connect_http(phb, addr, addrlen); + ret = proxy_connect_http(connect_info, addr, addrlen); break; default: @@ -2228,7 +2228,7 @@ } if (ret < 0) { - gaim_proxy_phb_error(phb, _("TODO")); + gaim_proxy_connect_info_error(connect_info, _("TODO")); } } @@ -2236,11 +2236,11 @@ connection_host_resolved(GSList *hosts, gpointer data, const char *error_message) { - struct _GaimProxyConnectInfo *phb = (struct _GaimProxyConnectInfo*)data; + struct _GaimProxyConnectInfo *connect_info = (struct _GaimProxyConnectInfo*)data; - phb->hosts = hosts; + connect_info->hosts = hosts; - try_connect(phb); + try_connect(connect_info); } GaimProxyInfo * @@ -2316,31 +2316,31 @@ { const char *connecthost = host; int connectport = port; - struct _GaimProxyConnectInfo *phb; + struct _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! */ - phb = g_new0(struct _GaimProxyConnectInfo, 1); - phb->connect_cb = connect_cb; - phb->error_cb = error_cb; - phb->data = data; - phb->host = g_strdup(host); - phb->port = port; - phb->gpi = gaim_proxy_get_setup(account); + connect_info = g_new0(struct _GaimProxyConnectInfo, 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; + connect_info->gpi = gaim_proxy_get_setup(account); - if ((gaim_proxy_info_get_type(phb->gpi) != GAIM_PROXY_NONE) && - (gaim_proxy_info_get_host(phb->gpi) == NULL || - gaim_proxy_info_get_port(phb->gpi) <= 0)) { + if ((gaim_proxy_info_get_type(connect_info->gpi) != GAIM_PROXY_NONE) && + (gaim_proxy_info_get_host(connect_info->gpi) == NULL || + gaim_proxy_info_get_port(connect_info->gpi) <= 0)) { gaim_notify_error(NULL, NULL, _("Invalid proxy settings"), _("Either the host name or port number specified for your given proxy type is invalid.")); - gaim_proxy_phb_destroy(phb); + gaim_proxy_connect_info_destroy(connect_info); return NULL; } - switch (gaim_proxy_info_get_type(phb->gpi)) + switch (gaim_proxy_info_get_type(connect_info->gpi)) { case GAIM_PROXY_NONE: break; @@ -2349,25 +2349,25 @@ case GAIM_PROXY_SOCKS4: case GAIM_PROXY_SOCKS5: case GAIM_PROXY_USE_ENVVAR: - connecthost = gaim_proxy_info_get_host(phb->gpi); - connectport = gaim_proxy_info_get_port(phb->gpi); + connecthost = gaim_proxy_info_get_host(connect_info->gpi); + connectport = gaim_proxy_info_get_port(connect_info->gpi); break; default: - gaim_proxy_phb_destroy(phb); + gaim_proxy_connect_info_destroy(connect_info); return NULL; } if (gaim_gethostbyname_async(connecthost, - connectport, connection_host_resolved, phb) != 0) + connectport, connection_host_resolved, connect_info) != 0) { - gaim_proxy_phb_destroy(phb); + gaim_proxy_connect_info_destroy(connect_info); return NULL; } - phbs = g_slist_prepend(phbs, phb); + connect_infos = g_slist_prepend(connect_infos, connect_info); - return phb; + return connect_info; } /* @@ -2378,31 +2378,31 @@ GaimProxyConnectFunction connect_cb, GaimProxyErrorFunction error_cb, gpointer data) { - struct _GaimProxyConnectInfo *phb; + struct _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! */ - phb = g_new0(struct _GaimProxyConnectInfo, 1); - phb->connect_cb = connect_cb; - phb->error_cb = error_cb; - phb->data = data; - phb->host = g_strdup(host); - phb->port = port; - phb->gpi = gpi; + connect_info = g_new0(struct _GaimProxyConnectInfo, 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; + connect_info->gpi = gpi; if (gaim_gethostbyname_async(gaim_proxy_info_get_host(gpi), - gaim_proxy_info_get_port(gpi), connection_host_resolved, phb) != 0) + gaim_proxy_info_get_port(gpi), connection_host_resolved, connect_info) != 0) { - gaim_proxy_phb_destroy(phb); + gaim_proxy_connect_info_destroy(connect_info); return NULL; } - phbs = g_slist_prepend(phbs, phb); + connect_infos = g_slist_prepend(connect_infos, connect_info); - return phb; + return connect_info; } @@ -2485,6 +2485,6 @@ void gaim_proxy_uninit(void) { - while (phbs != NULL) - gaim_proxy_phb_destroy(phbs->data); + while (connect_infos != NULL) + gaim_proxy_connect_info_destroy(connect_infos->data); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rl...@us...> - 2006-08-12 20:01:45
|
Revision: 16724 Author: rlaager Date: 2006-08-12 13:01:35 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16724&view=rev Log Message: ----------- Remove an outdated comment. Modified Paths: -------------- trunk/src/proxy.c Modified: trunk/src/proxy.c =================================================================== --- trunk/src/proxy.c 2006-08-12 15:17:14 UTC (rev 16723) +++ trunk/src/proxy.c 2006-08-12 20:01:35 UTC (rev 16724) @@ -38,7 +38,6 @@ #include "proxy.h" #include "util.h" -/* Does anyone know what PHB stands for? */ struct _GaimProxyConnectInfo { GaimProxyConnectFunction connect_cb; GaimProxyErrorFunction error_cb; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sa...@us...> - 2006-08-12 15:17:19
|
Revision: 16723 Author: sadrul Date: 2006-08-12 08:17:14 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16723&view=rev Log Message: ----------- Tab-completion should be case-insensitive. Modified Paths: -------------- trunk/console/libgnt/gntentry.c Modified: trunk/console/libgnt/gntentry.c =================================================================== --- trunk/console/libgnt/gntentry.c 2006-08-12 12:57:16 UTC (rev 16722) +++ trunk/console/libgnt/gntentry.c 2006-08-12 15:17:14 UTC (rev 16723) @@ -80,7 +80,7 @@ for (count = 0, iter = entry->suggests; iter; iter = iter->next) { const char *text = iter->data; - if (strncmp(suggest, text, len) == 0 && strlen(text) >= len) + if (g_ascii_strncasecmp(suggest, text, len) == 0 && strlen(text) >= len) { gnt_tree_add_row_after(GNT_TREE(entry->ddown), (gpointer)text, gnt_tree_create_row(GNT_TREE(entry->ddown), text), @@ -258,10 +258,9 @@ { char *s = get_beginning_of_word(entry); char *iter = text; - while (*s == *iter) + while (toupper(*s) == toupper(*iter)) { - s++; - iter++; + *s++ = *iter++; } gnt_entry_key_pressed(widget, iter); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <may...@us...> - 2006-08-12 12:57:26
|
Revision: 16722 Author: mayuan2006 Date: 2006-08-12 05:57:16 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16722&view=rev Log Message: ----------- change some minor bug committed by Ma Yuan<may...@gm...> Modified Paths: -------------- branches/soc-2006-msnp13/src/protocols/msn/notification.c branches/soc-2006-msnp13/src/protocols/msn/oim.c branches/soc-2006-msnp13/src/protocols/msn/oim.h Modified: branches/soc-2006-msnp13/src/protocols/msn/notification.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-12 11:20:34 UTC (rev 16721) +++ branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-12 12:57:16 UTC (rev 16722) @@ -37,7 +37,7 @@ /**************************************************************************** * Local Function Prototype ****************************************************************************/ -void msn_add_contact_xml(xmlnode *mlNode,char *passport,int list_op,int type); +void msn_add_contact_xml(xmlnode *mlNode,const char *passport,int list_op,int type); /************************************************************************** * Main @@ -441,7 +441,7 @@ **************************************************************************/ /* add contact to xmlnode */ void -msn_add_contact_xml(xmlnode *mlNode,char *passport,int list_op,int type) +msn_add_contact_xml(xmlnode *mlNode,const char *passport,int list_op,int type) { xmlnode *d_node,*c_node; char **tokens; @@ -1383,8 +1383,6 @@ initial_mdata_msg(MsnCmdProc *cmdproc, MsnMessage *msg) { MsnSession *session; - xmlnode *mdNode; - char *end; char **elems, **cur, **tokens; // gaim_debug_info("MaYuan","mdata...{%s} \n",msg->body); Modified: branches/soc-2006-msnp13/src/protocols/msn/oim.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/oim.c 2006-08-12 11:20:34 UTC (rev 16721) +++ branches/soc-2006-msnp13/src/protocols/msn/oim.c 2006-08-12 12:57:16 UTC (rev 16722) @@ -233,7 +233,7 @@ /*parse the oim XML data*/ void -msn_parse_oim_msg(MsnOim *oim,char *xmlmsg) +msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg) { xmlnode *mdNode,*mNode,*INode,*nNode,*ENode,*rtNode; char *passport,*rTime,*msgid,*nickname; Modified: branches/soc-2006-msnp13/src/protocols/msn/oim.h =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/oim.h 2006-08-12 11:20:34 UTC (rev 16721) +++ branches/soc-2006-msnp13/src/protocols/msn/oim.h 2006-08-12 12:57:16 UTC (rev 16722) @@ -103,7 +103,7 @@ void msn_oim_destroy(MsnOim *oim); void msn_oim_connect(MsnOim *oim); -void msn_parse_oim_msg(MsnOim *oim,char *xmlmsg); +void msn_parse_oim_msg(MsnOim *oim,const char *xmlmsg); /*get the OIM message*/ void msn_oim_get_msg(MsnOim *oim); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <may...@us...> - 2006-08-12 11:20:41
|
Revision: 16721 Author: mayuan2006 Date: 2006-08-12 04:20:34 -0700 (Sat, 12 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16721&view=rev Log Message: ----------- change the GCF payload process procedure committed by Ma Yuan<may...@gm...> Modified Paths: -------------- branches/soc-2006-msnp13/src/protocols/msn/notification.c Modified: branches/soc-2006-msnp13/src/protocols/msn/notification.c =================================================================== --- branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-12 11:16:53 UTC (rev 16720) +++ branches/soc-2006-msnp13/src/protocols/msn/notification.c 2006-08-12 11:20:34 UTC (rev 16721) @@ -1230,17 +1230,22 @@ } static void -gcf_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) +gcf_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, + size_t len) { - gaim_debug_info("MaYuan","Processing GCF... \n"); - if(cmd->payload_len == 0){ - return; - } /*get the payload content*/ gaim_debug_info("MaYuan","GCF{%s}\n",cmd->payload); } static void +gcf_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) +{ + gaim_debug_info("MaYuan","Processing GCF... \n"); + cmdproc->last_cmd->payload_cb = gcf_cmd_post; + return; +} + +static void sbs_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { gaim_debug_info("MaYuan","Processing SBS... \n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |