From: Kaj-Michael Lang Date: Thu, 15 May 2008 15:54:55 +0000 (+0300) Subject: GpsBluez: cleanups X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc6a3245440b46a2d86fb6c2e26332fdf63ba51e;p=mapper GpsBluez: cleanups --- diff --git a/src/gps-bluetooth-bluez.c b/src/gps-bluetooth-bluez.c index fee8da2..8a1517e 100644 --- a/src/gps-bluetooth-bluez.c +++ b/src/gps-bluetooth-bluez.c @@ -25,21 +25,27 @@ #include "settings.h" #include "ui-common.h" +static gboolean scan_bluetooth_idle(ScanInfo * scan_info); + gint -scan_start_search(ScanInfo * scan_info) +scan_start_search(ScanInfo *scan_info) { scan_info->sid=g_idle_add((GSourceFunc)scan_bluetooth_idle, scan_info); return 0; } -gboolean -scan_bluetooth_idle(ScanInfo * scan_info) +static gboolean +scan_bluetooth_idle(ScanInfo *scan_info) { -gint devid, num_rsp; +gint devid, num_rsp, sock; GtkTreeIter iter; inquiry_info *ii = NULL; devid = hci_get_route(NULL); +if (devid<0) { + popup_error(scan_info->settings_dialog, _("No bluetooth adapters found.")); + return FALSE; +} ii = (inquiry_info *)malloc(255 * sizeof(inquiry_info)); num_rsp = hci_inquiry(devid, 4, 255, NULL, &ii, IREQ_CACHE_FLUSH); @@ -54,7 +60,8 @@ if (num_rsp < 0) { popup_error(scan_info->settings_dialog, _("No bluetooth devices found.")); } else { guint i; - gint sock = hci_open_dev(devid); + + sock = hci_open_dev(devid); for (i = 0; i < num_rsp; i++) { gchar addr[19] = { 0 }; gchar name[256] = { 0 }; @@ -65,9 +72,7 @@ if (num_rsp < 0) { strcpy(name, _("Unknown")); gtk_list_store_append(scan_info->store, &iter); - gtk_list_store_set(scan_info->store, &iter, - 0, g_strdup(addr), - 1, g_strdup(name), -1); + gtk_list_store_set(scan_info->store, &iter, 0, g_strdup(addr), 1, g_strdup(name), -1); } close(sock); gtk_widget_destroy(scan_info->banner);