changeset 11927:0d9c6d2ad64b

[gaim-migrate @ 14218] Better error handling for Howl when your mDNS daemon is not running committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 31 Oct 2005 06:06:14 +0000
parents 5b703a92e79d
children f41037708e62
files src/protocols/bonjour/bonjour.c src/protocols/bonjour/dns_sd.c src/protocols/bonjour/dns_sd.h src/prpl.c
diffstat 4 files changed, 25 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/bonjour/bonjour.c	Mon Oct 31 05:57:23 2005 +0000
+++ b/src/protocols/bonjour/bonjour.c	Mon Oct 31 06:06:14 2005 +0000
@@ -88,7 +88,7 @@
 
 	if (bonjour_jabber_start(bd->jabber_data) == -1) {
 		/* Send a message about the connection error */
-		gaim_debug_error("bonjour", "Unable to listen to iChat connections");
+		gaim_debug_error("bonjour", "Unable to listen for incoming IM connections");
 
 		/* Free the data */
 		g_free(bd->jabber_data);
@@ -121,7 +121,11 @@
 	bd->dns_sd_data->msg = g_strdup(gaim_status_get_attr_string(status, "message"));
 
 	bd->dns_sd_data->account = account;
-	bonjour_dns_sd_start(bd->dns_sd_data);
+	if (!bonjour_dns_sd_start(bd->dns_sd_data))
+	{
+		gaim_connection_error(gc, _("Unable to establish connection with the local mDNS server.  Is it running?"));
+		return;
+	}
 
 	/* Create a group for bonjour buddies */
 	bonjour_group = gaim_group_new(BONJOUR_GROUP_NAME);
--- a/src/protocols/bonjour/dns_sd.c	Mon Oct 31 05:57:23 2005 +0000
+++ b/src/protocols/bonjour/dns_sd.c	Mon Oct 31 06:06:14 2005 +0000
@@ -238,7 +238,7 @@
 	/* Fill the data for the service */
 	if (sw_text_record_init(&dns_data) != SW_OKAY)
 	{
-		gaim_debug_error("bonjour", "Unable to initialize the data for the mDNS.");
+		gaim_debug_error("bonjour", "Unable to initialize the data for the mDNS.\n");
 		return -1;
 	}
 
@@ -334,7 +334,7 @@
  * Advertise our presence within the dns-sd daemon and start browsing
  * for other bonjour peers.
  */
-void
+gboolean
 bonjour_dns_sd_start(BonjourDnsSd *data)
 {
 	GaimAccount *account;
@@ -345,12 +345,14 @@
 	account = data->account;
 	gc = gaim_account_get_connection(account);
 
-	/* Initilizations of the dns-sd data and session */
+	/* Initialize the dns-sd data and session */
 	data->session = malloc(sizeof(sw_discovery));
 	if (sw_discovery_init(data->session) != SW_OKAY)
 	{
-		gaim_debug_error("bonjour", "Unable to initialize a mDNS session.");
-		return;
+		free(data->session);
+		data->session = NULL;
+		gaim_debug_error("bonjour", "Unable to initialize an mDNS session.\n");
+		return FALSE;
 	}
 
 	/* Publish our bonjour IM client at the mDNS daemon */
@@ -361,7 +363,7 @@
 			data->account, &session_id) != SW_OKAY)
 	{
 		gaim_debug_error("bonjour", "Unable to get service.");
-		return;
+		return FALSE;
 	}
 
 	/* Get the socket that communicates with the mDNS daemon and bind it to a */
@@ -369,22 +371,25 @@
 	dns_sd_socket = sw_discovery_socket(*(data->session));
 	gc->inpa = gaim_input_add(dns_sd_socket, GAIM_INPUT_READ,
 									_dns_sd_handle_packets, data->session);
+
+	return TRUE;
 }
 
 /**
  * Unregister the "_presence._tcp" service at the mDNS daemon.
  */
-int
+void
 bonjour_dns_sd_stop(BonjourDnsSd *data)
 {
 	GaimAccount *account;
 	GaimConnection *gc;
 
+	if (data->session == NULL)
+		return;
+
 	sw_discovery_cancel(*(data->session), data->session_id);
 
 	account = data->account;
 	gc = gaim_account_get_connection(account);
 	gaim_input_remove(gc->inpa);
-
-	return 0;
 }
--- a/src/protocols/bonjour/dns_sd.h	Mon Oct 31 05:57:23 2005 +0000
+++ b/src/protocols/bonjour/dns_sd.h	Mon Oct 31 06:06:14 2005 +0000
@@ -73,11 +73,11 @@
  * Advertise our presence within the dns-sd daemon and start
  * browsing for other bonjour peers.
  */
-void bonjour_dns_sd_start(BonjourDnsSd *data);
+gboolean bonjour_dns_sd_start(BonjourDnsSd *data);
 
 /**
  * Unregister the "_presence._tcp" service at the mDNS daemon.
  */
-int bonjour_dns_sd_stop(BonjourDnsSd *data);
+void bonjour_dns_sd_stop(BonjourDnsSd *data);
 
 #endif
--- a/src/prpl.c	Mon Oct 31 05:57:23 2005 +0000
+++ b/src/prpl.c	Mon Oct 31 06:06:14 2005 +0000
@@ -304,10 +304,10 @@
 		return;
 	}
 
-	if (!gaim_status_is_online(new_status) &&
-			 !gaim_account_is_disconnected(account))
+	if (!gaim_status_is_online(new_status))
 	{
-		gaim_account_disconnect(account);
+		if (!gaim_account_is_disconnected(account))
+			gaim_account_disconnect(account);
 		return;
 	}