From f2f0b98f9f9dee02097201ab7a7cb51f4f0262aa Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 17 Sep 2007 13:45:51 +0300 Subject: [PATCH] Fix maemo specific bluetooth D-Bus code so it works. --- src/bt-maemo.c | 26 +++++++++++++++----------- src/bt.h | 6 ++++++ src/gps-browse.c | 9 ++++++--- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/bt-maemo.c b/src/bt-maemo.c index 40a94bd..d12e2b2 100644 --- a/src/bt-maemo.c +++ b/src/bt-maemo.c @@ -4,13 +4,21 @@ #ifdef WITH_HILDON_DBUS_BT +#include + #include #include #include #include #include +#include + #include "bt-maemo-marshal.h" +#include "bt.h" +#include "gps.h" +#include "settings.h" +#include "ui-common.h" /*****************************************************************************/ @@ -19,12 +27,8 @@ 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); - -_input_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE, - G_IO_IN | G_IO_PRI, channel_cb_input, NULL, NULL); - +_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; return FALSE; } @@ -100,7 +104,7 @@ if (-1 == (_fd = open(fdpath, O_RDONLY))) { _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_IO_OUT, channel_cb_connect, NULL, NULL); } g_free(fdpath); } @@ -126,8 +130,7 @@ if (_conn_state == RCVR_DOWN && _rcvr_mac) { 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))) + if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) rcvr_connect_later(); /* Try again later. */ else set_conn_state(RCVR_OFF); @@ -195,7 +198,7 @@ void rcvr_connect_later() _clater_sid = g_timeout_add(1000, (GSourceFunc) rcvr_connect_now, NULL); } -void +static void scan_cb_dev_found(DBusGProxy * sig_proxy, const gchar * bda, const gchar * name, gpointer * class, guchar rssi, gint coff, ScanInfo * scan_info) @@ -205,7 +208,8 @@ gtk_list_store_append(scan_info->store, &iter); gtk_list_store_set(scan_info->store, &iter, 0, g_strdup(bda), 1, g_strdup(name), -1); } -void scan_cb_search_complete(DBusGProxy * sig_proxy, ScanInfo * scan_info) +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, @@ -245,7 +249,7 @@ DBusGConnection *dbus_conn; return 2; } - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING_POINTER_UCHAR_UINT, + 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); diff --git a/src/bt.h b/src/bt.h index 6463d9b..567c895 100644 --- a/src/bt.h +++ b/src/bt.h @@ -3,6 +3,8 @@ #define _GNU_SOURCE +#include + #include "utils.h" #include "mapper-types.h" @@ -34,6 +36,10 @@ struct _ScanInfo { GtkWidget *banner; GtkListStore *store; guint sid; +#ifdef WITH_HILDON_DBUS_BT + DBusGProxy *req_proxy; + DBusGProxy *sig_proxy; +#endif }; ConnState _conn_state; diff --git a/src/gps-browse.c b/src/gps-browse.c index 73e5486..b150cd0 100644 --- a/src/gps-browse.c +++ b/src/gps-browse.c @@ -18,6 +18,10 @@ #include +#ifdef WITH_HILDON_DBUS_BT +#include +#endif + #include "utils.h" #include "mapper-types.h" #include "bt.h" @@ -102,10 +106,9 @@ gboolean scan_bluetooth(GtkWidget * widget, ScanInfo * scan_info) gtk_widget_destroy(dialog); -#ifdef BT_HILDON_DBUS +#ifdef WITH_HILDON_DBUS_BT /* Clean up D-Bus. */ - dbus_g_proxy_call(scan_info->req_proxy, BTSEARCH_STOP_SEARCH_REQ, - &error, G_TYPE_INVALID, G_TYPE_INVALID); + dbus_g_proxy_call(scan_info->req_proxy, BTSEARCH_STOP_SEARCH_REQ, &error, G_TYPE_INVALID, G_TYPE_INVALID); g_object_unref(scan_info->req_proxy); g_object_unref(scan_info->sig_proxy); #endif -- 2.39.5