Re: [PATCH 04/13] dundee: Initial GDBusClient for BlueZ 5

2013-03-11 Thread Daniel Wagner

Hi Paulo,

On 03/04/2013 08:33 PM, Paulo Borges wrote:

This patch adds the callbacks to track additions and removals of
BlueZ related interfaces and property changes in these interfaces.
---
  dundee/bluez5.c |   60 +++
  dundee/dundee.h |2 ++
  2 files changed, 62 insertions(+)

diff --git a/dundee/bluez5.c b/dundee/bluez5.c
index 6685b4c..40df700 100644
--- a/dundee/bluez5.c
+++ b/dundee/bluez5.c
@@ -22,16 +22,76 @@
  #include 
  #endif

+#include 
+#include 
+#include 
+
  #include "dundee.h"
+#include "plugins/bluez5.h"
+
+#define DUN_DT_PROFILE_PATH   "/bluetooth/profile/dun_dt"
+
+static GDBusClient *bluez;
+
+static void proxy_added(GDBusProxy *proxy, void *user_data)
+{
+   const char *path = g_dbus_proxy_get_path(proxy);
+   const char *interface = g_dbus_proxy_get_interface(proxy);
+
+   if (g_str_equal(BLUEZ_DEVICE_INTERFACE, interface) == FALSE)
+   return;


In oFono, just use let the '== FALSE' part away. The same applies for 
the rest of the series.



cheers,
daniel
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 04/13] dundee: Initial GDBusClient for BlueZ 5

2013-03-04 Thread Paulo Borges
This patch adds the callbacks to track additions and removals of
BlueZ related interfaces and property changes in these interfaces.
---
 dundee/bluez5.c |   60 +++
 dundee/dundee.h |2 ++
 2 files changed, 62 insertions(+)

diff --git a/dundee/bluez5.c b/dundee/bluez5.c
index 6685b4c..40df700 100644
--- a/dundee/bluez5.c
+++ b/dundee/bluez5.c
@@ -22,16 +22,76 @@
 #include 
 #endif
 
+#include 
+#include 
+#include 
+
 #include "dundee.h"
+#include "plugins/bluez5.h"
+
+#define DUN_DT_PROFILE_PATH   "/bluetooth/profile/dun_dt"
+
+static GDBusClient *bluez;
+
+static void proxy_added(GDBusProxy *proxy, void *user_data)
+{
+   const char *path = g_dbus_proxy_get_path(proxy);
+   const char *interface = g_dbus_proxy_get_interface(proxy);
+
+   if (g_str_equal(BLUEZ_DEVICE_INTERFACE, interface) == FALSE)
+   return;
+
+   DBG("%s %s", path, interface);
+}
+
+static void proxy_removed(GDBusProxy *proxy, void *user_data)
+{
+   const char *path = g_dbus_proxy_get_path(proxy);
+   const char *interface = g_dbus_proxy_get_interface(proxy);
+
+   if (g_str_equal(BLUEZ_DEVICE_INTERFACE, interface) == FALSE)
+   return;
+
+   DBG("%s %s", path, interface);
+}
+
+static void property_changed(GDBusProxy *proxy, const char *name,
+   DBusMessageIter *iter, void *user_data)
+{
+   const char *path = g_dbus_proxy_get_path(proxy);
+   const char *interface = g_dbus_proxy_get_interface(proxy);
+
+   if (g_str_equal(BLUEZ_DEVICE_INTERFACE, interface) == FALSE)
+   return;
+
+   DBG("%s %s.%s", path, interface, name);
+}
+
+static void connect_handler(DBusConnection *conn, void *user_data)
+{
+   DBG("");
+
+   bt_register_profile_with_role(conn, DUN_UUID, DUN_VERSION_1_2,
+   "dun_dt", DUN_DT_PROFILE_PATH, "client");
+}
 
 int __dundee_bluetooth_init(void)
 {
+   DBusConnection *conn = ofono_dbus_get_connection();
+
DBG("");
 
+   bluez = g_dbus_client_new(conn, BLUEZ_SERVICE, BLUEZ_MANAGER_PATH);
+   g_dbus_client_set_connect_watch(bluez, connect_handler, NULL);
+   g_dbus_client_set_proxy_handlers(bluez, proxy_added, proxy_removed,
+   property_changed, NULL);
+
return 0;
 }
 
 void __dundee_bluetooth_cleanup(void)
 {
DBG("");
+
+   g_dbus_client_unref(bluez);
 }
diff --git a/dundee/dundee.h b/dundee/dundee.h
index db932b6..daf78a5 100644
--- a/dundee/dundee.h
+++ b/dundee/dundee.h
@@ -26,6 +26,8 @@
 
 #include 
 
+#define DUN_VERSION_1_2 0x0102
+
 void __dundee_exit(void);
 
 enum dundee_error_type {
-- 
1.7.9.5

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono