]> err.no Git - mapper/commitdiff
GPS Connection handlings code cleanups
authorKaj-Michael Lang <milang@angel.tal.org>
Sun, 28 Oct 2007 10:11:08 +0000 (12:11 +0200)
committerKaj-Michael Lang <milang@angel.tal.org>
Sun, 28 Oct 2007 10:11:08 +0000 (12:11 +0200)
src/bt-bluez.c
src/bt-maemo.c
src/cb.c
src/gps-conn.c
src/gps-nmea-parse.c
src/gps.h
src/maemo-osso.c
src/ui-common.c

index f1cd511090093c65a4ef58740806109ab5e1d214..33db0fa453dec7bff59718cea0879bc72fcecaa9 100644 (file)
 
 struct sockaddr_rc _rcvr_addr = { 0 };
 
+static gint fd;
+
 static gboolean
 channel_cb_connect(GIOChannel * src, GIOCondition condition, gpointer data)
 {
 gint error, size = sizeof(error);
 
-if (*_rcvr_mac != '/' && (getsockopt(_fd, SOL_SOCKET, SO_ERROR, &error, &size) || error)) {
+if (*_rcvr_mac != '/' && (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &size) || error)) {
        g_printf("Error connecting to receiver; retrying...\n");
        /* Try again. */
        rcvr_disconnect();
        rcvr_connect_later();
 } else {
        g_printf("Connected to receiver!\n");
-       set_conn_state(RCVR_UP);
-       _input_sid = g_io_add_watch_full(_channel, G_PRIORITY_LOW,
-                                       G_IO_IN | G_IO_PRI,
-                                       channel_cb_input, NULL, NULL);
+       gps_conn_set_state(RCVR_UP);
+       _input_sid = g_io_add_watch_full(_channel, G_PRIORITY_LOW, G_IO_IN | G_IO_PRI, channel_cb_input, NULL, NULL);
 }
 
 _connect_sid = 0;
@@ -62,7 +62,7 @@ static gboolean
 rcvr_connect_bt(void)
 {
 int r, e;
-r = connect(_fd, (struct sockaddr *)&_rcvr_addr, sizeof(_rcvr_addr));
+r = connect(fd, (struct sockaddr *)&_rcvr_addr, sizeof(_rcvr_addr));
 e = errno;
 
 /* The socket is non blocking so handle it */
@@ -101,7 +101,7 @@ return TRUE;
 gint 
 scan_start_search(ScanInfo * scan_info)
 {
-scan_info->sid = g_idle_add((GSourceFunc) scan_bluetooth_idle, scan_info);
+scan_info->sid = g_idle_add((GSourceFunc)scan_bluetooth_idle, scan_info);
 return 0;
 }
 
@@ -138,15 +138,15 @@ if (_channel) {
 }
 
 /* Close the file descriptor. */
-if (_fd != -1) {
-       close(_fd);
-       _fd = -1;
+if (fd != -1) {
+       close(fd);
+       fd = -1;
 }
 }
 
 /**
  * Connect to the receiver.
- * This method assumes that _fd is -1 and _channel is NULL.  If unsure, call
+ * This method assumes that fd is -1 and _channel is NULL.  If unsure, call
  * rcvr_disconnect() first.
  * Since this is an idle function, this function returns whether or not it
  * should be called again, which is always FALSE.
@@ -171,15 +171,15 @@ if (_conn_state == RCVR_DOWN && _rcvr_mac) {
 #ifndef DEBUG_GPS
        /* Create the file descriptor. */
        if (*_rcvr_mac == '/')
-               _fd = open(_rcvr_mac, O_RDONLY);
+               fd = open(_rcvr_mac, O_RDONLY);
        else
-               _fd = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
+               fd = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
 
        /* If file descriptor creation failed, try again later.  Note that
         * there is no need to call rcvr_disconnect() because the file
         * descriptor creation is the first step, so if it fails, there's
         * nothing to clean up. */
-       if (_fd == -1) {
+       if (fd == -1) {
                g_printf("Failed to create socket\n");
                rcvr_connect_later();
        } else {
@@ -189,7 +189,7 @@ if (_conn_state == RCVR_DOWN && _rcvr_mac) {
                _gps_read_buf_last = _gps_read_buf + GPS_READ_BUF_SIZE - 1;
 
                /* Create channel and add watches. */
-               _channel = g_io_channel_unix_new(_fd);
+               _channel = g_io_channel_unix_new(fd);
                g_io_channel_set_encoding(_channel, NULL, NULL);
                g_io_channel_set_flags(_channel, G_IO_FLAG_NONBLOCK, NULL);
                _error_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE,
@@ -204,7 +204,7 @@ if (_conn_state == RCVR_DOWN && _rcvr_mac) {
        }
 #else
        /* We're in DEBUG mode, so instead of connecting, skip to FIXED. */
-       set_conn_state(RCVR_FIXED);
+       gps_conn_set_state(RCVR_FIXED);
 #endif
 }
 
@@ -230,7 +230,7 @@ inquiry_info *ii = NULL;
 
 devid = hci_get_route(NULL);
 
-ii = (inquiry_info *) malloc(255 * sizeof(inquiry_info));
+ii = (inquiry_info *)malloc(255 * sizeof(inquiry_info));
 num_rsp = hci_inquiry(devid, 4, 255, NULL, &ii, IREQ_CACHE_FLUSH);
 
 if (num_rsp < 0) {
@@ -250,8 +250,7 @@ if (num_rsp < 0) {
 
                ba2str(&ii[i].bdaddr, addr);
                memset(name, 0, sizeof(name));
-               if (hci_read_remote_name
-                   (sock, &ii[i].bdaddr, sizeof(name), name, 0))
+               if (hci_read_remote_name(sock, &ii[i].bdaddr, sizeof(name), name, 0))
                        strcpy(name, _("Unknown"));
 
                gtk_list_store_append(scan_info->store, &iter);
index 59bf49b4412a20f0d4e76ca79e80ad5903b45caf..ce76efdeb94d59677323827666e63efccaaf97f8 100644 (file)
 #include "settings.h"
 #include "ui-common.h"
 
+static guint errors;
+static gint fd;
+
+void rcvr_connect_later();     /* Forward declaration. */
+
 /*****************************************************************************/
 
 static gboolean
@@ -22,9 +27,10 @@ channel_cb_connect(GIOChannel * src, GIOCondition condition, gpointer data)
 {
 _gps_read_buf_curr = _gps_read_buf;
 _gps_read_buf_last = _gps_read_buf + GPS_READ_BUF_SIZE - 1;
-set_conn_state(RCVR_UP);
+gps_conn_set_state(RCVR_UP);
 _input_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE, G_IO_IN | G_IO_PRI, channel_cb_input, NULL, NULL);
 _connect_sid = 0;
+errors=0;
 return FALSE;
 }
 
@@ -63,31 +69,29 @@ if (_channel) {
 }
 
 /* Close the file descriptor. */
-if (_fd != -1) {
-       close(_fd);
-       _fd = -1;
+if (fd != -1) {
+       close(fd);
+       fd = -1;
 }
 
 if (_rfcomm_req_proxy) {
        dbus_g_proxy_call(_rfcomm_req_proxy,
-                         BTCOND_RFCOMM_CANCEL_CONNECT_REQ, &error,
-                         G_TYPE_STRING, _rcvr_mac, G_TYPE_STRING,
-                         "SPP", G_TYPE_INVALID, G_TYPE_INVALID);
+                       BTCOND_RFCOMM_CANCEL_CONNECT_REQ, &error,
+                       G_TYPE_STRING, _rcvr_mac, G_TYPE_STRING,
+                       "SPP", G_TYPE_INVALID, G_TYPE_INVALID);
        error = NULL;
        dbus_g_proxy_call(_rfcomm_req_proxy,
-                         BTCOND_RFCOMM_DISCONNECT_REQ, &error,
-                         G_TYPE_STRING, _rcvr_mac, G_TYPE_STRING,
-                         "SPP", G_TYPE_INVALID, G_TYPE_INVALID);
+                       BTCOND_RFCOMM_DISCONNECT_REQ, &error,
+                       G_TYPE_STRING, _rcvr_mac, G_TYPE_STRING,
+                       "SPP", G_TYPE_INVALID, G_TYPE_INVALID);
 }
 }
 
-void rcvr_connect_later();     /* Forward declaration. */
-
 void 
-rcvr_connect_fd(gchar * fdpath)
+rcvr_connect_fd(gchar *fdpath)
 {
 /* If file descriptor creation failed, try again later. */
-if (-1 == (_fd = open(fdpath, O_RDONLY))) {
+if (-1 == (fd = open(fdpath, O_RDONLY))) {
        rcvr_disconnect();
        rcvr_connect_later();
 } else {
@@ -96,24 +100,22 @@ if (-1 == (_fd = open(fdpath, O_RDONLY))) {
        *_gps_read_buf_curr = '\0';
 
        /* Create channel and add watches. */
-       _channel = g_io_channel_unix_new(_fd);
+       _channel = g_io_channel_unix_new(fd);
        g_io_channel_set_flags(_channel, G_IO_FLAG_NONBLOCK, NULL);
-       _error_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE,
-               G_IO_ERR | G_IO_HUP, channel_cb_error, NULL, NULL);
-       _connect_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE,
-               G_IO_OUT, channel_cb_connect, NULL, NULL);
-       }
+       _error_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE, G_IO_ERR | G_IO_HUP, channel_cb_error, NULL, NULL);
+       _connect_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE, G_IO_OUT, channel_cb_connect, NULL, NULL);
+}
 g_free(fdpath);
 }
 
