mot-agent: disable multiple MOT at once feature
authorsaerome.kim <saerome.kim@samsung.com>
Mon, 22 Jan 2018 03:54:04 +0000 (12:54 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:46 +0000 (19:38 +0900)
comp-manager: MOT local comp-manager at first discovery time

Signed-off-by: saerome.kim <saerome.kim@samsung.com>
src/companion-manager/include/comp_context.h [changed mode: 0755->0644]
src/companion-manager/src/comp_context.c
src/companion-manager/src/comp_group.c [changed mode: 0755->0644]
src/companion-manager/src/comp_mot_agent.c [changed mode: 0755->0644]
src/mot-agent/ma-subowner.c

old mode 100755 (executable)
new mode 100644 (file)
index a0146e0..1f1bbc4
@@ -16,6 +16,7 @@ typedef struct {
        GList *resource_list[COMP_RESOURCE_TYPE_MAX];
 
        char *device_uuid;
+       bool mot_me; /**< Indicator whether mot local comp-manager */
        int operation_resource_count;
 } comp_context_t;
 
index 00ac9ea419e3e2a52a3fcab819f64b811aac94e0..63a44e61707330ad48a4dac1676b02a7340ab15f 100755 (executable)
@@ -10,6 +10,7 @@ int comp_context_create()
                LOG_DEBUG("create mtp_context is failed");
                return COMP_ERROR_UNKNOWN;
        }
+       _comp_ctx->mot_me = FALSE;
 
        return COMP_ERROR_NONE;
 }
old mode 100755 (executable)
new mode 100644 (file)
index 3793966..db17375
@@ -341,7 +341,7 @@ int comp_group_invite(gchar *uuid_dev1, gchar *uuid_dev2, gchar *pin,
         * 3. Pairwise
         */
 
-       ret = agent_mot_device(uuid_dev1, pin);
+       ret = agent_mot_device(uuid_dev2, pin);
 
        if (ret == COMP_ERROR_NONE) {
                group_invite_info = g_try_malloc0(sizeof(comp_group_invite_info_t));
old mode 100755 (executable)
new mode 100644 (file)
index 5b0c4f9..172914d
@@ -455,6 +455,17 @@ static gboolean __perform_remove_cred_at_local(gpointer data)
        return FALSE;
 }
 
+static gboolean __perform_mot_me(gpointer data)
+{
+       int ret;
+       comp_context_t *comp_ctx = comp_context_get_context();
+       ret = agent_mot_device(comp_ctx->device_uuid, "12341234");
+       if (ret != COMP_ERROR_NONE) {
+               LOG_ERR("agent_mot_device(%s) Failed", comp_ctx->device_uuid);
+       }
+
+       return FALSE;
+}
 
 static void _agent_signal_handler(GDBusConnection *connection,
                const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
@@ -482,6 +493,7 @@ static void _agent_signal_handler(GDBusConnection *connection,
                gsize len = 0;
                int mot_enb_devs_cnt = 0;
                comp_mot_device_t *device;
+               comp_context_t *comp_ctx = comp_context_get_context();
 
                if (NULL == parameters) {
                        LOG_ERR("No MOT enabled devices found");
@@ -494,8 +506,14 @@ static void _agent_signal_handler(GDBusConnection *connection,
                        while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
                                if (strcasecmp(key, "deviceId") == 0)  {
                                        const char *deviceid = g_variant_get_string(val, &len);
+                                       if (comp_ctx && (FALSE == comp_ctx->mot_me) &&
+                                               strcasecmp(deviceid, comp_ctx->device_uuid) == 0) {
+                                               g_timeout_add(10, __perform_mot_me, NULL);
+                                               comp_ctx->mot_me = TRUE;
+                                       }
                                        LOG_DEBUG("deviceId = %s", deviceid);
                                        device->device_id = g_strdup(deviceid);
+
                                } else if (strcasecmp(key, "adapter") == 0)  {
                                        int adapter = g_variant_get_uint32(val);
                                        LOG_DEBUG("adapter = %d", adapter);
@@ -670,6 +688,8 @@ static void _agent_signal_handler(GDBusConnection *connection,
                g_variant_get(parameters, "(i)", &result);
                LOG_DEBUG("Result : %d", result);
 
+               g_timeout_add(1000, __perform_agent_pairwise, NULL);
+#if 0
                if (result != 0 && result != 49) {
                        comp_group_notify_group_invite(result);
                        mot_dev2 = false;
@@ -679,6 +699,7 @@ static void _agent_signal_handler(GDBusConnection *connection,
                        else
                                g_timeout_add(1000, __perform_agent_pairwise, NULL);
                }
+#endif
        } else if (0 == g_strcmp0(signal_name, "remove_mo_done")) {
                g_variant_get(parameters, "(i)", &result);
                LOG_DEBUG("Result : %d", result);
index b24a36b9273a34dddee3a1b84dfb704aa64663c7..b8a3f5eaa23da6306078891ae4e219144a27ec3b 100644 (file)
@@ -892,7 +892,6 @@ static void _mot_cb(void* ctx, int num, OCProvisionResult_t* arr, bool has_error
        client->g_doneCB = true;
 }
 
-#define MULTIPLE_OWN_AT_ONCE
 static gpointer _mot_func(gpointer data)
 {
        OCStackResult ret = OC_STACK_OK;