changeset 14099:7b030f6ed1c3

[gaim-migrate @ 16728] Extremely minor error message improvements committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 12 Aug 2006 22:16:23 +0000
parents a8c9d714658c
children 85144ba7d726
files src/proxy.c
diffstat 1 files changed, 36 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/proxy.c	Sat Aug 12 21:13:25 2006 +0000
+++ b/src/proxy.c	Sat Aug 12 22:16:23 2006 +0000
@@ -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;