2 * This file is part of mapper
4 * Copyright (C) 2007 Kaj-Michael Lang
5 * Copyright (C) 2006-2007 John Costigan.
7 * POI and GPS-Info code originally written by Cezary Jackiewicz.
9 * Default map data provided by http://www.openstreetmap.org/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 /* Let this header handle all ifdefs */
31 #include "hildon-mapper.h"
34 #include "gps-bluetooth-maemo-marshal.h"
37 #include "ui-common.h"
39 #include "bluetooth-scan.h"
42 * Bluetooth device scanning functions below
45 scan_cb_dev_found(DBusGProxy *sig_proxy, const gchar *bda, const gchar *name, gpointer *class, guchar rssi, gint coff, ScanInfo *scan_info)
48 gtk_list_store_append(scan_info->store, &iter);
49 gtk_list_store_set(scan_info->store, &iter, 0, g_strdup(bda), 1, g_strdup(name), -1);
53 scan_cb_search_complete(DBusGProxy * sig_proxy, ScanInfo * scan_info)
55 gtk_widget_destroy(scan_info->banner);
56 dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_DEV_FOUND_SIG, G_CALLBACK(scan_cb_dev_found), scan_info);
57 dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG, G_CALLBACK(scan_cb_search_complete), scan_info);
61 * Request bluetooth device scan
64 scan_start_search(ScanInfo * scan_info)
68 if (NULL == (scan_info->req_proxy = dbus_g_proxy_new_for_name(dbus_conn, BTSEARCH_SERVICE, BTSEARCH_REQ_PATH, BTSEARCH_REQ_INTERFACE))) {
69 g_printerr("Failed to create D-Bus request proxy for btsearch.");
73 if (NULL == (scan_info->sig_proxy = dbus_g_proxy_new_for_name(dbus_conn, BTSEARCH_SERVICE, BTSEARCH_SIG_PATH, BTSEARCH_SIG_INTERFACE))) {
74 g_printerr("Failed to create D-Bus signal proxy for btsearch.");
78 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);
80 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);
81 dbus_g_proxy_connect_signal(scan_info->sig_proxy, BTSEARCH_DEV_FOUND_SIG, G_CALLBACK(scan_cb_dev_found), scan_info, NULL);
83 dbus_g_proxy_add_signal(scan_info->sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG, G_TYPE_INVALID);
84 dbus_g_proxy_connect_signal(scan_info->sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG, G_CALLBACK(scan_cb_search_complete), scan_info, NULL);
87 if (!dbus_g_proxy_call(scan_info->req_proxy, BTSEARCH_START_SEARCH_REQ, &error, G_TYPE_INVALID, G_TYPE_INVALID)) {
88 if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
89 g_printerr("Caught remote method exception %s: %s", dbus_g_error_get_name(error), error->message);
91 g_printerr("Error: %s\n", error->message);