# HG changeset patch # User Mark Doliner # Date 1130738774 0 # Node ID 0d9c6d2ad64b5a4884d39258f7d0f74bd00b24f2 # Parent 5b703a92e79d5e9f100a09ad4d67c4dc5cfc93fa [gaim-migrate @ 14218] Better error handling for Howl when your mDNS daemon is not running committer: Tailor Script diff -r 5b703a92e79d -r 0d9c6d2ad64b src/protocols/bonjour/bonjour.c --- 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); diff -r 5b703a92e79d -r 0d9c6d2ad64b src/protocols/bonjour/dns_sd.c --- 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; } diff -r 5b703a92e79d -r 0d9c6d2ad64b src/protocols/bonjour/dns_sd.h --- 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 diff -r 5b703a92e79d -r 0d9c6d2ad64b src/prpl.c --- 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; }