Skip mot enabled device when the device already invited to local device 86/184886/1
authorJihoon Jung <jh8801.jung@samsung.com>
Tue, 24 Jul 2018 06:01:22 +0000 (15:01 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Tue, 24 Jul 2018 06:01:22 +0000 (15:01 +0900)
Change-Id: I65b2c375b841f43c497ab1883f92dd63d016215b
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
src/mot-agent/ma-subowner.c

index ea2a6d1..885a8c2 100755 (executable)
@@ -408,7 +408,39 @@ static gpointer ___notify_found_devs(gpointer data)
                MA_LOGD("Found %d Mowned devices", g_client->g_mowndev_cnt);
        }
 
+       char *uuid_str = NULL;
+       OicUuid_t uuid;
+
+       GetDoxmDevOwnerId(&uuid);
+       ConvertUuidToStr(&uuid, &uuid_str);
+
+       MA_LOGD("local owner uuid is %s", uuid_str);
+
        while (iter != NULL) {
+               MA_LOGD("-----------------------------------");
+               if (con->cid == MA_FIND_MOT_ENABLED_DEVICES) {
+                       bool is_invited = false;
+                       OicSecSubOwner_t* subOwner = iter->doxm->subOwners;
+                       if (subOwner != NULL) {
+                               while (subOwner != NULL) {
+                                       char *readable_uuid = ma_get_readable_uuid(&(subOwner->uuid));
+                                       MA_LOGD("remote owner uuid is %s", readable_uuid);
+
+                                       if (g_strcmp0(readable_uuid, uuid_str) == 0) {
+                                               is_invited = true;
+                                               break;
+                                       }
+                                       subOwner = subOwner->next;
+                               }
+                       }
+
+                       if (is_invited == true) {
+                               MA_LOGD("The device is already invited. Skip the device");
+                               iter = iter->next;
+                               continue;
+                       }
+               }
+
                OicUuid_t *uuid = &iter->doxm->deviceID;
                ma_check_null_ret_error("uuid", uuid, NULL);