-void rcvr_connect_response(DBusGProxy * proxy, DBusGProxyCall * call_id)
+void 
+rcvr_connect_response(DBusGProxy * proxy, DBusGProxyCall * call_id)
 {
 GError *error = NULL;
 gchar *fdpath = NULL;
 
 if (_conn_state == RCVR_DOWN && _rcvr_mac) {
-       if (!dbus_g_proxy_end_call(_rfcomm_req_proxy, call_id, &error,
-                                  G_TYPE_STRING, &fdpath, G_TYPE_INVALID)) {
+       if (!dbus_g_proxy_end_call(_rfcomm_req_proxy, call_id, &error, G_TYPE_STRING, &fdpath, G_TYPE_INVALID)) {
                if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
                        /* If we're already connected, it's not an error, unless
                         * they don't give us the file descriptor path, in which
@@ -124,13 +126,12 @@ if (_conn_state == RCVR_DOWN && _rcvr_mac) {
                                rcvr_disconnect();
 
                                /* Ask user to re-connect. */
-                               confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
-                                            _("Failed to connect to GPS receiver.  Retry?"));
+                               confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), _("Failed to connect to GPS receiver. Retry?"));
 
                                if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm)))
                                        rcvr_connect_later();   /* Try again later. */
                                else
-                                       set_conn_state(RCVR_OFF);
+                                       gps_conn_set_state(RCVR_OFF);
 
                                gtk_widget_destroy(confirm);
                                return;
@@ -150,15 +151,16 @@ if (_conn_state == RCVR_DOWN && _rcvr_mac) {
 
 /**
  * Connect to the receiver.
- * This method assumes that _fd is -1 and _channel is NULL.  If unsure, call
+ * This method assumes that fd is -1 and _channel is NULL.  If unsure, call
  * rcvr_disconnect() first.
  * Since this is an idle function, this function returns whether or not it
  * should be called again, which is always FALSE.
  */
-gboolean rcvr_connect_now()
+gboolean 
+rcvr_connect_now()
 {
 if (_conn_state == RCVR_DOWN && _rcvr_mac) {
-#ifndef DEBUG
+#ifndef DEBUG_GPS
        if (*_rcvr_mac != '/') {
                if (_rfcomm_req_proxy) {
                        gint mybool = TRUE;
@@ -173,13 +175,13 @@ if (_conn_state == RCVR_DOWN && _rcvr_mac) {
                                                G_TYPE_BOOLEAN, &mybool,
                                                G_TYPE_INVALID);
                }
-       } else
+       } else {
                rcvr_connect_fd(g_strdup(_rcvr_mac));
-
+       }
 #else
        /* We're in DEBUG mode, so instead of connecting, skip to FIXED. */
        printf("FIXED!\n");
-       set_conn_state(RCVR_FIXED);
+       gps_conn_set_state(RCVR_FIXED);
 #endif
 }
 
@@ -193,13 +195,14 @@ return FALSE;
 void 
 rcvr_connect_later()
 {
-_clater_sid = g_timeout_add(1000, (GSourceFunc) rcvr_connect_now, NULL);
+_clater_sid = g_timeout_add(1000, (GSourceFunc)rcvr_connect_now, NULL);
 }
 
+/**
+ * Bluetooth device scanning functions below
+ */
 static void
-scan_cb_dev_found(DBusGProxy * sig_proxy, const gchar * bda,
-                 const gchar * name, gpointer * class, guchar rssi, gint coff,
-                 ScanInfo * scan_info)
+scan_cb_dev_found(DBusGProxy *sig_proxy, const gchar *bda, const gchar *name, gpointer *class, guchar rssi, gint coff, ScanInfo *scan_info)
 {
 GtkTreeIter iter;
 gtk_list_store_append(scan_info->store, &iter);
@@ -210,75 +213,43 @@ static void
 scan_cb_search_complete(DBusGProxy * sig_proxy, ScanInfo * scan_info)
 {
 gtk_widget_destroy(scan_info->banner);
-dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_DEV_FOUND_SIG,
-                      G_CALLBACK(scan_cb_dev_found), scan_info);
-dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG,
-                      G_CALLBACK(scan_cb_search_complete), scan_info);
+dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_DEV_FOUND_SIG, G_CALLBACK(scan_cb_dev_found), scan_info);
+dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG, G_CALLBACK(scan_cb_search_complete), scan_info);
 }
 
 gint 
 scan_start_search(ScanInfo * scan_info)
 {
 GError *error = NULL;
-DBusGConnection *dbus_conn;
 
-       /* Initialize D-Bus. */
-       if (NULL == (dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) {
-               g_printerr("Failed to open connection to D-Bus: %s.\n",
-                          error->message);
-               return 1;
-       }
+if (NULL == (scan_info->req_proxy = dbus_g_proxy_new_for_name(dbus_conn, BTSEARCH_SERVICE, BTSEARCH_REQ_PATH, BTSEARCH_REQ_INTERFACE))) {
+       g_printerr("Failed to create D-Bus request proxy for btsearch.");
+       return 2;
+}
 
-       if (NULL == (scan_info->req_proxy = dbus_g_proxy_new_for_name(dbus_conn,
-                                                                     BTSEARCH_SERVICE,
-                                                                     BTSEARCH_REQ_PATH,
-                                                                     BTSEARCH_REQ_INTERFACE)))
-       {
-               g_printerr
-                   ("Failed to create D-Bus request proxy for btsearch.");
-               return 2;
-       }
+if (NULL == (scan_info->sig_proxy = dbus_g_proxy_new_for_name(dbus_conn, BTSEARCH_SERVICE, BTSEARCH_SIG_PATH, BTSEARCH_SIG_INTERFACE))) {
+       g_printerr("Failed to create D-Bus signal proxy for btsearch.");
+       return 2;
+}
 
-       if (NULL == (scan_info->sig_proxy = dbus_g_proxy_new_for_name(dbus_conn,
-                                                                     BTSEARCH_SERVICE,
-                                                                     BTSEARCH_SIG_PATH,
-                                                                     BTSEARCH_SIG_INTERFACE)))
-       {
-               g_printerr("Failed to create D-Bus signal proxy for btsearch.");
-               return 2;
-       }
+dbus_g_object_register_marshaller(_bt_maemo_VOID__STRING_STRING_POINTER_UCHAR_UINT,
+     G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UCHAR, G_TYPE_UINT, G_TYPE_INVALID);
 
-       dbus_g_object_register_marshaller(_bt_maemo_VOID__STRING_STRING_POINTER_UCHAR_UINT,
-            G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, DBUS_TYPE_G_UCHAR_ARRAY,
-            G_TYPE_UCHAR, G_TYPE_UINT, G_TYPE_INVALID);
-
-       dbus_g_proxy_add_signal(scan_info->sig_proxy,
-                               BTSEARCH_DEV_FOUND_SIG,
-                               G_TYPE_STRING,
-                               G_TYPE_STRING,
-                               DBUS_TYPE_G_UCHAR_ARRAY,
-                               G_TYPE_UCHAR, G_TYPE_UINT, G_TYPE_INVALID);
-       dbus_g_proxy_connect_signal(scan_info->sig_proxy, BTSEARCH_DEV_FOUND_SIG,
-                                   G_CALLBACK(scan_cb_dev_found), scan_info,
-                                   NULL);
-
-       dbus_g_proxy_add_signal(scan_info->sig_proxy,
-                               BTSEARCH_SEARCH_COMPLETE_SIG, G_TYPE_INVALID);
-       dbus_g_proxy_connect_signal(scan_info->sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG,
-                                   G_CALLBACK(scan_cb_search_complete),
-                                   scan_info, NULL);
+dbus_g_proxy_add_signal(scan_info->sig_proxy, BTSEARCH_DEV_FOUND_SIG, G_TYPE_STRING, G_TYPE_STRING, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UCHAR, G_TYPE_UINT, G_TYPE_INVALID);
+dbus_g_proxy_connect_signal(scan_info->sig_proxy, BTSEARCH_DEV_FOUND_SIG, G_CALLBACK(scan_cb_dev_found), scan_info, NULL);
 
-       error = NULL;
-       if (!dbus_g_proxy_call(scan_info->req_proxy, BTSEARCH_START_SEARCH_REQ,
-                              &error, G_TYPE_INVALID, G_TYPE_INVALID)) {
-               if (error->domain == DBUS_GERROR
-                   && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
-                       g_printerr("Caught remote method exception %s: %s",
-                                  dbus_g_error_get_name(error), error->message);
-               } else
-                       g_printerr("Error: %s\n", error->message);
-               return 3;
+dbus_g_proxy_add_signal(scan_info->sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG, G_TYPE_INVALID);
+dbus_g_proxy_connect_signal(scan_info->sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG, G_CALLBACK(scan_cb_search_complete), scan_info, NULL);
+
+error = NULL;
+if (!dbus_g_proxy_call(scan_info->req_proxy, BTSEARCH_START_SEARCH_REQ, &error, G_TYPE_INVALID, G_TYPE_INVALID)) {
+       if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
+               g_printerr("Caught remote method exception %s: %s", dbus_g_error_get_name(error), error->message);
+       } else {
+               g_printerr("Error: %s\n", error->message);
        }
+       return 3;
+}
 
 return 0;
 }
index b7ba0c44320ffd8c1ba998d020a747babc36f6b8..b92a605e5c0df75cdfa060978fe663ce4fe7788e 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
@@ -33,7 +33,7 @@
 #include "latlon.h"
 #include "cb.h"
 #include "gps-panels.h"
-
+#include "gps-conn.h"
 #include "help.h"
 
 gboolean 
@@ -479,7 +479,7 @@ menu_cb_enable_gps(GtkAction * action)
 {
 if ((_enable_gps = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))) {
        if (_rcvr_mac) {
-               set_conn_state(RCVR_DOWN);
+               gps_conn_set_state(RCVR_DOWN);
                rcvr_connect_now();
        } else {
                popup_error(_window, _("Cannot enable GPS until a GPS Receiver MAC is set in the Settings dialog box."));
@@ -487,7 +487,7 @@ if ((_enable_gps = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))) {
        }
 } else {
        if (_conn_state > RCVR_OFF)
-               set_conn_state(RCVR_OFF);
+               gps_conn_set_state(RCVR_OFF);
        rcvr_disconnect();
        track_add(0, FALSE);
        _speed_excess=FALSE;
@@ -528,7 +528,7 @@ menu_cb_settings(GtkAction * action)
 if (settings_dialog()) {
        /* Settings have changed - reconnect to receiver. */
        if (_enable_gps) {
-               set_conn_state(RCVR_DOWN);
+               gps_conn_set_state(RCVR_DOWN);
                rcvr_disconnect();
                rcvr_connect_now();
        }
index 1c177e0af7aed4b778910c21cf331703619c6c9c..34865ae31a1071448b267a3bd28d96d0aee872b4 100644 (file)
@@ -25,48 +25,48 @@ static GtkWidget *fix_banner = NULL;
 #include "map.h"
 #include "bt.h"
 #include "ui-common.h"
+#include "gps-conn.h"
 
 /**
- * Set the connection state.  This function controls all connection-related
- * banners.
+ * Set the connection state. This function controls all connection-related banners.
  */
 void 
-set_conn_state(ConnState new_conn_state)
+gps_conn_set_state(ConnState new_conn_state)
 {
 switch (_conn_state = new_conn_state) {
        case RCVR_OFF:
        case RCVR_FIXED:
                if (connect_banner) {
                        gtk_widget_destroy(connect_banner);
-                       connect_banner = NULL;
+                       connect_banner=NULL;
                }
                if (fix_banner) {
                        gtk_widget_destroy(fix_banner);
-                       fix_banner = NULL;
+                       fix_banner=NULL;
                }
                break;
        case RCVR_DOWN:
                if (fix_banner) {
                        gtk_widget_destroy(fix_banner);
-                       fix_banner = NULL;
+                       fix_banner=NULL;
                }
                if (!connect_banner)
-                       connect_banner = hildon_banner_show_animation(_window, NULL, _("Searching for GPS receiver"));
+                       connect_banner=hildon_banner_show_animation(_window, NULL, _("Searching for GPS receiver"));
                break;
        case RCVR_UP:
                if (connect_banner) {
                        gtk_widget_destroy(connect_banner);
-                       connect_banner = NULL;
+                       connect_banner=NULL;
                }
                if (!fix_banner)
-                       fix_banner = hildon_banner_show_progress(_window, NULL, _("Establishing GPS fix"));
+                       fix_banner=hildon_banner_show_progress(_window, NULL, _("Establishing GPS fix"));
                break;
        default:;               /* to quell warning. */
 }
 }
 
 void
-set_fix_progress(gdouble fix)
+gps_conn_set_progress(gdouble fix)
 {
 #ifdef WITH_HILDON
 hildon_banner_set_fraction(fix_banner, fix);
index 6e2300b4778e9ada66ef3c18c9d799e32766e295..3bf75a61b84fac3829933002ced7a663a8663269 100644 (file)
 #include "route.h"
 #include "gps-panels.h"
 #include "settings.h"
-
+#include "gps-conn.h"
 #include "gtkgps.h"
 #include "gtkcompass.h"
 
+
 #define GPS_FILTER_MAX_SKIP (10)
 static gint track_drop_cnt=0;
 
 gboolean
 channel_cb_error(GIOChannel * src, GIOCondition condition, gpointer data)
 {
-       printf("%s(%d)\n", __PRETTY_FUNCTION__, condition);
-
-       /* An error has occurred - re-connect(). */
-       rcvr_disconnect();
-       track_add(0, FALSE);
-       _speed_excess = FALSE;
-
-       if (_conn_state > RCVR_OFF) {
-               set_conn_state(RCVR_DOWN);
-               gps_hide_text();
-               rcvr_connect_later();
-       }
+/* An error has occurred - re-connect(). */
+rcvr_disconnect();
+track_add(0, FALSE);
+_speed_excess = FALSE;
+
+if (_conn_state > RCVR_OFF) {
+       gps_conn_set_state(RCVR_DOWN);
+       gps_hide_text();
+       rcvr_connect_later();
+}
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return FALSE;
+return FALSE;
 }
 
 static void 
@@ -89,12 +87,12 @@ channel_parse_rmc(gchar * sentence)
                /* Data is valid. */
                if (_conn_state != RCVR_FIXED) {
                        newly_fixed = TRUE;
-                       set_conn_state(RCVR_FIXED);
+                       gps_conn_set_state(RCVR_FIXED);
                }
        } else {
                /* Data is invalid - not enough satellites?. */
                if (_conn_state != RCVR_UP) {
-                       set_conn_state(RCVR_UP);
+                       gps_conn_set_state(RCVR_UP);
                        track_add(0, FALSE);
                }
        }
@@ -402,7 +400,7 @@ channel_parse_gsv(gchar * sentence)
                        if (_conn_state == RCVR_UP) {
                                gdouble fraction = running_total * sqrt(num_sats_used) / num_sats_used / 100.0;
                                BOUND(fraction, 0.0, 1.0);
-                               set_fix_progress(fraction);
+                               gps_conn_set_progress(fraction);
                        }
                        running_total = 0;
                        num_sats_used = 0;
index 607f740818354a920abdf73cc83163909ecc0e46..fae11db8d868a0c51062de7d464baad51be7c8f7 100644 (file)
--- a/src/gps.h
+++ b/src/gps.h
 
 #define GPS_READ_BUF_SIZE 1024
 
-/** The file descriptor of our connection with the GPS receiver. */
-gint _fd;
 gchar _gps_read_buf[GPS_READ_BUF_SIZE];
 gchar *_gps_read_buf_curr;
 gchar *_gps_read_buf_last;
+
 DBusGProxy *_rfcomm_req_proxy;
 
 /** The GIOChannel through which communication with the GPS receiver is
index 68058ee2a3293bcc48d3cf5f743dd9db7c3329de..7e2b57e747a8f5992cd14ba4bb62c162746f7c00 100644 (file)
@@ -50,7 +50,7 @@ if (state->system_inactivity_ind) {
                if (_conn_state > RCVR_OFF) {
                        if (gconf_client_get_bool(gconf_client, GCONF_KEY_DISCONNECT_ON_COVER, NULL)) {
                                gconf_client_clear_cache(gconf_client);
-                               set_conn_state(RCVR_OFF);
+                               gps_conn_set_state(RCVR_OFF);
                                rcvr_disconnect();
                                track_add(0, FALSE);
                                /* Pretend autoroute is in progress to avoid download. */
@@ -70,7 +70,7 @@ if (state->system_inactivity_ind) {
        /* Drop any memory we can.. */
 } else {
        if (_conn_state == RCVR_OFF && _enable_gps) {
-               set_conn_state(RCVR_DOWN);
+               gps_conn_set_state(RCVR_DOWN);
                rcvr_connect_later();
                if (_autoroute_data.enabled)
                        _autoroute_data.in_progress = TRUE;
index fa7fcd452cd0b0218b84a73a7fe059e54103edbb..98a2a92e62bb98a9064b24aa73f1834473c7d627 100644 (file)
@@ -423,8 +423,8 @@ if (done_here) {
        /* Re-enable any banners that might have been up. */
        {
                ConnState old_state = _conn_state;
-               set_conn_state(RCVR_OFF);
-               set_conn_state(old_state);
+               gps_conn_set_state(RCVR_OFF);
+               gps_conn_set_state(old_state);
        }
 }