- if (!proxy) {
- BT_ERR("Unable to create proxy: %s", err->message);
- g_clear_error(&err);
- return BLUETOOTH_ERROR_INTERNAL;
- }
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
- key_type = "DataType";
- value = (guint16) data_type;
- g_variant_builder_add(builder, "{sv}",
- key_type, g_variant_new("q",
- value));
-
- key_type = "Role";
- /*0-Source,1-Sink*/
- svalue = (role == HDP_ROLE_SINK) ? "Sink" : "Source";
- g_variant_builder_add(builder, "{sv}",
- key_type, g_variant_new("s",
- svalue));
-
- key_type = "Description";
- svalue = "Health Device";
- g_variant_builder_add(builder, "{sv}",
- key_type, g_variant_new("s",
- svalue));
-
- if (role == HDP_ROLE_SOURCE) {
- key_type = "ChannelType";
- if (channel_type == HDP_QOS_RELIABLE)
- svalue = "reliable";
- else if (channel_type == HDP_QOS_STREAMING)
- svalue = "streaming";
-
- g_variant_builder_add(builder, "{sv}",
- key_type, g_variant_new("s",
- svalue));
- }
-
- reply = g_dbus_proxy_call_sync(proxy, "CreateApplication",
- g_variant_new("(a{sv})", builder),
- G_DBUS_CALL_FLAGS_NONE, -1,
- NULL, &err);
-
- g_variant_builder_unref(builder);
- g_object_unref(proxy);
-
- if (!reply) {
- BT_ERR(" HDP:dbus Can't create application");
- if (err) {
- BT_ERR("%s", err->message);
- if (g_strrstr(err->message, BT_ACCESS_DENIED_MSG))
- ret = BLUETOOTH_ERROR_PERMISSION_DEINED;
- else
- ret = BLUETOOTH_ERROR_INTERNAL;
- g_clear_error(&err);
- }
- return ret;
- }
-
- g_variant_get(reply, "(&o)", &app_path);
- BT_DBG("Created health application: %s", (char *)app_path);
-
- ret = __bt_hdp_internal_add_filter();
-
- if (ret != BLUETOOTH_ERROR_NONE) {
- BT_ERR("Funtion failed");
- return ret;
- }
-
- list = g_new0(hdp_app_list_t, 1);
- list->app_handle = (void *)g_strdup(app_path);
- *app_handle = list->app_handle;
-
- g_app_list = g_slist_append(g_app_list, list);
-
- g_variant_unref(reply);
- return BLUETOOTH_ERROR_NONE;