changeset 15695:79808b1a237f

merge of 'e57f2c0fb5b3a764c079b6991a8e68e23230b016' and 'fe52ccdd53046a7cef83ae2919b4f98960d8b416'
author Sean Egan <seanegan@gmail.com>
date Sun, 25 Feb 2007 01:09:40 +0000
parents 95d67f46bb93 (current diff) c463709294f8 (diff)
children 31a6bfedf7be
files
diffstat 13 files changed, 148 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Sun Feb 25 01:09:27 2007 +0000
+++ b/COPYRIGHT	Sun Feb 25 01:09:40 2007 +0000
@@ -297,6 +297,7 @@
 Jim Seymour
 Joe Shaw
 Scott Shedden
+Dossy Shiobara
 Ettore Simone
 John Silvestri
 Craig Slusher
--- a/console/gntgaim.c	Sun Feb 25 01:09:27 2007 +0000
+++ b/console/gntgaim.c	Sun Feb 25 01:09:40 2007 +0000
@@ -148,7 +148,8 @@
 	g_timeout_add,
 	g_source_remove,
 	gnt_input_add,
-	g_source_remove
+	g_source_remove,
+	NULL /* input_get_error */
 };
 
 static GaimEventLoopUiOps *
--- a/console/libgnt/gntcolors.c	Sun Feb 25 01:09:27 2007 +0000
+++ b/console/libgnt/gntcolors.c	Sun Feb 25 01:09:40 2007 +0000
@@ -161,7 +161,7 @@
 		while (nkeys--)
 		{
 			gsize len;
-			char *key = keys[nkeys];
+			gchar *key = keys[nkeys];
 			char **list = g_key_file_get_string_list(kfile, "colors", key, &len, NULL);
 			if (len == 3)
 			{
@@ -170,8 +170,9 @@
 				int b = atoi(list[2]);
 				int color = -1;
 
-				g_ascii_strdown(key, -1);
+				key = g_ascii_strdown(key, -1);
 				color = get_color(key);
+				g_free(key);
 				if (color == -1)
 					continue;
 
@@ -204,17 +205,21 @@
 	while (nkeys--)
 	{
 		gsize len;
-		char *key = keys[nkeys];
+		gchar *key = keys[nkeys];
 		char **list = g_key_file_get_string_list(kfile, "colorpairs", key, &len, NULL);
 		if (len == 2)
 		{
 			GntColorType type = 0;
-			int fg = get_color(g_ascii_strdown(list[0], -1));
-			int bg = get_color(g_ascii_strdown(list[1], -1));
+			gchar *fgc = g_ascii_strdown(list[0], -1);
+			gchar *bgc = g_ascii_strdown(list[1], -1);
+			int fg = get_color(fgc);
+			int bg = get_color(bgc);
+			g_free(fgc);
+			g_free(bgc);
 			if (fg == -1 || bg == -1)
 				continue;
 
-			g_ascii_strdown(key, -1);
+			key = g_ascii_strdown(key, -1);
 
 			if (strcmp(key, "normal") == 0)
 				type = GNT_COLOR_NORMAL;
@@ -234,8 +239,11 @@
 				type = GNT_COLOR_DISABLED;
 			else if (strcmp(key, "urgent") == 0)
 				type = GNT_COLOR_URGENT;
-			else
+			else {
+				g_free(key);
 				continue;
+			}
+			g_free(key);
 
 			init_pair(type, fg, bg);
 		}
--- a/libpurple/eventloop.c	Sun Feb 25 01:09:27 2007 +0000
+++ b/libpurple/eventloop.c	Sun Feb 25 01:09:40 2007 +0000
@@ -23,6 +23,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "eventloop.h"
+#include "internal.h"
 
 static GaimEventLoopUiOps *eventloop_ui_ops = NULL;
 
@@ -58,6 +59,26 @@
 	return ops->input_remove(tag);
 }
 
+int
+gaim_input_get_error(int fd, int *error)
+{
+	GaimEventLoopUiOps *ops = gaim_eventloop_get_ui_ops();
+
+	if (ops->input_get_error)
+	{
+		int ret = ops->input_get_error(fd, error);
+		errno = *error;
+		return ret;
+	}
+	else
+	{
+		socklen_t len;
+		len = sizeof(*error);
+
+		return getsockopt(fd, SOL_SOCKET, SO_ERROR, error, &len);
+	}
+}
+
 void
 gaim_eventloop_set_ui_ops(GaimEventLoopUiOps *ops)
 {
--- a/libpurple/eventloop.h	Sun Feb 25 01:09:27 2007 +0000
+++ b/libpurple/eventloop.h	Sun Feb 25 01:09:40 2007 +0000
@@ -71,6 +71,16 @@
 	 * @see gaim_input_remove, g_source_remove
 	 */
 	gboolean (*input_remove)(guint handle);
+	
+	
+	/**
+	 * Get the current error status for an input.
+	 * Implementation of this UI op is optional. Implement it if the UI's sockets
+	 * or event loop needs to customize determination of socket error status.
+	 * @see gaim_input_get_error, getsockopt
+	 */
+	int (*input_get_error)(int fd, int *error);
+
 };
 
 /**************************************************************************/
@@ -121,6 +131,21 @@
  */
 gboolean gaim_input_remove(guint handle);
 
+/**
+ * Get the current error status for an input.
+ * The return value and error follow getsockopt() with a level of SOL_SOCKET and an
+ * option name of SO_ERROR, and this is how the error is determined if the UI does not
+ * implement the input_get_error UI op.
+ *
+ * @param fd        The input file descriptor.
+ * @param errno		A pointer to an int which on return will have the error, or 0 if no error.
+ *
+ * @return 0 if there is no error; -1 if there is an error, in which case errno will be set.
+ */
+int
+gaim_input_get_error(int fd, int *error);
+
+
 /*@}*/
 
 
--- a/libpurple/example/nullclient.c	Sun Feb 25 01:09:27 2007 +0000
+++ b/libpurple/example/nullclient.c	Sun Feb 25 01:09:40 2007 +0000
@@ -107,7 +107,8 @@
 	g_timeout_add,
 	g_source_remove,
 	glib_input_add,
-	g_source_remove
+	g_source_remove,
+	NULL
 };
 /*** End of the eventloop functions. ***/
 
--- a/libpurple/plugins/tcl/signal-test.tcl	Sun Feb 25 01:09:27 2007 +0000
+++ b/libpurple/plugins/tcl/signal-test.tcl	Sun Feb 25 01:09:40 2007 +0000
@@ -100,6 +100,14 @@
 }
 }
 
+gaim::signal connect [gaim::plugins handle] plugin-load args {
+	gaim::debug -info "tcl signal" "plugin-load [list $args]"
+}
+
+gaim::signal connect [gaim::plugins handle] plugin-unload args {
+	gaim::debug -info "tcl signal" "plugin-unload [list $args]"
+}
+
 proc plugin_init { } {
 	list "Tcl Signal Test" \
              "$gaim::version" \
--- a/libpurple/plugins/tcl/tcl.c	Sun Feb 25 01:09:27 2007 +0000
+++ b/libpurple/plugins/tcl/tcl.c	Sun Feb 25 01:09:40 2007 +0000
@@ -134,6 +134,7 @@
 	Tcl_CreateObjCommand(interp, "::gaim::core", tcl_cmd_core, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::debug", tcl_cmd_debug, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::notify", tcl_cmd_notify, (ClientData)NULL, NULL);
+	Tcl_CreateObjCommand(interp, "::gaim::plugins", tcl_cmd_plugins, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::prefs", tcl_cmd_prefs, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::presence", tcl_cmd_presence, (ClientData)NULL, NULL);
 	Tcl_CreateObjCommand(interp, "::gaim::send_im", tcl_cmd_send_im, (ClientData)NULL, NULL);
--- a/libpurple/plugins/tcl/tcl_cmds.c	Sun Feb 25 01:09:27 2007 +0000
+++ b/libpurple/plugins/tcl/tcl_cmds.c	Sun Feb 25 01:09:40 2007 +0000
@@ -912,6 +912,34 @@
 	return TCL_OK;
 }
 
