comp-manager: change SVR DB of comp-manager to support MOT feature
authorsaerome.kim <saerome.kim@samsung.com>
Fri, 12 Jan 2018 05:43:37 +0000 (14:43 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:40 +0000 (19:38 +0900)
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
packaging/d2d-manager.spec
src/companion-manager/CMakeLists.txt [changed mode: 0755->0644]
src/companion-manager/oic_svr_db_comp_manager.dat [new file with mode: 0644]
src/companion-manager/oic_svr_db_comp_manager.json [new file with mode: 0644]
src/companion-manager/src/comp_iot.c
src/fn-manager/src/fn_iot.c [deleted file]

index d38e2239a5e97d205506a3378ea2b6f32159b6f7..99df8415799be9c22b790133eab8481e18cc43ec 100644 (file)
@@ -133,6 +133,7 @@ rm -rf %{NETWORK_FW_DATADIR}/oic_pdm_d2ds.db-journal
 %attr(644,root,root) %{_unitdir}/fnm.service
 %attr(644,root,root) %{_unitdir}/d2ds.service
 %attr(644,network_fw,network_fw) %{NETWORK_FW_DATADIR}/oic_svr_db_d2ds.dat
+%attr(644,network_fw,network_fw) %{NETWORK_FW_DATADIR}/oic_svr_db_comp_manager.dat
 
 %files devel
 %manifest %{name}-devel.manifest
old mode 100755 (executable)
new mode 100644 (file)
index c9a8c0d..d3e1723
@@ -19,3 +19,4 @@ SET(COMP_MANAGER "companion-manager")
 ADD_EXECUTABLE(${COMP_MANAGER} ${COMP_MANAGER_SRCS})
 TARGET_LINK_LIBRARIES(${COMP_MANAGER} ${daemon_pkgs_LIBRARIES} pthread)
 INSTALL(TARGETS ${COMP_MANAGER} DESTINATION bin)
+INSTALL(FILES oic_svr_db_comp_manager.dat DESTINATION ${NETWORK_FW_DATADIR})
diff --git a/src/companion-manager/oic_svr_db_comp_manager.dat b/src/companion-manager/oic_svr_db_comp_manager.dat
new file mode 100644 (file)
index 0000000..f449223
Binary files /dev/null and b/src/companion-manager/oic_svr_db_comp_manager.dat differ
diff --git a/src/companion-manager/oic_svr_db_comp_manager.json b/src/companion-manager/oic_svr_db_comp_manager.json
new file mode 100644 (file)
index 0000000..208d4a3
--- /dev/null
@@ -0,0 +1,123 @@
+{\r
+    "cred":{\r
+        "creds": [\r
+            {\r
+                "credid": 1,\r
+                "subjectuuid": "*",\r
+                "credtype": 16,\r
+                "privatedata": {\r
+                    "encoding": "oic.sec.encoding.raw",\r
+                    "data": "12341234"\r
+                }\r
+            }\r
+        ],\r
+        "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
+    },\r
+    "acl": {\r
+        "aclist": {\r
+            "aces": [\r
+                {\r
+                    "subjectuuid": "*",\r
+                    "resources": [\r
+                        {\r
+                            "href": "/oic/res",\r
+                            "rel": "",\r
+                            "rt": ["oic.wk.res"],\r
+                            "if": ["oic.if.ll"]\r
+                        },{\r
+                            "href": "/oic/d",\r
+                            "rel": "",\r
+                            "rt": ["oic.wk.d"],\r
+                            "if": ["oic.if.baseline", "oic.if.r"]\r
+                        },{\r
+                            "href": "/oic/p",\r
+                            "rel": "",\r
+                            "rt": ["oic.wk.p"],\r
+                            "if": ["oic.if.baseline", "oic.if.r"]\r
+                        }\r
+                    ],\r
+                    "permission": 2\r
+                },\r
+                {\r
+                    "subjectuuid": "*",\r
+                    "resources": [\r
+                        {\r
+                            "href": "/oic/sec/doxm",\r
+                            "rel": "",\r
+                            "rt": ["oic.r.doxm"],\r
+                            "if": ["oic.if.baseline"]\r
+                        },\r
+                        {\r
+                            "href": "/oic/sec/pstat",\r
+                            "rel": "",\r
+                            "rt": ["oic.r.pstat"],\r
+                            "if": ["oic.if.baseline"]\r
+                        },\r
+                        {\r
+                            "href": "/oic/sec/cred",\r
+                            "rel": "",\r
+                            "rt": ["oic.r.cred"],\r
+                            "if": ["oic.if.baseline"]\r
+                        }\r
+                    ],\r
+                    "permission": 6\r
+                },   \r
+                {\r
+                    "subjectuuid": "*",\r
+                    "resources": [\r
+                        {\r
+                            "href": "/fn/group",\r
+                            "rel": "",\r
+                            "rt": ["core.fn.group"],\r
+                            "if": ["oic.if.ll"]\r
+                        },{\r
+                            "href": "/fn/operation",\r
+                            "rel": "",\r
+                            "rt": ["core.fn.operation"],\r
+                            "if": ["oic.if.baseline", "oic.if.r"]\r
+                        }\r
+                    ],\r
+                    "permission": 31\r
+                },\r
+                {\r
+                    "subjectuuid": "*",\r
+                    "resources": [\r
+                        {\r
+                            "href": "/oic/sec/pconf",\r
+                            "rel": "",\r
+                            "rt": ["oic.r.pconf"],\r
+                            "if": ["oic.if.baseline"]\r
+                        },\r
+                        {\r
+                            "href": "/oic/sec/dpairing",\r
+                            "rel": "",\r
+                            "rt": ["oic.r.dpairing"],\r
+                            "if": ["oic.if.baseline"]\r
+                        }\r
+                    ],\r
+                    "permission": 2\r
+                }\r
+            ]\r
+        },\r
+        "rowneruuid" : "00000000-0000-0000-0000-000000000000"\r
+    },\r
+    "pstat": {\r
+        "isop": false,\r
+        "cm": 2,\r
+        "tm": 0,\r
+        "om": 4,\r
+        "sm": 4,\r
+        "deviceuuid": "00000000-0000-0000-0000-000000000000",\r
+        "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
+    },\r
+    "doxm": {\r
+        "oxms": [0, 65280],\r
+        "oxmsel": 65280,\r
+        "sct": 17,\r
+        "owned": false,\r
+        "x.org.iotivity.mom": 1,\r
+        "deviceuuid": "00000000-0000-0000-0000-000000000000",\r
+        "devowneruuid": "00000000-0000-0000-0000-000000000000",\r
+        "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
+    }\r
+}\r
index da0961d4334fd70302f6aa3e998106226efaf369..adfdc52787fa8f4460615be1248e6b12b558a011 100755 (executable)
@@ -1,6 +1,13 @@
+#include <tzplatform_config.h>
+#include <ocprovisioningmanager.h>
+
 #include <comp_iot.h>
 #include <comp_group.h>
 
+#define MAX_FILE_PATH_LEN 1024
+#define SVR_DB_FILE_NAME "oic_svr_db_comp_manager.dat"
+
+
 static bool _request_device_info(iotcon_device_info_h info, iotcon_error_e result,
                 void *user_data)
 {
@@ -34,7 +41,12 @@ static bool _request_device_info(iotcon_device_info_h info, iotcon_error_e resul
 
 int comp_iot_initialize()
 {
-       int ret = iotcon_initialize(SVR_PATH);
+       char data_dir[MAX_FILE_PATH_LEN] = {0,};
+
+       snprintf(data_dir, MAX_FILE_PATH_LEN, "%s/network/%s",
+                       tzplatform_getenv(TZ_SYS_GLOBALUSER_DATA), SVR_DB_FILE_NAME);
+
+       int ret = iotcon_initialize(data_dir);
        if (IOTCON_ERROR_NONE != ret) {
                LOG_ERR("iotcon_initialize: Failed %s", get_error_message(ret));
                return false;
@@ -49,6 +61,12 @@ int comp_iot_initialize()
                return false;
        }
 
+       /* Do Self-Ownership Transfer */
+       ret = OCConfigSelfOwnership();
+       if (OC_STACK_OK != ret ) {
+               LOG_ERR( "OCConfigSelfOwnership() error = [%d][%s]", ret, get_error_message(ret));
+       }
+
        /*
                "operation" resource
                The operation resource is a control command channel between daemon and daemon.
diff --git a/src/fn-manager/src/fn_iot.c b/src/fn-manager/src/fn_iot.c
deleted file mode 100755 (executable)
index ccafe4b..0000000
+++ /dev/null
@@ -1,287 +0,0 @@
-#include <fn_iot.h>
-#include <fn_group.h>
-
-static bool _request_device_info(iotcon_device_info_h info, iotcon_error_e result,
-                void *user_data)
-{
-       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
-               The Group device resource is only one per device.
-          resource type is core.fn.group.device
-               This resource has device information as an attribute.
-               The resource uri is /fn/group/device + certain uuid.
-               ex) /fn/group/device123123
-       */
-       //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);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("iotcon_initialize: Failed %s", get_error_message(ret));
-               return false;
-       }
-
-       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);
-
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("iotcon_find_device_info: Failed %s", get_error_message(ret));
-               return false;
-       }
-
-       /*
-               "operation" resource
-               The operation resource is a control command channel between daemon and daemon.
-          resource type is core.fn.operation
-          Within this function we create a default operation resource. (uri is /fn/operation/1)
-          If we need more control channels, increase the number.
-               ex) /fn/operation/2, /fn/operation/3
-       */
-       fn_iot_add_resource(FN_RESOURCE_TYPE_OPERATION, "1");
-
-       return FN_ERROR_NONE;
-}
-
-static void _request_handler(iotcon_resource_h resource, iotcon_request_h request,
-       void *user_data)
-{
-       LOG_DEBUG("thread id is ");
-       //get resource element from fn resource list or, parsing resource uri
-
-       //if request type is "get" and resource type is "group",
-               //then OWNER send device information to CLIENT(Device info Exchange)
-       //if request type is "put" and resource type is "operation",
-               //then It is join request. CLIENT send device information to OWNER(Device info Exchange)
-       //resource type "operation" don't have "get" request type.
-}
-
-int fn_iot_add_resource(fn_resource_type_e resource_type, char *uri)
-{
-       iotcon_resource_h resource = NULL;
-       iotcon_resource_types_h resource_types = NULL;
-       iotcon_resource_interfaces_h resource_ifaces = NULL;
-       char uri_path[PATH_MAX] = {0,};
-
-       int ret = iotcon_resource_types_create(&resource_types);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("iotcon_resource_types_create failed! : %s", get_error_message(ret));
-               goto EXIT;
-       }
-
-       ret = iotcon_resource_types_add(resource_types, fn_resource_get_type(resource_type));
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("iotcon_resource_types_add failed! : %s", get_error_message(ret));
-               goto EXIT;
-       }
-
-       ret = iotcon_resource_interfaces_create(&resource_ifaces);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("iotcon_resource_interfaces_create failed! : %s", get_error_message(ret));
-               goto EXIT;
-       }
-
-       ret = iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("iotcon_resource_interfaces_add failed! : %s", get_error_message(ret));
-               goto EXIT;
-       }
-
-       strncpy(uri_path, fn_resource_get_uri_prefix(resource_type), PATH_MAX);
-       strncat(uri_path, uri, PATH_MAX);
-
-       LOG_DEBUG("[ADD] resource uri is %s", uri_path);
-       //name duplication check
-
-       ret = iotcon_resource_create(uri_path, resource_types, resource_ifaces,
-                                       fn_resource_get_policies(resource_type), _request_handler, NULL, &resource);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("iotcon_resource_create failed! : %s", get_error_message(ret));
-               goto EXIT;
-       }
-
-       //get resource list of resource type
-       ret = fn_resource_append(resource_type, uri, resource);
-       if (FN_ERROR_NONE != ret) {
-               LOG_ERR("fn_resource_append failed! : %s", fn_log_get_error_string(ret));
-               goto EXIT;
-       }
-
-EXIT:
-       if (resource_types != NULL)
-               iotcon_resource_types_destroy(resource_types);
-
-       if (resource_ifaces != NULL)
-               iotcon_resource_interfaces_destroy(resource_ifaces);
-
-       return FN_ERROR_NONE;
-}
-
-static bool _get_res_type_cb(const char *string, void *user_data)
-{
-       char **resource_type = user_data;
-
-       *resource_type = g_strdup(string);
-
-       LOG_DEBUG("resource type : %s", *resource_type);
-
-       return IOTCON_FUNC_CONTINUE;
-}
-
-int found_device_count = 0;
-
-static bool _found_resource(iotcon_remote_resource_h resource,
-                                               iotcon_error_e result, void *user_data)
-{
-       int ret;
-       char *resource_uri_path = NULL;
-       iotcon_resource_types_h resource_types;
-       char *resource_device_id;
-       char *resource_device_name;
-       char *resource_host;
-       char *resource_type;
-       fn_group_type_e group_type;
-
-       LOG_DEBUG("Resource Found");
-
-       /* get the resource URI */
-       ret = iotcon_remote_resource_get_uri_path(resource, &resource_uri_path);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("Failed to get resource uri path");
-               return IOTCON_FUNC_CONTINUE;
-       }
-       LOG_DEBUG("resource uri : %s", resource_uri_path);
-
-       /* get the resource device id */
-       ret = iotcon_remote_resource_get_device_id(resource, &resource_device_id);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("Failed to get resource device id");
-               return IOTCON_FUNC_CONTINUE;
-       }
-       LOG_DEBUG("resource device id : %s", resource_device_id);
-
-       /* get the resource device name */
-       ret = iotcon_remote_resource_get_device_name(resource,
-                                                                &resource_device_name);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("Failed to get resource device name");
-               return IOTCON_FUNC_CONTINUE;
-       }
-       LOG_DEBUG("resource device name : %s", resource_device_name);
-
-       /* get the resource host address */
-       ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("Failed to get resource host address");
-               return IOTCON_FUNC_CONTINUE;
-       }
-       LOG_DEBUG("resource host : %s", resource_host);
-
-       ret = iotcon_remote_resource_get_types(resource, &resource_types);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("Failed to get resource types");
-               return IOTCON_FUNC_CONTINUE;
-       }
-
-       ret = iotcon_resource_types_foreach(resource_types, _get_res_type_cb,
-                       &resource_type);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("Failed to get foreach resource types");
-               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, group_type);
-       found_device_count++;
-
-       g_free(resource_type);
-
-       return IOTCON_FUNC_CONTINUE;
-}
-
-static gboolean _timeout_cb(gpointer data)
-{
-       int ret = -1;
-       if (found_device_count > 0)
-               ret = 0;
-
-       notify_group_finish(ret);
-
-       return false;
-}
-
-int fn_iot_discovery_resource(fn_resource_type_e resource_type, int timeout)
-{
-       int ret;
-       iotcon_query_h query;
-
-       found_device_count = 0;
-
-       ret = iotcon_set_timeout(timeout);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("Failed to set timeout value");
-               return FN_ERROR_OPERATION_FAILED;
-       }
-
-       ret = iotcon_query_create(&query);
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("Failed to create iotcon query");
-               return FN_ERROR_OPERATION_FAILED;
-       }
-
-       ret = iotcon_query_set_resource_type(query,
-                                                        fn_resource_get_type(resource_type));
-       if (IOTCON_ERROR_NONE != ret) {
-               LOG_ERR("Failed to set iotcon query resource type");
-               return FN_ERROR_OPERATION_FAILED;
-       }
-
-       LOG_DEBUG("find resource : %s", get_error_message(ret));
-
-       ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS,
-               IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP,
-               query, _found_resource, NULL);
-
-       g_timeout_add_seconds(timeout + 1, _timeout_cb, NULL);
-
-       LOG_DEBUG("find resource : %s", get_error_message(ret));
-
-       return ret;
-}
-
-int fn_iot_delete_resource(fn_resource_type_e resource_type)
-{
-       //delete resource from resource list using resource_type and index
-       //delete DB
-       return FN_ERROR_NONE;
-}
-
-int fn_iot_deinitialize()
-{
-       return FN_ERROR_NONE;
-}