* [PATCH 1/5] bluetooth: move find_adapter_cb to better place.
@ 2011-02-17 22:00 Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 2/5] bluetooth: add a bluetoothd connect watch Gustavo F. Padovan
2011-02-18 0:00 ` [PATCH 1/5] bluetooth: move find_adapter_cb to better place Marcel Holtmann
0 siblings, 2 replies; 10+ messages in thread
From: Gustavo F. Padovan @ 2011-02-17 22:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2085 bytes --]
---
plugins/bluetooth.c | 52 +++++++++++++++++++++++++-------------------------
1 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 175ebaa..32be96e 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -633,6 +633,32 @@ static void add_record(gpointer data, gpointer user_data)
DBUS_TYPE_INVALID);
}
+static void find_adapter_cb(DBusPendingCall *call, gpointer user_data)
+{
+ DBusMessage *reply = dbus_pending_call_steal_reply(call);
+ DBusError derr;
+ const char *path;
+
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("Replied with an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
+ goto done;
+ }
+
+ dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+
+ adapter_any_path = g_strdup(path);
+
+ g_slist_foreach(server_list, (GFunc) add_record, NULL);
+
+done:
+ dbus_message_unref(reply);
+}
+
static gboolean adapter_added(DBusConnection *connection, DBusMessage *message,
void *user_data)
{
@@ -724,32 +750,6 @@ static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
g_hash_table_foreach(uuid_hash, bluetooth_remove_all_modem, NULL);
}
-static void find_adapter_cb(DBusPendingCall *call, gpointer user_data)
-{
- DBusMessage *reply = dbus_pending_call_steal_reply(call);
- DBusError derr;
- const char *path;
-
- dbus_error_init(&derr);
-
- if (dbus_set_error_from_message(&derr, reply)) {
- ofono_error("Replied with an error: %s, %s",
- derr.name, derr.message);
- dbus_error_free(&derr);
- goto done;
- }
-
- dbus_message_get_args(reply, NULL, DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
- adapter_any_path = g_strdup(path);
-
- g_slist_foreach(server_list, (GFunc) add_record, NULL);
-
-done:
- dbus_message_unref(reply);
-}
-
static guint bluetooth_watch;
static guint adapter_added_watch;
static guint adapter_removed_watch;
--
1.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/5] bluetooth: add a bluetoothd connect watch
2011-02-17 22:00 [PATCH 1/5] bluetooth: move find_adapter_cb to better place Gustavo F. Padovan
@ 2011-02-17 22:00 ` Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 3/5] bluetooth: change how we report DBus errors Gustavo F. Padovan
2011-02-18 0:01 ` [PATCH 2/5] bluetooth: add a bluetoothd connect watch Marcel Holtmann
2011-02-18 0:00 ` [PATCH 1/5] bluetooth: move find_adapter_cb to better place Marcel Holtmann
1 sibling, 2 replies; 10+ messages in thread
From: Gustavo F. Padovan @ 2011-02-17 22:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]
This fix a issue with sending DBus messages when bluetoothd is not up yet.
---
plugins/bluetooth.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 32be96e..8ca9f5f 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -742,6 +742,18 @@ static void bluetooth_remove_all_modem(gpointer key, gpointer value,
profile->remove_all();
}
+static void bluetooth_connect(DBusConnection *connection, void *user_data)
+{
+ bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
+ manager_properties_cb, NULL, NULL, -1,
+ DBUS_TYPE_INVALID);
+
+ bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "FindAdapter",
+ find_adapter_cb, NULL, NULL, -1,
+ DBUS_TYPE_STRING, &adapter_any_name,
+ DBUS_TYPE_INVALID);
+}
+
static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
{
if (uuid_hash == NULL)
@@ -763,7 +775,8 @@ static void bluetooth_ref(void)
connection = ofono_dbus_get_connection();
bluetooth_watch = g_dbus_add_service_watch(connection, BLUEZ_SERVICE,
- NULL, bluetooth_disconnect, NULL, NULL);
+ bluetooth_connect,
+ bluetooth_disconnect, NULL, NULL);
adapter_added_watch = g_dbus_add_signal_watch(connection, NULL, NULL,
BLUEZ_MANAGER_INTERFACE,
@@ -791,15 +804,6 @@ static void bluetooth_ref(void)
adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free);
- bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
- manager_properties_cb, NULL, NULL, -1,
- DBUS_TYPE_INVALID);
-
- bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "FindAdapter",
- find_adapter_cb, NULL, NULL, -1,
- DBUS_TYPE_STRING, &adapter_any_name,
- DBUS_TYPE_INVALID);
-
increment:
g_atomic_int_inc(&bluetooth_refcount);
--
1.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/5] bluetooth: change how we report DBus errors
2011-02-17 22:00 ` [PATCH 2/5] bluetooth: add a bluetoothd connect watch Gustavo F. Padovan
@ 2011-02-17 22:00 ` Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 4/5] bluetooth: fix crash by removing record Gustavo F. Padovan
2011-02-18 0:03 ` [PATCH 3/5] bluetooth: change how we report DBus errors Marcel Holtmann
2011-02-18 0:01 ` [PATCH 2/5] bluetooth: add a bluetoothd connect watch Marcel Holtmann
1 sibling, 2 replies; 10+ messages in thread
From: Gustavo F. Padovan @ 2011-02-17 22:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2456 bytes --]
---
plugins/bluetooth.c | 33 ++++++++++++++++++++-------------
1 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 8ca9f5f..161ae4b 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -267,19 +267,16 @@ static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
const char *device_addr = NULL;
const char *alias = NULL;
struct bluetooth_profile *profile;
+ struct DBusError derr;
reply = dbus_pending_call_steal_reply(call);
- if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
- DBG("Bluetooth daemon is apparently not available.");
- goto done;
- }
-
- if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) {
- if (!dbus_message_is_error(reply, DBUS_ERROR_UNKNOWN_METHOD))
- ofono_info("Error from GetProperties reply: %s",
- dbus_message_get_error_name(reply));
+ dbus_error_init(&derr);
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("Device.GetProperties replied an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
goto done;
}
@@ -397,14 +394,19 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
{
const char *path = user_data;
DBusMessage *reply;
+ DBusError derr;
GSList *device_list = NULL;
GSList *l;
const char *addr;
reply = dbus_pending_call_steal_reply(call);
- if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
- DBG("Bluetooth daemon is apparently not available.");
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("Adapter.GetProperties replied an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
goto done;
}
@@ -717,11 +719,16 @@ static void parse_adapters(DBusMessageIter *array, gpointer user_data)
static void manager_properties_cb(DBusPendingCall *call, gpointer user_data)
{
DBusMessage *reply;
+ DBusError derr;
reply = dbus_pending_call_steal_reply(call);
- if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
- DBG("Bluetooth daemon is apparently not available.");
+ dbus_error_init(&derr);
+
+ if (dbus_set_error_from_message(&derr, reply)) {
+ ofono_error("Manager.GetProperties() replied an error: %s, %s",
+ derr.name, derr.message);
+ dbus_error_free(&derr);
goto done;
}
--
1.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/5] bluetooth: fix crash by removing record
2011-02-17 22:00 ` [PATCH 3/5] bluetooth: change how we report DBus errors Gustavo F. Padovan
@ 2011-02-17 22:00 ` Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 5/5] bluetooth: add DBG() messages Gustavo F. Padovan
2011-02-18 0:03 ` [PATCH 4/5] bluetooth: fix crash by removing record Marcel Holtmann
2011-02-18 0:03 ` [PATCH 3/5] bluetooth: change how we report DBus errors Marcel Holtmann
1 sibling, 2 replies; 10+ messages in thread
From: Gustavo F. Padovan @ 2011-02-17 22:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]
When bluetoothd is not running we should not call RemoveRecord()
---
plugins/bluetooth.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 161ae4b..5f2d80d 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -445,6 +445,9 @@ static void remove_record(struct server *server)
{
DBusMessage *msg;
+ if (server->handle == 0)
+ return;
+
msg = dbus_message_new_method_call(BLUEZ_SERVICE, adapter_any_path,
BLUEZ_SERVICE_INTERFACE,
"RemoveRecord");
@@ -596,6 +599,13 @@ static void new_connection(GIOChannel *io, gpointer user_data)
client_event, cbd);
}
+static void remove_service_handle(gpointer data, gpointer user_data)
+{
+ struct server *server = data;
+
+ server->handle = 0;
+}
+
static void add_record_cb(DBusPendingCall *call, gpointer user_data)
{
struct server *server = user_data;
@@ -767,6 +777,8 @@ static void bluetooth_disconnect(DBusConnection *connection, void *user_data)
return;
g_hash_table_foreach(uuid_hash, bluetooth_remove_all_modem, NULL);
+
+ g_slist_foreach(server_list, (GFunc) remove_service_handle, NULL);
}
static guint bluetooth_watch;
--
1.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/5] bluetooth: add DBG() messages
2011-02-17 22:00 ` [PATCH 4/5] bluetooth: fix crash by removing record Gustavo F. Padovan
@ 2011-02-17 22:00 ` Gustavo F. Padovan
2011-02-18 0:03 ` Marcel Holtmann
2011-02-18 0:03 ` [PATCH 4/5] bluetooth: fix crash by removing record Marcel Holtmann
1 sibling, 1 reply; 10+ messages in thread
From: Gustavo F. Padovan @ 2011-02-17 22:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 795 bytes --]
---
plugins/bluetooth.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 5f2d80d..7c2d5b0 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -280,6 +280,8 @@ static void device_properties_cb(DBusPendingCall *call, gpointer user_data)
goto done;
}
+ DBG("");
+
bluetooth_parse_properties(reply, "UUIDs", has_uuid, &have_uuid,
"Adapter", parse_string, &adapter,
"Address", parse_string, &device_addr,
@@ -410,6 +412,8 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
goto done;
}
+ DBG("");
+
bluetooth_parse_properties(reply,
"Devices", parse_devices, &device_list,
"Address", parse_string, &addr,
--
1.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/5] bluetooth: move find_adapter_cb to better place.
2011-02-17 22:00 [PATCH 1/5] bluetooth: move find_adapter_cb to better place Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 2/5] bluetooth: add a bluetoothd connect watch Gustavo F. Padovan
@ 2011-02-18 0:00 ` Marcel Holtmann
1 sibling, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2011-02-18 0:00 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 204 bytes --]
Hi Gustavo,
> plugins/bluetooth.c | 52 +++++++++++++++++++++++++-------------------------
> 1 files changed, 26 insertions(+), 26 deletions(-)
patch has been applied.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/5] bluetooth: add a bluetoothd connect watch
2011-02-17 22:00 ` [PATCH 2/5] bluetooth: add a bluetoothd connect watch Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 3/5] bluetooth: change how we report DBus errors Gustavo F. Padovan
@ 2011-02-18 0:01 ` Marcel Holtmann
1 sibling, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2011-02-18 0:01 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 263 bytes --]
Hi Gustavo,
> This fix a issue with sending DBus messages when bluetoothd is not up yet.
> ---
> plugins/bluetooth.c | 24 ++++++++++++++----------
> 1 files changed, 14 insertions(+), 10 deletions(-)
patch has been applied.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/5] bluetooth: change how we report DBus errors
2011-02-17 22:00 ` [PATCH 3/5] bluetooth: change how we report DBus errors Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 4/5] bluetooth: fix crash by removing record Gustavo F. Padovan
@ 2011-02-18 0:03 ` Marcel Holtmann
1 sibling, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2011-02-18 0:03 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 187 bytes --]
Hi Gustavo,
> plugins/bluetooth.c | 33 ++++++++++++++++++++-------------
> 1 files changed, 20 insertions(+), 13 deletions(-)
patch has been applied.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 4/5] bluetooth: fix crash by removing record
2011-02-17 22:00 ` [PATCH 4/5] bluetooth: fix crash by removing record Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 5/5] bluetooth: add DBG() messages Gustavo F. Padovan
@ 2011-02-18 0:03 ` Marcel Holtmann
1 sibling, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2011-02-18 0:03 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 240 bytes --]
Hi Gustavo,
> When bluetoothd is not running we should not call RemoveRecord()
> ---
> plugins/bluetooth.c | 12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
patch has been applied.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 5/5] bluetooth: add DBG() messages
2011-02-17 22:00 ` [PATCH 5/5] bluetooth: add DBG() messages Gustavo F. Padovan
@ 2011-02-18 0:03 ` Marcel Holtmann
0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2011-02-18 0:03 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 156 bytes --]
Hi Gustavo,
> plugins/bluetooth.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
patch has been applied.
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-02-18 0:03 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-17 22:00 [PATCH 1/5] bluetooth: move find_adapter_cb to better place Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 2/5] bluetooth: add a bluetoothd connect watch Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 3/5] bluetooth: change how we report DBus errors Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 4/5] bluetooth: fix crash by removing record Gustavo F. Padovan
2011-02-17 22:00 ` [PATCH 5/5] bluetooth: add DBG() messages Gustavo F. Padovan
2011-02-18 0:03 ` Marcel Holtmann
2011-02-18 0:03 ` [PATCH 4/5] bluetooth: fix crash by removing record Marcel Holtmann
2011-02-18 0:03 ` [PATCH 3/5] bluetooth: change how we report DBus errors Marcel Holtmann
2011-02-18 0:01 ` [PATCH 2/5] bluetooth: add a bluetoothd connect watch Marcel Holtmann
2011-02-18 0:00 ` [PATCH 1/5] bluetooth: move find_adapter_cb to better place Marcel Holtmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox