This patch adds the parsing of the mandatory arguments in NewConnection
method call implemented in Profile1 interface.
---
 plugins/bluetooth.h |  1 +
 plugins/hfp_hf.c    | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 96f3a53..a9355f6 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -24,6 +24,7 @@
 
 #define        BLUEZ_SERVICE "org.bluez"
 #define        BLUEZ_MANAGER_INTERFACE         BLUEZ_SERVICE ".Manager"
+#define        BLUEZ_ERROR_INTERFACE           BLUEZ_SERVICE ".Error"
 #define BLUEZ_PROFILE_MGMT_INTERFACE   BLUEZ_SERVICE ".ProfileManager1"
 #define        BLUEZ_PROFILE_INTERFACE         BLUEZ_SERVICE ".Profile1"
 #define        BLUEZ_ADAPTER_INTERFACE         BLUEZ_SERVICE ".Adapter"
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 405ada2..edb7671 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -342,8 +342,41 @@ static int hfp_unregister_ofono_handsfree(struct 
ofono_modem *modem)
 static DBusMessage *profile_new_connection(DBusConnection *conn,
                                        DBusMessage *msg, void *data)
 {
+       struct ofono_modem *modem;
+       const char *device;
+       DBusMessageIter entry;
+       int fd;
+
        DBG("Profile handler NewConnection");
+
+       if (dbus_message_iter_init(msg, &entry) == FALSE)
+               goto error;
+
+       if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_OBJECT_PATH)
+               goto error;
+
+       dbus_message_iter_get_basic(&entry, &device);
+       modem = g_hash_table_lookup(modem_hash, device);
+       if (modem == NULL) {
+               DBG("%s: modem not found", device);
+               goto error;
+       }
+
+       dbus_message_iter_next(&entry);
+       if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_UNIX_FD)
+               goto error;
+
+       dbus_message_iter_get_basic(&entry, &fd);
+       if (fd < 0)
+               goto error;
+
+       DBG("modem %p, SLC FD: %d", modem, fd);
+
        return dbus_message_new_method_return(msg);
+
+error:
+       return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE ".Rejected",
+                                       "Invalid arguments in method call");
 }
 
 static DBusMessage *profile_release(DBusConnection *conn,
-- 
1.7.11.7

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to