]> err.no Git - mapper/commitdiff
GpsBluez: cleanups
authorKaj-Michael Lang <milang@tal.org>
Thu, 15 May 2008 15:54:55 +0000 (18:54 +0300)
committerKaj-Michael Lang <milang@tal.org>
Thu, 15 May 2008 15:54:55 +0000 (18:54 +0300)
src/gps-bluetooth-bluez.c

index fee8da239c6647ede13d910bf056988ac2acb7b2..8a1517e5deb61383333d9984ef9c8a408410c1b8 100644 (file)
 #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);