Add code to set device as trusted 2.2_release submit/tizen_2.2/20130814.090201 submit/tizen_2.2/20130814.101822
authorDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 9 Apr 2013 14:12:11 +0000 (19:42 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 2 Aug 2013 06:45:16 +0000 (15:45 +0900)
Changes:
Added a new enum GAP_AGENT_ACCEPT_ALWAYS, if bluetooth service gets
this response from bt-syspopup, the device is set as trusted and for
consecutive connection from this device there will be no authorization
popup.

Change-Id: I4160008f34459c347fbcf5fcf6fe9726b366303b

bt-service/bt-service-gap-agent.c
bt-service/include/bt-service-gap-agent.h

index 8b6ddf7..30c174c 100644 (file)
@@ -27,6 +27,7 @@
 #include "bt-service-agent.h"
 #include "bt-service-gap-agent.h"
 #include "bt-service-adapter.h"
+#include "bt-service-device.h"
 
 static DBusGConnection *connection = NULL;
 
@@ -787,6 +788,19 @@ gboolean gap_agent_reply_authorize(GapAgent *agent, const guint accept,
                                                priv->reply_context != NULL) {
                if (accept == GAP_AGENT_ACCEPT) {
                        dbus_g_method_return(priv->reply_context);
+               } else if (accept == GAP_AGENT_ACCEPT_ALWAYS) {
+                       bluetooth_device_address_t addr = {{0,}};
+                       int result;
+
+                       _bt_convert_addr_string_to_type(addr.addr,
+                                                       priv->authorize_addr);
+
+                       result = _bt_set_authorization(&addr, TRUE);
+                       if (result == BLUETOOTH_ERROR_NONE) {
+                               BT_DBG("Device added to trusted");
+                       }
+
+                       dbus_g_method_return(priv->reply_context);
                } else {
                        GError *error = NULL;
                        switch (accept) {
index 271171b..3288eb7 100644 (file)
@@ -75,6 +75,7 @@ typedef enum {
        GAP_AGENT_REJECT,
        GAP_AGENT_CANCEL,
        GAP_AGENT_TIMEOUT,
+       GAP_AGENT_ACCEPT_ALWAYS,
 } GAP_AGENT_ACCEPT_TYPE_T;
 
 struct _GapAgent {