#include "bt-hal-msg.h"
#include "bt-hal-utils.h"
+#include "bt-internal-types.h"
+
#include <glib.h>
#include <gio/gio.h>
#include <dlog.h>
#define AGENT_ALREADY_EXIST 0x24
+#define GAP_UUID "00001800-0000-1000-8000-00805f9b34fb"
#define GAP_AGENT_ERROR (gap_agent_error_quark())
static GQuark gap_agent_error_quark(void)
g_object_unref(device);
return;
} else if (g_strcmp0(method_name, "RequestAuthorization") == 0) {
+ if (!TIZEN_PROFILE_WEARABLE) {
+ /* Accept always */
g_dbus_method_invocation_return_value(invocation, NULL);
+ } else {
+ /* TODO: This security feature is applicable for Mobile. */
+ GapAgentPrivate *priv = user_data;
+ char *sender = (char *)g_dbus_method_invocation_get_sender(invocation);
+ GDBusProxy *device;
+ GDBusConnection *conn;
+ char *addr;
+ char *path;
+
+ if (sender == NULL)
+ return;
+
+ g_variant_get(parameters, "(&o)", &path);
+ DBG("Request authorization :sender %s priv->busname %s"
+ "Device Path :%s",
+ sender, priv->busname, path);
+
+ if (!priv->cb.authorize_func)
+ return;
+
+ conn = _bt_hal_get_system_gconn();
+ if (conn == NULL)
+ return;
+
+ device = g_dbus_proxy_new_sync(conn,
+ G_DBUS_PROXY_FLAGS_NONE, NULL,
+ BT_HAL_BLUEZ_NAME, path,
+ BT_HAL_PROPERTIES_INTERFACE, NULL, &err);
+
+ if (!device) {
+ ERR("Fail to make device proxy");
+
+ g_dbus_method_invocation_return_error(invocation,
+ GAP_AGENT_ERROR, GAP_AGENT_ERROR_REJECT,
+ "No proxy for device");
+
+ if (err) {
+ ERR("Unable to create proxy: %s", err->message);
+ g_clear_error(&err);
+ }
+
+ return;
+ }
+
+ priv->exec_type = GAP_AGENT_EXEC_AUTHORZATION;
+ priv->reply_context = invocation;
+
+ addr = strstr(path, "dev_");
+ if (addr != NULL) {
+ char *pos = NULL;
+ addr += 4;
+ g_strlcpy(priv->authorize_addr, addr,
+ sizeof(priv->authorize_addr));
+
+ while ((pos = strchr(priv->authorize_addr, '_')) != NULL)
+ *pos = ':';
+ }
+
+ priv->cb.authorize_func(priv, device, GAP_UUID);
+
+ g_object_unref(device);
+ return;
+ }
} else if (g_strcmp0(method_name, "ConfirmModeChange") == 0) {
g_dbus_method_invocation_return_value(invocation, NULL);
} else if (g_strcmp0(method_name, "Cancel") == 0) {