bluez5: Unify bt_register_profile_* into a single function
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>
Tue, 23 Apr 2013 21:21:50 +0000 (18:21 -0300)
committerDenis Kenzior <denkenz@gmail.com>
Thu, 25 Apr 2013 08:38:11 +0000 (03:38 -0500)
It was a cause of confusion for little gain to have separate
functions for registering profiles with extra information, for
example "role" and "features". We remove those helper functions
in favor of a single one with more parameters, "role" and
"feature" when NULL, will be ignored.

dundee/bluez5.c
plugins/bluez5.c
plugins/bluez5.h
plugins/dun_gw_bluez5.c
plugins/hfp_ag_bluez5.c
plugins/hfp_hf_bluez5.c

index 3f9c6463d56e5ac457b707d6cea640838e6f6789..79b5adeceec4b23e3efb54c3f3737ab6b32ec018 100644 (file)
@@ -379,8 +379,8 @@ static void connect_handler(DBusConnection *conn, void *user_data)
 {
        DBG("");
 
-       bt_register_profile_with_role(conn, DUN_GW_UUID, DUN_VERSION_1_2,
-                               "dun_dt", DUN_DT_PROFILE_PATH, "client");
+       bt_register_profile(conn, DUN_GW_UUID, DUN_VERSION_1_2, "dun_dt",
+                                       DUN_DT_PROFILE_PATH, "client", 0);
 }
 
 int __dundee_bluetooth_init(void)
index 0f997daff618f3d64ac8b95d3f81e0a185b1acbc..979076e4f6bd476e8ff20df76c1126963d3f7cde 100644 (file)
@@ -90,9 +90,10 @@ done:
        dbus_message_unref(reply);
 }
 
-int bt_register_profile_with_role(DBusConnection *conn, const char *uuid,
+int bt_register_profile(DBusConnection *conn, const char *uuid,
                                        uint16_t version, const char *name,
-                                       const char *object, const char *role)
+                                       const char *object, const char *role,
+                                       uint16_t features)
 {
        DBusMessageIter iter, dict;
        DBusPendingCall *c;
@@ -114,6 +115,10 @@ int bt_register_profile_with_role(DBusConnection *conn, const char *uuid,
        if (role)
                ofono_dbus_dict_append(&dict, "Role", DBUS_TYPE_STRING, &role);
 
+       if (features)
+               ofono_dbus_dict_append(&dict, "Features", DBUS_TYPE_UINT16,
+                                                               &features);
+
        dbus_message_iter_close_container(&iter, &dict);
 
        if (!dbus_connection_send_with_reply(conn, msg, &c, -1)) {
@@ -130,14 +135,6 @@ int bt_register_profile_with_role(DBusConnection *conn, const char *uuid,
        return 0;
 }
 
-int bt_register_profile(DBusConnection *conn, const char *uuid,
-                                       uint16_t version, const char *name,
-                                                       const char *object)
-{
-       return bt_register_profile_with_role(conn, uuid, version, name, object,
-                                                                       NULL);
-}
-
 void bt_unregister_profile(DBusConnection *conn, const char *object)
 {
        DBusMessageIter iter;
index 5b8c1f55ac8b5da9b83223ed5874cbe9a62395b0..db24b1abe711a8b926ee07cae046d94ee82a1808 100644 (file)
 #define HFP_HS_UUID    "0000111e-0000-1000-8000-00805f9b34fb"
 #define HFP_AG_UUID    "0000111f-0000-1000-8000-00805f9b34fb"
 
-int bt_register_profile_with_role(DBusConnection *conn, const char *uuid,
-                                       uint16_t version, const char *name,
-                                       const char *object, const char *role);
-
 int bt_register_profile(DBusConnection *conn, const char *uuid,
                                        uint16_t version, const char *name,
-                                       const char *object);
+                                       const char *object, const char *role,
+                                       uint16_t features);
 
 void bt_unregister_profile(DBusConnection *conn, const char *object);
 
index 9844092f9f245b4e85e57aed9df9d29813ec2a21..faea12b0dd91332fcbd05b37f7d9dc02fd03dde0 100644 (file)
@@ -172,7 +172,7 @@ static void gprs_watch(struct ofono_atom *atom,
 
        if (modems->next == NULL)
                bt_register_profile(conn, DUN_GW_UUID, DUN_GW_VERSION_1_0,
-                                       "dun_gw", DUN_GW_EXT_PROFILE_PATH);
+                               "dun_gw", DUN_GW_EXT_PROFILE_PATH, NULL, 0);
 }
 
 static void modem_watch(struct ofono_modem *modem, gboolean added, void *user)
index 59e84d21ada67d5d24def1b27ad88008aca762f2..245de21797bdaf7d284ba665be5cf454e1475347 100644 (file)
@@ -233,7 +233,7 @@ static void sim_state_watch(enum ofono_sim_state new_state, void *data)
                return;
 
        bt_register_profile(conn, HFP_AG_UUID, HFP_VERSION_1_5, "hfp_ag",
-                                               HFP_AG_EXT_PROFILE_PATH);
+                                       HFP_AG_EXT_PROFILE_PATH, NULL, 0);
 }
 
 static gboolean sim_watch_remove(gpointer key, gpointer value,
index 2b9275b372bdcfe6069ca2376ee4c3c1d1cd31da..826796f0764bfe49a33e88f312176a49c95c956d 100644 (file)
@@ -639,7 +639,7 @@ static void connect_handler(DBusConnection *conn, void *user_data)
        DBG("Registering External Profile handler ...");
 
        bt_register_profile(conn, HFP_HS_UUID, HFP_VERSION_1_6, "hfp_hf",
-                                               HFP_EXT_PROFILE_PATH);
+                                       HFP_EXT_PROFILE_PATH, NULL, 0);
 }
 
 static gboolean has_hfp_ag_uuid(DBusMessageIter *array)