AC_ARG_ENABLE([btdbus],AS_HELP_STRING([--enable-btdbus],[Use D-Bus bluez interface]),
[enable_btdbus=$enableval], [enable_btdbus=no])
+AC_ARG_ENABLE([bluez],AS_HELP_STRING([--enable-bluez],[Use bluez libbluetooth]),
+ [enable_bluez=$enableval], [enable_bluez=no])
+
AC_ARG_ENABLE([gpsd],AS_HELP_STRING([--enable-gpsd],[Use gpsd]),
[enable_gpsd=$enableval], [enable_gpsd=no])
AC_DEFINE([WITH_HILDON_DBUS_BT], 1, [IT D-Bus bluetooth])
fi
-PKG_CHECK_MODULES(BLUEZ, bluez, HAVE_BLUEZ=yes, HAVE_BLUEZ=no)
-if test "x$HAVE_BLUEZ" = "xyes"; then
- AC_SUBST(BLUEZ_LIBS)
- AC_SUBST(BLUEZ_CFLAGS)
- WITH_BLUEZ=yes
- AC_DEFINE([WITH_BLUEZ], 1, [Bluez RFCOMM])
+if test "x$enable_bluez" = "xno" ; then
+ WITH_BLUEZ=no
+else
+ PKG_CHECK_MODULES(BLUEZ, bluez, HAVE_BLUEZ=yes, HAVE_BLUEZ=no)
+ if test "x$HAVE_BLUEZ" = "xyes"; then
+ AC_SUBST(BLUEZ_LIBS)
+ AC_SUBST(BLUEZ_CFLAGS)
+ WITH_BLUEZ=yes
+ AC_DEFINE([WITH_BLUEZ], 1, [Bluez RFCOMM])
+ fi
fi
if test "x$enable_btdbus" = "xno" ; then
AC_DEFINE([WITH_BLUEZ_DBUS_BT], 1, [bluez D-Bus bluetooth])
fi
+AM_CONDITIONAL(HAVE_BLUEZ, [test "$enable_bluez" = "yes"])
AM_CONDITIONAL(HAVE_HILDON_DBUS_BT, [test "$enable_itbtdbus" = "yes"])
AM_CONDITIONAL(HAVE_BLUEZ_DBUS_BT, [test "$enable_btdbus" = "yes"])
AC_MSG_NOTICE([** Tablet bluetooth D-Bus support enabled])
fi
-if test x$HAVE_BLUEZ = xyes; then
+if test x$enable_bluez = xyes; then
AC_MSG_NOTICE([** Bluez support enabled])
fi
#include <config.h>
-#include <fcntl.h>
+#include <stdlib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+#include <glib-object.h>
#include "mapper.h"
+#include "bluetooth-scan.h"
#include "gps-bluetooth-bluez-marshal.h"
#include "gps.h"
#include "settings.h"
scan_cb_dev_found(DBusGProxy *object, const char *address, const unsigned int class, const int rssi, ScanInfo *scan_info)
{
GtkTreeIter iter;
+
gtk_list_store_append(scan_info->store, &iter);
-gtk_list_store_set(scan_info->store, &iter, 0, g_strdup(address), 1, g_strdup(name), -1);
+gtk_list_store_set(scan_info->store, &iter, 0, g_strdup(address), -1);
+}
+
+static void
+scan_cb_dev_name_found(DBusGProxy *object, const char *address, const char *name, ScanInfo *scan_info)
+{
+GtkTreeIter iter;
+gboolean c;
+
+c=gtk_tree_model_get_iter_first(scan_info->store, &iter);
+while (c == TRUE) {
+ gchar *value;
+
+ gtk_tree_model_get(GTK_TREE_MODEL(scan_info->store), &iter, 0, &value, -1);
+ if (g_ascii_strcasecmp(address, value) == 0) {
+ gtk_list_store_set(scan_info->store, &iter, 1, g_strdup(name), -1);
+ return;
+ }
+ c=gtk_tree_model_iter_next(GTK_TREE_MODEL(scan_info->store), &iter);
+}
+
}
static void
-scan_cb_search_complete(DBusGProxy * sig_proxy, ScanInfo * scan_info)
+scan_cb_search_complete(DBusGProxy *object, 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(object, "RemoteDeviceFound", G_CALLBACK(scan_cb_dev_found), scan_info);
+dbus_g_proxy_disconnect_signal(object, "DiscoveryCompleted", G_CALLBACK(scan_cb_search_complete), scan_info);
+dbus_g_proxy_disconnect_signal(object, "RemoteNameUpdated", G_CALLBACK(scan_cb_dev_name_found), scan_info);
}
gint
-scan_start_search(ScanInfo * scan_info)
+scan_start_search(ScanInfo *scan_info)
{
GError *error = NULL;
-if (NULL == (scan_info->req_proxy = dbus_g_proxy_new_for_name(bus, "org.bluez", "/org/bluez/hci0", "org.bluez.Adapter"))) {
+if (NULL == (scan_info->req_proxy = dbus_g_proxy_new_for_name(dbus_conn, "org.bluez", "/org/bluez/hci0", "org.bluez.Adapter"))) {
g_printerr("Failed to create D-Bus request proxy for btsearch.");
return 2;
}
-dbus_g_object_register_marshaller(marshal_VOID__STRING_UINT_INT, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID);
-
+dbus_g_object_register_marshaller(_bt_bluez_VOID__STRING_UINT_INT, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID);
dbus_g_proxy_add_signal(scan_info->req_proxy, "RemoteDeviceFound", G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID);
-dbus_g_proxy_connect_signal(scan_info->req_proxy, "RemoteDeviceFound", G_CALLBACK(scan_cb_dev_found), bus, NULL);
+dbus_g_proxy_connect_signal(scan_info->req_proxy, "RemoteDeviceFound", G_CALLBACK(scan_cb_dev_found), scan_info, NULL);
dbus_g_proxy_add_signal(scan_info->req_proxy, "DiscoveryCompleted", G_TYPE_INVALID);
-dbus_g_proxy_connect_signal(scan_info->req_proxy, "DiscoveryCompleted", G_CALLBACK(scan_cb_search_complete), bus, NULL);
+dbus_g_proxy_connect_signal(scan_info->req_proxy, "DiscoveryCompleted", G_CALLBACK(scan_cb_search_complete), scan_info, NULL);
-#if 0
-dbus_g_object_register_marshaller(marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+dbus_g_object_register_marshaller(_bt_bluez_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_add_signal(scan_info->req_proxy, "RemoteNameUpdated", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
-dbus_g_proxy_connect_signal(scan_info->req_proxy, "RemoteNameUpdated", G_CALLBACK(scan_cb_dev_found), NULL, NULL);
-#endif
+dbus_g_proxy_connect_signal(scan_info->req_proxy, "RemoteNameUpdated", G_CALLBACK(scan_cb_dev_name_found), scan_info, NULL);
error = NULL;
-if (!dbus_g_proxy_call(obj, "DiscoverDevices", &error, G_TYPE_INVALID, G_TYPE_INVALID)) {
+if (!dbus_g_proxy_call(scan_info->req_proxy, "DiscoverDevices", &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 {