- Fixing RRS code to support recent changes in dependent packages.
signed-off-by: Ram <ram.kannan@samsung.com>
Change-Id: I2cafbf999278996e465af9a14f2b78336abfadbe
} 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
*
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
#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
%{_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
%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*
%{_libdir}/pkgconfig/rrs-client.pc
%license LICENSE.APLv2
-
%if %{build_test_suite} == "ON"
%files -n rrs-test
%defattr(-,root,root,-)
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) {
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);
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;
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)
#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;
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;
--- /dev/null
+/*
+ * 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_ */
#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;