SET(INSTALL_EXEC_PREFIX "${INSTALL_PREFIX}/bin")
SET(INSTALL_RESDIR "${INSTALL_PREFIX}/res")
-SET(INSTALL_DATADIR "/home/owner/apps_rw/org.tizen.position-finder-server/data")
+SET(INSTALL_RESDIR "/home/owner/apps_rw/org.tizen.position-finder-server/res")
SET(CMAKE_VERBOSE_MAKEFILE 0)
SET(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}")
${PROJECT_ROOT_DIR}/src/resource/resource_touch_sensor.c
${PROJECT_ROOT_DIR}/src/resource/resource_ultrasonic_sensor.c
)
-#${PROJECT_ROOT_DIR}/src/connectivity.c
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lm)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${APP_PKGS_LDFLAGS})
INSTALL(FILES ${PROJECT_ROOT_DIR}/tizen-manifest.xml DESTINATION ${SYS_PACKAGES_DIR} RENAME org.tizen.position-finder-server.xml)
INSTALL(DIRECTORY DESTINATION ${PREFIX}/data)
INSTALL(FILES ${PROJECT_ROOT_DIR}/shared/res/position_finder_server.png DESTINATION ${SYS_ICONS_DIR})
-INSTALL(FILES ${PROJECT_ROOT_DIR}/res/iotcon-test-svr-db-server.dat DESTINATION ${INSTALL_DATADIR})
+INSTALL(FILES ${PROJECT_ROOT_DIR}/res/iotcon-test-svr-db-server.dat DESTINATION ${INSTALL_RESDIR})
# End of a file
%define _pkg_dir %{TZ_SYS_RO_APP}/%{alias}
%define _pkg_shared_dir %{_pkg_dir}/shared
%define _pkg_data_dir %{_pkg_dir}/data
+%define _pkg_rw_res_dir /home/owner/apps_rw/org.tizen.position-finder-server/res
%define _pkg_rw_data_dir /home/owner/apps_rw/org.tizen.position-finder-server/data
%define _sys_icons_dir %{_pkg_shared_dir}/res
%define _sys_packages_dir %{TZ_SYS_RO_PACKAGES}
%post
/sbin/ldconfig
+chsmack -a "User::Pkg::org.tizen.position-finder-server" %{_pkg_rw_res_dir}/*.dat
+chmod 666 %{_pkg_rw_res_dir}/*.dat
+
+touch %{_pkg_rw_data_dir}/*.dat
chsmack -a "User::Pkg::org.tizen.position-finder-server" %{_pkg_rw_data_dir}/*.dat
chmod 666 %{_pkg_rw_data_dir}/*.dat
%files
%manifest org.tizen.position-finder-server.manifest
-%{_pkg_rw_data_dir}/*.dat
-/home/owner/apps_rw/org.tizen.position-finder-server/data/iotcon-test-svr-db-server.dat
+%{_pkg_rw_res_dir}/*.dat
%defattr(-,root,root,-)
%{_pkg_dir}/bin/position-finder-server
%{_sys_packages_dir}/org.tizen.position-finder-server.xml
* limitations under the License.
*/
+#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <glib.h>
#define ULTRASONIC_RESOURCE_1_URI "/door/1"
#define ULTRASONIC_RESOURCE_2_URI "/door/2"
#define ULTRASONIC_RESOURCE_TYPE "org.tizen.door"
+#define BUFSIZE 1024
+#define CBOR_FILE_IN_RES "/home/owner/apps_rw/org.tizen.position-finder-server/res/iotcon-test-svr-db-server.dat"
+#define CBOR_FILE_IN_DATA "/home/owner/apps_rw/org.tizen.position-finder-server/data/iotcon-test-svr-db-server.dat"
static void _request_resource_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data);
ret = iotcon_request_get_observe_id(request, &observe_id);
retv_if(IOTCON_ERROR_NONE != ret, -1);
+ _I("Add an observer : %d", observe_id);
+
ret = iotcon_observers_add(observers, observe_id);
retv_if(IOTCON_ERROR_NONE != ret, -1);
} else if (IOTCON_OBSERVE_DEREGISTER == observe_type) {
ret = iotcon_request_get_observe_id(request, &observe_id);
retv_if(IOTCON_ERROR_NONE != ret, -1);
+ _I("Remove an observer : %d", observe_id);
+
ret = iotcon_observers_remove(observers, observe_id);
retv_if(IOTCON_ERROR_NONE != ret, -1);
}
_send_response(request, NULL, IOTCON_RESPONSE_ERROR);
}
+static void _copy_file(const char *in_filename, const char *out_filename)
+{
+ char buf[BUFSIZE] = { 0, };
+ size_t nread = 0;
+ FILE *in = NULL;
+ FILE *out = NULL;
+
+ ret_if(!in_filename);
+ ret_if(!out_filename);
+
+ in = fopen(in_filename, "r");
+ ret_if(!in);
+
+ out = fopen(out_filename, "w");
+ goto_if(!out, error);
+
+ rewind(in);
+ while ((nread = fread(buf, 1, sizeof(buf), in)) > 0) {
+ if (fwrite (buf, 1, nread, out) < nread) {
+ _E("critical error to copy a file");
+ break;
+ }
+ }
+
+ fclose(in);
+ fclose(out);
+
+ return;
+
+error:
+ fclose(out);
+}
+
int connectivity_init(void)
{
int ret = -1;
- ret = iotcon_initialize("/home/owner/apps_rw/org.tizen.position-finder-server/data/iotcon-test-svr-db-server.dat");
+ _copy_file(CBOR_FILE_IN_RES, CBOR_FILE_IN_DATA);
+
+ ret = iotcon_initialize(CBOR_FILE_IN_DATA);
retv_if(IOTCON_ERROR_NONE != ret, -1);
ret = iotcon_set_device_name(ULTRASONIC_RESOURCE_TYPE);