Fixing RRS for recent changes in dependent packages 21/79821/1 tizen
authorRamasamy <ram.kannan@samsung.com>
Wed, 13 Jul 2016 06:31:30 +0000 (12:01 +0530)
committerRamasamy <ram.kannan@samsung.com>
Wed, 13 Jul 2016 06:32:16 +0000 (12:02 +0530)
- Fixing RRS code to support recent changes in dependent packages.

signed-off-by: Ram <ram.kannan@samsung.com>
Change-Id: I2cafbf999278996e465af9a14f2b78336abfadbe

include/rrs_main.h
packaging/remote-resource-service.spec
src/client/ResourceClient.cpp
src/client/rrs_resource.cpp
src/common/CMakeLists.txt
src/common/rrs.cpp
src/common/rrs_server.h [new file with mode: 0644]
src/server/daemon/Server.cpp

index de66132..3c7fca3 100644 (file)
@@ -103,8 +103,8 @@ typedef enum _rrs_resource_e {
 } rrs_resource_e;
 
 /**
- * @brief      Creates an RRS and assigns it with a handle.
- * @details This function creates an RRS and issues a new handle for it.
+ * @brief      Creates a RRS client and assigns it with a handle.
+ * @details This function creates a RRS client and issues a new handle for it.
  * \n The handle is used to discover resources.
  * @since_tizen 3.0
  *
index fc9b0d5..152a454 100644 (file)
@@ -21,8 +21,6 @@ BuildRequires:  pkgconfig(cynara-creds-gdbus)
 BuildRequires:  pkgconfig(cynara-client)
 BuildRequires:  pkgconfig(cynara-session)
 BuildRequires:  pkgconfig(vconf)
-BuildRequires:  pkgconfig(capi-system-info)
-BuildRequires:  pkgconfig(libtzplatform-config)
 Requires(post):  /sbin/ldconfig
 Requires(postun):  /sbin/ldconfig
 
@@ -104,16 +102,10 @@ mkdir -p %{buildroot}/usr/share/license
 #cp LICENSE %{buildroot}/usr/share/license/%{name}
 
 %post -n capi-rrs-client -p /sbin/ldconfig
-%post -n capi-rrs-client-devel -p /sbin/ldconfig
+%post -n rrs-serverd -p /sbin/ldconfig
 
 %postun -n capi-rrs-client -p /sbin/ldconfig
-%postun -n capi-rrs-client-devel -p /sbin/ldconfig
-
-chown -R root:root %{buildroot}/root/share/rrs/*.dat
-chsmack -a '_' %{buildroot}/root/share/rrs/*.dat
-
-chown -R owner:users %{buildroot}/home/owner/share/rrs/*.dat
-chsmack -a 'User::App::Shared' %{buildroot}/home/owner/share/rrs/*.dat
+%postun -n rrs-serverd -p /sbin/ldconfig
 
 %files -n rrs-serverd
 %manifest packaging/rrs-serverd.manifest
@@ -125,7 +117,7 @@ chsmack -a 'User::App::Shared' %{buildroot}/home/owner/share/rrs/*.dat
 %{_libdir}/systemd/system/default.target.wants/remote-resource-service.service
 %license LICENSE.APLv2
 %attr(0644,root,root)/usr/share/rrs/*.dat
-/root/share/rrs/*.dat
+%attr(0644,root,root)/root/share/rrs/*.dat
 %attr(0644,root,root)/usr/lib/rrs/schemas/rrsdiscovery.json
 %attr(0644,root,root)/usr/lib/rrs/schemas/sensorcontrol.json
 %attr(0644,root,root)/usr/lib/rrs/schemas/accelerometer.json
@@ -185,6 +177,7 @@ chsmack -a 'User::App::Shared' %{buildroot}/home/owner/share/rrs/*.dat
 %attr(0644,root,root)/usr/lib/rrs/schemas/uv.json
 
 %files -n capi-rrs-client-devel
+%manifest packaging/capi-rrs-client.manifest
 %defattr(-,root,root,-)
 %{_includedir}/*.h
 %{_libdir}/librrs-client.so*
@@ -192,7 +185,6 @@ chsmack -a 'User::App::Shared' %{buildroot}/home/owner/share/rrs/*.dat
 %{_libdir}/pkgconfig/rrs-client.pc
 %license LICENSE.APLv2
 
-
 %if %{build_test_suite} == "ON"
 %files -n rrs-test
 %defattr(-,root,root,-)
index cc486e0..e284fb8 100644 (file)
@@ -139,7 +139,7 @@ bool ResourceClient::__found_discovery_resource(iotcon_remote_resource_h resourc
                return false;
        }
 
-       DBG("[%s] resource host : %s", client->__uriPath, client->__hostAddress);
+       DBG("Resource host : %s", client->__hostAddress);
 
        ret = iotcon_remote_resource_get_connectivity_type(resource, &client->__connectivityType);
        if (ret != IOTCON_ERROR_NONE) {
@@ -226,7 +226,7 @@ bool ResourceClient::__found_resource(iotcon_remote_resource_h resource, iotcon_
                delete client;
                return false;
        }
-       DBG("[%s] resource host : %s", client->__uriPath, hostAddress);
+       DBG("Resource host : %s", hostAddress);
        client->__hostAddress = strdup(hostAddress);
 
        ret = iotcon_remote_resource_get_connectivity_type(resource, &client->__connectivityType);
index 2aa7b5a..5c24ca7 100644 (file)
@@ -228,7 +228,7 @@ EXPORT_API int rrs_resource_get_device_name(const rrs_resource_h handle, char **
                ERR("iotcon_remote_resource_get_device_name() Fail(%d)", ret);
                return RRS_ERROR_INVALID_PARAMETER;
        }
-       DBG("[%s] resource device name : %s", client->__uriPath, deviceName);
+       DBG("Resource device name : %s", deviceName);
        *device_name = strdup(deviceName);
 
        return RRS_ERROR_NONE;
index db4988b..e005167 100755 (executable)
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6)
 project(rrs-common CXX)
 
 INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(rrs-common-pkgs REQUIRED glib-2.0 dlog json-glib-1.0 iotcon cynara-client capi-system-info libtzplatform-config)
+PKG_CHECK_MODULES(rrs-common-pkgs REQUIRED glib-2.0 dlog json-glib-1.0 iotcon cynara-client)
 
 INCLUDE_DIRECTORIES(include)
 FILE(GLOB rrs-common-srcs *.c *.cpp)
index 8b55a2c..3310062 100644 (file)
 
 #include <glib.h>
 #include "rrs.h"
+#include "rrs_server.h"
 #include "Mutex.h"
 #include "common.h"
-#include "tzplatform_config.h"
 
 extern bool __has_iot_privilege();
 
 static bool handle_array[MAX_RRS_HANDLE] = {false};
 static Mutex m_mutex;
 
-#define RRS_SECURITY_FILEPATH tzplatform_mkpath(TZ_USER_SHARE, "rrs/rrs-svr-db.dat")
-
 EXPORT_API int rrs_create(rrs_h *rrs)
 {
        int ret;
@@ -54,10 +52,45 @@ EXPORT_API int rrs_create(rrs_h *rrs)
                return RRS_ERROR_SERVICE_NOT_AVAILABLE;
        }
 
-       INFO("Path: %s", RRS_SECURITY_FILEPATH);
+       /* connect iotcon */
+       ret = iotcon_initialize("/home/owner/share/rrs/rrs-svr-db.dat");
+       if (ret != IOTCON_ERROR_NONE) {
+               ERR("iotcon_initialize() Fail(%d)", ret);
+               return RRS_ERROR_SERVICE_NOT_AVAILABLE;
+       }
+
+       return RRS_ERROR_NONE;
+}
+
+int rrs_server_create(rrs_h *rrs)
+{
+       int ret;
+       int value = 1;
+
+       /* Check if parameters are valid */
+       if (!rrs)
+               return RRS_ERROR_INVALID_PARAMETER;
+
+       /* Check if privileges enough */
+       if (!__has_iot_privilege())
+               return RRS_ERROR_PERMISSION_DENIED;
+
+       {
+               AUTOLOCK(m_mutex);
+               while (handle_array[value] == true)
+                       value++;
+
+               *rrs = value;
+               handle_array[value] = true;
+       }
+
+       if (*rrs > MAX_RRS_HANDLE) {
+               ERR("Maximum limit for RRS handles reached");
+               return RRS_ERROR_SERVICE_NOT_AVAILABLE;
+       }
 
        /* connect iotcon */
-       ret = iotcon_initialize(RRS_SECURITY_FILEPATH);
+       ret = iotcon_initialize("/root/share/rrs/rrs-svr-db.dat");
        if (ret != IOTCON_ERROR_NONE) {
                ERR("iotcon_initialize() Fail(%d)", ret);
                return RRS_ERROR_SERVICE_NOT_AVAILABLE;
diff --git a/src/common/rrs_server.h b/src/common/rrs_server.h
new file mode 100644 (file)
index 0000000..170291c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _RRS_SERVER_H_
+#define _RRS_SERVER_H_
+
+#include "rrs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * @brief      Creates an RRS server and assigns it with a handle.
+ * @details This function creates an RRS server and issues a new handle for it.
+ * \n The handle is used to create resources.
+ * @since_tizen 3.0
+ *
+ * @remarks @a rrs handle must be released using rrs_destroy().
+ *
+ * @param[out] rrs             A handle of the newly created RRS server
+ * @return     0 on success, otherwise a negative error value
+ * @retval     #RRS_ERROR_NONE Successful
+ * @retval     #RRS_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval     #RRS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval     #RRS_ERROR_PERMISSION_DENIED Permission Denied
+ *
+ * @see rrs_destroy()
+ */
+int rrs_server_create(rrs_h *rrs);
+
+
+#ifdef __cplusplus
+}
+#endif
+/**
+ * @}
+ */
+
+#endif /* _RRS_SERVER_H_ */
index a8cd0ef..4817676 100755 (executable)
 #include <thread>
 #include <vconf.h>
 #include "rrs.h"
+#include "rrs_server.h"
 #include "ResourceServer.h"
 #include "common.h"
 
-
 using std::thread;
 
 Server::Server()
 {
        __mainLoop = NULL;
+
        /* Create RRS */
-       int ret = rrs_create(&__rrs);
+       int ret = rrs_server_create(&__rrs);
        if (ret != RRS_ERROR_NONE) {
                ERR("rrs_create() Fail(%d)", ret);
                return;