+int tcl_cmd_plugins(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+	Tcl_Obj *result = Tcl_GetObjResult(interp);
+	const char *cmds[] = { "handle", NULL };
+	enum { CMD_PLUGINS_HANDLE } cmd;
+	int error;
+
+	if (objc < 2) {
+		Tcl_WrongNumArgs(interp, 1, objv, "subcommand ?args?");
+		return TCL_ERROR;
+	}
+
+	if ((error = Tcl_GetIndexFromObj(interp, objv[1], cmds, "subcommand", 0, (int *)&cmd)) != TCL_OK)
+		return error;
+
+	switch (cmd) {
+	case CMD_PLUGINS_HANDLE:
+		if (objc != 2) {
+			Tcl_WrongNumArgs(interp, 2, objv, "");
+			return TCL_ERROR;
+		}
+		Tcl_SetIntObj(result, (int)gaim_plugins_get_handle());
+		break;
+	}
+
+	return TCL_OK;
+}
+
 int tcl_cmd_prefs(ClientData unused, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	Tcl_Obj *result, *list, *elem, **elems;
--- a/libpurple/plugins/tcl/tcl_gaim.h	Sun Feb 25 01:09:27 2007 +0000
+++ b/libpurple/plugins/tcl/tcl_gaim.h	Sun Feb 25 01:09:40 2007 +0000
@@ -104,6 +104,7 @@
 Tcl_ObjCmdProc tcl_cmd_core;
 Tcl_ObjCmdProc tcl_cmd_debug;
 Tcl_ObjCmdProc tcl_cmd_notify;
+Tcl_ObjCmdProc tcl_cmd_plugins;
 Tcl_ObjCmdProc tcl_cmd_prefs;
 Tcl_ObjCmdProc tcl_cmd_presence;
 Tcl_ObjCmdProc tcl_cmd_send_im;
--- a/libpurple/protocols/msn/error.c	Sun Feb 25 01:09:27 2007 +0000
+++ b/libpurple/protocols/msn/error.c	Sun Feb 25 01:09:40 2007 +0000
@@ -28,18 +28,18 @@
 msn_error_get_text(unsigned int type, gboolean *debug)
 {
 	static char msg[MSN_BUF_LEN];
-	debug = FALSE;
+	*debug = FALSE;
 
 	switch (type) {
 		case 0:
 			g_snprintf(msg, sizeof(msg),
 					   _("Unable to parse message"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 200:
 			g_snprintf(msg, sizeof(msg),
 					   _("Syntax Error (probably a client bug)"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 201:
 			g_snprintf(msg, sizeof(msg),
@@ -66,7 +66,7 @@
 			break;
 		case 215:
 			g_snprintf(msg, sizeof(msg), _("Already there"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 216:
 			g_snprintf(msg, sizeof(msg), _("Not on list"));
@@ -76,11 +76,11 @@
 			break;
 		case 218:
 			g_snprintf(msg, sizeof(msg), _("Already in the mode"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 219:
 			g_snprintf(msg, sizeof(msg), _("Already in opposite list"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 223:
 			g_snprintf(msg, sizeof(msg), _("Too many groups"));
@@ -96,7 +96,7 @@
 			break;
 		case 230:
 			g_snprintf(msg, sizeof(msg), _("Cannot remove group zero"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 231:
 			g_snprintf(msg, sizeof(msg),
@@ -105,20 +105,20 @@
 			break;
 		case 280:
 			g_snprintf(msg, sizeof(msg), _("Switchboard failed"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 281:
 			g_snprintf(msg, sizeof(msg), _("Notify transfer failed"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 
 		case 300:
 			g_snprintf(msg, sizeof(msg), _("Required fields missing"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 301:
 			g_snprintf(msg, sizeof(msg), _("Too many hits to a FND"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 302:
 			g_snprintf(msg, sizeof(msg), _("Not logged in"));
@@ -129,23 +129,23 @@
 			break;
 		case 501:
 			g_snprintf(msg, sizeof(msg), _("Database server error"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 502:
 			g_snprintf(msg, sizeof(msg), _("Command disabled"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 510:
 			g_snprintf(msg, sizeof(msg), _("File operation error"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 520:
 			g_snprintf(msg, sizeof(msg), _("Memory allocation error"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 540:
 			g_snprintf(msg, sizeof(msg), _("Wrong CHL value sent to server"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 
 		case 600:
@@ -156,11 +156,11 @@
 			break;
 		case 602:
 			g_snprintf(msg, sizeof(msg), _("Peer notification server down"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 603:
 			g_snprintf(msg, sizeof(msg), _("Database connect error"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 604:
 			g_snprintf(msg, sizeof(msg),
@@ -172,19 +172,19 @@
 
 		case 707:
 			g_snprintf(msg, sizeof(msg), _("Error creating connection"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 710:
 			g_snprintf(msg, sizeof(msg),
 					   _("CVR parameters are either unknown or not allowed"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 711:
 			g_snprintf(msg, sizeof(msg), _("Unable to write"));
 			break;
 		case 712:
 			g_snprintf(msg, sizeof(msg), _("Session overload"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 713:
 			g_snprintf(msg, sizeof(msg), _("User is too active"));
@@ -197,11 +197,11 @@
 			break;
 		case 717:
 			g_snprintf(msg, sizeof(msg), _("Bad friend file"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 		case 731:
 			g_snprintf(msg, sizeof(msg), _("Not expected"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 
 		case 800:
@@ -242,12 +242,12 @@
 			break;
 		case 928:
 			g_snprintf(msg, sizeof(msg), _("Bad ticket"));
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 
 		default:
 			g_snprintf(msg, sizeof(msg), _("Unknown Error Code %d"), type);
-			debug = TRUE;
+			*debug = TRUE;
 			break;
 	}
 
--- a/libpurple/proxy.c	Sun Feb 25 01:09:27 2007 +0000
+++ b/libpurple/proxy.c	Sun Feb 25 01:09:40 2007 +0000
@@ -386,14 +386,14 @@
 socket_ready_cb(gpointer data, gint source, GaimInputCondition cond)
 {
 	GaimProxyConnectData *connect_data = data;
-	socklen_t len;
 	int error = 0;
 	int ret;
 
-	gaim_debug_info("proxy", "Connected.\n");
+	gaim_debug_info("proxy", "Connected to %s:%d.\n",
+					connect_data->host, connect_data->port);
 
 	/*
-	 * getsockopt after a non-blocking connect returns -1 if something is
+	 * gaim_input_get_error after a non-blocking connect returns -1 if something is
 	 * really messed up (bad descriptor, usually). Otherwise, it returns 0 and
 	 * error holds what connect would have returned if it blocked until now.
 	 * Thus, error == 0 is success, error == EINPROGRESS means "try again",
@@ -403,17 +403,21 @@
 	 * be overly optimistic sometimes. select is just a hint that you might be
 	 * able to do something.)
 	 */
-	len = sizeof(error);
-	ret = getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len);
+	ret = gaim_input_get_error(connect_data->fd, &error);
 
-	if (ret == 0 && error == EINPROGRESS)
+	if (ret == 0 && error == EINPROGRESS) {
 		/* No worries - we'll be called again later */
 		/* TODO: Does this ever happen? */
+		gaim_debug_info("proxy", "(ret == 0 && error == EINPROGRESS)");
 		return;
+	}
 
 	if (ret != 0 || error != 0) {
 		if (ret != 0)
 			error = errno;
+		gaim_debug_info("proxy", "Error connecting to %s:%d (%s).\n",
+						connect_data->host, connect_data->port, strerror(error));
+
 		gaim_proxy_connect_data_disconnect(connect_data, strerror(error));
 		return;
 	}
@@ -466,14 +470,12 @@
 		/*
 		 * The connection happened IMMEDIATELY... strange, but whatever.
 		 */
-		socklen_t len;
 		int error = ETIMEDOUT;
 		int ret;
 
 		gaim_debug_info("proxy", "Connected immediately.\n");
 
-		len = sizeof(error);
-		ret = getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len);
+		ret = gaim_input_get_error(connect_data->fd, &error);
 		if ((ret != 0) || (error != 0))
 		{
 			if (ret != 0)
@@ -783,13 +785,13 @@
 {
 	GString *request;
 	GaimProxyConnectData *connect_data;
-	socklen_t len;
 	int error = ETIMEDOUT;
 	int ret;
 
-	gaim_debug_info("proxy", "Connected.\n");
+	connect_data = data;
 
-	connect_data = data;
+	gaim_debug_info("proxy", "Connected to %s:%d.\n",
+		connect_data->host, connect_data->port);
 
 	if (connect_data->inpa > 0)
 	{
@@ -797,8 +799,7 @@
 		connect_data->inpa = 0;
 	}
 
-	len = sizeof(error);
-	ret = getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len);
+	ret = gaim_input_get_error(connect_data->fd, &error);
 	if ((ret != 0) || (error != 0))
 	{
 		if (ret != 0)
@@ -947,7 +948,6 @@
 	unsigned char packet[9];
 	struct hostent *hp;
 	GaimProxyConnectData *connect_data = data;
-	socklen_t len;
 	int error = ETIMEDOUT;
 	int ret;
 
@@ -959,8 +959,7 @@
 		connect_data->inpa = 0;
 	}
 
-	len = sizeof(error);
-	ret = getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len);
+	ret = gaim_input_get_error(connect_data->fd, &error);
 	if ((ret != 0) || (error != 0))
 	{
 		if (ret != 0)
@@ -1515,7 +1514,6 @@
 	unsigned char buf[5];
 	int i;
 	GaimProxyConnectData *connect_data = data;
-	socklen_t len;
 	int error = ETIMEDOUT;
 	int ret;
 
@@ -1527,8 +1525,7 @@
 		connect_data->inpa = 0;
 	}
 
-	len = sizeof(error);
-	ret = getsockopt(connect_data->fd, SOL_SOCKET, SO_ERROR, &error, &len);
+	ret = gaim_input_get_error(connect_data->fd, &error);
 	if ((ret != 0) || (error != 0))
 	{
 		if (ret != 0)
--- a/pidgin/gtkeventloop.c	Sun Feb 25 01:09:27 2007 +0000
+++ b/pidgin/gtkeventloop.c	Sun Feb 25 01:09:40 2007 +0000
@@ -118,7 +118,8 @@
 	g_timeout_add,
 	g_source_remove,
 	pidgin_input_add,
-	g_source_remove
+	g_source_remove,
+	NULL /* input_get_error */
 };
 
 GaimEventLoopUiOps *