determine find group is in the own device or remote device using device id
authorJihoon Jung <jh8801.jung@samsung.com>
Wed, 10 Jan 2018 10:28:35 +0000 (19:28 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:38 +0000 (19:38 +0900)
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
capi/src/familynet.c
src/fn-manager/src/fn_context.c [changed mode: 0644->0755]
src/fn-manager/src/fn_iot.c

index b8d01011d9006c7d53dc611faf51414d6208011b..c49ac0f8320d4be57e0e9474959f1107c8822d41 100755 (executable)
@@ -238,7 +238,7 @@ int familynet_group_find(int timeout, familynet_group_found_cb found_cb, familyn
 /* group merge */
 int familynet_group_merge(familynet_group_h dest_group, familynet_group_h src_group)
 {
-
+       return 0;
 }
 
 int familynet_group_information_get_type(familynet_group_h group_handle, familynet_group_type_e *type)
old mode 100644 (file)
new mode 100755 (executable)
index 8b5273c..0d21eda
@@ -10,7 +10,6 @@ int fn_context_create()
                LOG_DEBUG("create mtp_context is failed");
                return FN_ERROR_UNKNOWN;
        }
-       _fn_ctx->device_uuid = g_strdup("123123");
 
        return FN_ERROR_NONE;
 }
index 66a94b5ef2f9bc75b047b9a4604f1c0265635103..c7a76d652ceaa0e9fb238d9414745a21c074e334 100755 (executable)
@@ -1,12 +1,23 @@
 #include <fn_iot.h>
 #include <fn_group.h>
 
-int fn_iot_initialize()
+static bool _request_device_info(iotcon_device_info_h info, iotcon_error_e result,
+                void *user_data)
 {
-       int ret = iotcon_initialize(SVR_PATH);
-       LOG_DEBUG("iotcon_initialize : %s", get_error_message(ret));
+       int ret;
+       char *device_id = NULL;
+
+       LOG_DEBUG("device info found");
+
+       ret = iotcon_device_info_get_property(info, IOTCON_DEVICE_INFO_ID, &device_id);
+       if (IOTCON_ERROR_NONE != ret) {
+               return false;
+       }
+
+       LOG_DEBUG("device_id : %s", device_id);
 
        fn_context_t *fn_ctx = fn_context_get_context();
+       fn_ctx->device_uuid = g_strdup(device_id);
 
        /*
                "Group device" resource
@@ -18,6 +29,17 @@ int fn_iot_initialize()
        */
        fn_iot_add_resource(FN_RESOURCE_TYPE_GROUP_DEVICE, fn_ctx->device_uuid);
 
+       return false;
+}
+
+int fn_iot_initialize()
+{
+       int ret = iotcon_initialize(SVR_PATH);
+       LOG_DEBUG("iotcon_initialize : %s", get_error_message(ret));
+
+       ret = iotcon_find_device_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,
+                                                NULL, _request_device_info, NULL);
+
        /*
                "operation" resource
                The operation resource is a control command channel between daemon and daemon.
@@ -128,6 +150,7 @@ static bool _found_resource(iotcon_remote_resource_h resource,
        char *resource_device_name;
        char *resource_host;
        char *resource_type;
+       fn_group_type_e group_type;
 
        LOG_DEBUG("Resource Found");
 
@@ -177,8 +200,14 @@ static bool _found_resource(iotcon_remote_resource_h resource,
                return IOTCON_FUNC_CONTINUE;
        }
 
+       fn_context_t *fn_ctx = fn_context_get_context();
+       if (strcmp(resource_device_id, fn_ctx->device_uuid) == 0)
+               group_type = FN_GROUP_DEVICE;
+       else
+               group_type = FN_GROUP_REMOTE_DEVICE;
+
        fn_group_add_new(resource_uri_path, resource_device_id,
-                                        resource_device_name, resource_host, resource_type, FN_GROUP_REMOTE_DEVICE);
+                                        resource_device_name, resource_host, resource_type, group_type);
        found_device_count++;
 
        g_free(resource_type);