- adds static lib to share functions between daemon and libs 34/179234/2
authorJeonghoon Park <jh1979.park@samsung.com>
Wed, 16 May 2018 10:46:17 +0000 (19:46 +0900)
committerJeonghoon Park <jh1979.park@samsung.com>
Wed, 16 May 2018 10:47:44 +0000 (19:47 +0900)
- refines directory to add new lib for application

Change-Id: Ibaa5c40ffa4b2194dbad0ff941ae8f078c5b8690

24 files changed:
CMakeLists.txt
common/CMakeLists.txt [new file with mode: 0644]
common/common-app-inf.c [new file with mode: 0644]
common/common-app-inf.h [new file with mode: 0644]
common/common-util.c [new file with mode: 0644]
common/common-util.h [new file with mode: 0644]
common/common-worker-inf-dbus.xml [moved from lib/src/tizen-things-lib-dbus.xml with 100% similarity]
common/common-worker-inf-def.h [new file with mode: 0644]
daemon/CMakeLists.txt
daemon/src/tizen-things-daemon-dbus.xml [deleted file]
daemon/src/ttd-app-interface.c
daemon/src/ttd-worker-interface.c
lib/CMakeLists.txt
lib/things-service-worker/CMakeLists.txt [new file with mode: 0644]
lib/things-service-worker/include/log-private.h [moved from lib/include/log.h with 100% similarity]
lib/things-service-worker/include/ttsd-worker-lib.h [moved from lib/include/ttsd-worker-lib.h with 100% similarity]
lib/things-service-worker/src/ttsd-worker-lib.c [moved from lib/src/ttsd-worker-lib.c with 94% similarity]
lib/things-service-worker/things-service-worker.pc.in [moved from lib/libthings-service.pc.in with 100% similarity]
lib/things-service/CMakeLists.txt [new file with mode: 0644]
lib/things-service/include/log-private.h [new file with mode: 0644]
lib/things-service/include/things-service.h [new file with mode: 0644]
lib/things-service/src/things-service.c [new file with mode: 0644]
lib/things-service/things-service.pc.in [new file with mode: 0644]
packaging/tizen-things-daemon.spec

index 9b6dc68..8c34788 100644 (file)
@@ -1,4 +1,5 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
+ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(daemon)
 ADD_SUBDIRECTORY(lib)
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fc96f4f
--- /dev/null
@@ -0,0 +1,42 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(CMAKE_VERBOSE_MAKEFILE 0)
+SET(COMMON ttd-common)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(COMMON_PKGS REQUIRED
+       glib-2.0
+       gio-unix-2.0
+       dlog
+)
+
+FOREACH (flag ${COMMON_PKGS_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Winline -g -fno-builtin-malloc -fPIE")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Winline -g")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+                               " \\
+                               --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/common-worker-inf-dbus \\
+                               ${CMAKE_CURRENT_SOURCE_DIR}/common-worker-inf-dbus.xml \\
+                               ")
+
+FILE(GLOB COMMON_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
+
+SET(COMMON_INCLUDES
+       ${CMAKE_CURRENT_SOURCE_DIR}
+       CACHE PATH "common includes path"
+)
+
+SET(COMMON_LIBS
+       ${COMMON}
+       CACHE STRING "common libs"
+)
+
+ADD_LIBRARY(${COMMON} STATIC ${COMMON_SOURCE})
+TARGET_LINK_LIBRARIES(${COMMON} ${COMMON_LDFLAGS})
+TARGET_INCLUDE_DIRECTORIES(${COMMON} PUBLIC ${COMMON_INCLUDES})
\ No newline at end of file
diff --git a/common/common-app-inf.c b/common/common-app-inf.c
new file mode 100644 (file)
index 0000000..eebac90
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#include <glib.h>
+
+char *common_make_socket_addr_name(
+       const char *token, const char *appID, unsigned int appPID)
+{
+       /* TODO : improve it*/
+       return g_strdup_printf("%5u-%s", appPID, token);
+}
diff --git a/common/common-app-inf.h b/common/common-app-inf.h
new file mode 100644 (file)
index 0000000..1bf8251
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __TTD_COMMON_APPINF_H__
+#define __TTD_COMMON_APPINF_H__
+
+#define TTD_APP_MSG_DELIMITER "|"
+#define TTD_APP_INF_BUS_NAME "org.tizen.ttd.bus"
+#define TTD_APP_INF_BUS_INF "org.tizen.ttd.bus.appinf"
+#define TTD_APP_INF_OBJECT_PATH "/org/tizen/ttd/bus/appinf/object"
+
+char *common_make_socket_addr_name(
+       const char *token, const char *appID, unsigned int appPID);
+
+#endif /* __TTD_COMMON_APPINF_H__ */
diff --git a/common/common-util.c b/common/common-util.c
new file mode 100644 (file)
index 0000000..dbb04c0
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#include <time.h>
+
+unsigned long long common_get_monotonic_time(void)
+{
+       struct timespec ts;
+       int result;
+
+       result = clock_gettime(CLOCK_MONOTONIC, &ts);
+
+       if (result != 0)
+               return 0;
+
+       return (((unsigned long long) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000);
+}
diff --git a/common/common-util.h b/common/common-util.h
new file mode 100644 (file)
index 0000000..62d7a31
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __TTD_COMMON_UTIL_H__
+#define __TTD_COMMON_UTIL_H__
+
+unsigned long long common_get_monotonic_time(void);
+
+#endif /* __TTD_COMMON_UTIL_H__ */
diff --git a/common/common-worker-inf-def.h b/common/common-worker-inf-def.h
new file mode 100644 (file)
index 0000000..8b140c7
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __TTD_COMMON_WORKER_INF_DEF_H__
+#define __TTD_COMMON_WORKER_INF_DEF_H__
+
+#define TTSD_WORKER_DBUS_NAME "ttsd.worker.dbus"
+#define TTSD_WORKER_DBUS_OBJECT_PATH "/ttsd_worker_dbus_object"
+#define TTSD_WORKER_DBUS_INTERFACE "ttsd.worker.dbus"
+
+#endif /* __TTD_COMMON_WORKER_INF_DEF_H__ */
index add707d..2e0a762 100644 (file)
@@ -18,13 +18,6 @@ FOREACH (flag ${DAEMON_PKGS_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
-                " \\
-                --generate-c-code ${CMAKE_SOURCE_DIR}/daemon/src/tizen-things-daemon-dbus \\
-                ${CMAKE_SOURCE_DIR}/daemon/src/tizen-things-daemon-dbus.xml \\
-                ")
-
 FILE(GLOB DAEMON_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
 
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Winline -g -fno-builtin-malloc -fPIE")
@@ -33,10 +26,16 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,now -Wl,-z,relro")
 
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
 ADD_EXECUTABLE(${DAEMON} ${DAEMON_SOURCE})
-TARGET_LINK_LIBRARIES(${DAEMON} ${DAEMON_PKGS_LDFLAGS} -lm)
+TARGET_LINK_LIBRARIES(${DAEMON}
+       ${DAEMON_PKGS_LDFLAGS}
+       ${COMMON_LIBS}
+       -lm
+)
+TARGET_INCLUDE_DIRECTORIES(${DAEMON} PUBLIC
+       ${CMAKE_CURRENT_SOURCE_DIR}/include
+       ${COMMON_INCLUDES}
+)
 
 # Install
 INSTALL(TARGETS ${DAEMON} DESTINATION ${INSTALL_BIN_DIR})
diff --git a/daemon/src/tizen-things-daemon-dbus.xml b/daemon/src/tizen-things-daemon-dbus.xml
deleted file mode 100644 (file)
index 91b6ee2..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="0.1" encoding="UTF-8" ?>
-
-<!DOCTYPE node PUBLIC
-       "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
-       "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
-
-<node>
-       <interface name="ttsd.worker.dbus">
-
-               <!-- Method definitions -->
-
-               <method name="ttsd_worker_submit_report">
-                       <arg type="s" name="report" direction="in"/>
-                       <arg type="i" name="ret" direction="out"/>
-               </method>
-
-               <!-- We don't need to signals, because of aul_launch -->
-       </interface>
-</node>
-
index 25f44d8..e32dba0 100644 (file)
 #include "ttd-log.h"
 #include "ttd-app-interface.h"
 #include "ttd-http.h"
-
-/* TODO : move this one to common module */
-#define TTD_APP_MSG_DELIMITER "|"
-#define TTD_APP_INF_BUS_NAME "org.tizen.ttd.bus"
-#define TTD_APP_INF_BUS_INF "org.tizen.ttd.bus.appinf"
-#define TTD_APP_INF_OBJECT_PATH "/org/tizen/ttd/bus/appinf/object"
+#include "common-app-inf.h"
 
 #define POST_DATA_URL "http://apitest.showiot.xyz/api/data"
 #define __POST_THREAD_RUN 1
@@ -74,8 +69,7 @@ struct _ttd_app_inf_h {
 static char *
 __get_addr_name(const gchar *token, const gchar *appID, guint appPID)
 {
-       /* TODO : move this one to common module and improve it*/
-       return g_strdup_printf("%5u-%s", appPID, token);
+       return common_make_socket_addr_name(token, appID, appPID);
 }
 
 static gboolean
index dc4cb41..7d90971 100644 (file)
  */
 
 #include <glib.h>
-#include "tizen-things-daemon-dbus.h"
-
 #include "ttd-log.h"
 #include "ttd-worker-interface.h"
-
-#define TTSD_DBUS_OBJECT_PATH "/ttsd_worker_dbus_object"
-#define TTSD_DBUS_NAME "ttsd.worker.dbus"
+#include "common-worker-inf-def.h"
+#include "common-worker-inf-dbus.h"
 
 struct _worker_interface_h {
        guint owner_id;
@@ -78,7 +75,7 @@ static void __on_bus_acquired_cb(GDBusConnection *connection, const gchar *name,
        }
        worker_interface_h h = user_data;
 
-       h->m_server = g_dbus_object_manager_server_new(TTSD_DBUS_OBJECT_PATH);
+       h->m_server = g_dbus_object_manager_server_new(TTSD_WORKER_DBUS_OBJECT_PATH);
        if (!h->m_server) {
                _E("Failed to create dbus server");
                ttd_worker_interface_fini(h);
@@ -93,7 +90,7 @@ static void __on_bus_acquired_cb(GDBusConnection *connection, const gchar *name,
        }
 
        if (!g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(h->dbus_obj),
-                               connection, TTSD_DBUS_OBJECT_PATH, NULL)) {
+                               connection, TTSD_WORKER_DBUS_OBJECT_PATH, NULL)) {
                _E("Failed to export interface with object path");
                ttd_worker_interface_fini(h);
                return;
@@ -126,7 +123,7 @@ int ttd_worker_interface_init(worker_interface_h *h)
        }
 
        _h->owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
-                       TTSD_DBUS_NAME,
+                       TTSD_WORKER_DBUS_NAME,
                        G_BUS_NAME_OWNER_FLAGS_NONE,
                        __on_bus_acquired_cb,
                        __on_name_acquired_cb,
index 5edd4fb..607e85c 100644 (file)
@@ -1,62 +1,4 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
-SET(CMAKE_VERBOSE_MAKEFILE 0)
-SET(LIB libthings-service)
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(LIB_TTS_PKGS REQUIRED
-       glib-2.0
-       gio-unix-2.0
-       dlog
-)
-
-FOREACH (flag ${LIB_TTS_PKGS_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Winline -g")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${INSTALL_LIB_DIR}")
-
-FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
-                " \\
-                --generate-c-code ${CMAKE_SOURCE_DIR}/lib/src/tizen-things-lib-dbus \\
-                ${CMAKE_SOURCE_DIR}/lib/src/tizen-things-lib-dbus.xml \\
-                ")
-
-INCLUDE_DIRECTORIES(${INCLUDE_DIR})
-
-FILE(GLOB LIB_TTS_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
-
-ADD_LIBRARY(${LIB} SHARED ${LIB_TTS_SOURCE})
-TARGET_LINK_LIBRARIES(${LIB} ${LIB_TTS_LDFLAGS})
-
-SET_TARGET_PROPERTIES(${LIB}
-       PROPERTIES
-       VERSION ${FULL_VER}
-       SOVERSION ${MAJOR_VER}
-       CLEAN_DIRECT_OUTPUT 1
-)
-INSTALL(TARGETS ${LIB} DESTINATION ${INSTALL_LIB_DIR})
-
-INSTALL(
-       DIRECTORY ${INCLUDE_DIR}/ DESTINATION ${INSTALL_INC_DIR}
-       FILES_MATCHING
-       PATTERN "*_private.h" EXCLUDE
-       PATTERN "*.h"
-)
-
-# pkg-config file
-SET(PC_DENPS "") # add package name here if you have exposed lib in your library.
-SET(PC_NAME ${LIB})
-SET(PC_REQUIRED ${PC_DENPS})
-SET(PC_LDFLAGS -l${LIB})
-
-CONFIGURE_FILE(
-       ${LIB}.pc.in
-       ${CMAKE_CURRENT_SOURCE_DIR}/${LIB}.pc
-       @ONLY
-)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LIB}.pc DESTINATION ${INSTALL_LIB_DIR}/pkgconfig)
+ADD_SUBDIRECTORY(things-service)
+ADD_SUBDIRECTORY(things-service-worker)
diff --git a/lib/things-service-worker/CMakeLists.txt b/lib/things-service-worker/CMakeLists.txt
new file mode 100644 (file)
index 0000000..790fcf6
--- /dev/null
@@ -0,0 +1,62 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(CMAKE_VERBOSE_MAKEFILE 0)
+SET(LIB things-service-worker)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(LIB_TTS_PKGS REQUIRED
+       glib-2.0
+       gio-unix-2.0
+       dlog
+)
+
+FOREACH (flag ${LIB_TTS_PKGS_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Winline -g")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${INSTALL_LIB_DIR}")
+
+FILE(GLOB LIB_TTS_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
+
+ADD_LIBRARY(${LIB} SHARED ${LIB_TTS_SOURCE})
+TARGET_LINK_LIBRARIES(${LIB}
+       ${LIB_TTS_LDFLAGS}
+       ${COMMON_LIBS}
+)
+
+TARGET_INCLUDE_DIRECTORIES(${LIB}
+       PUBLIC
+       ${CMAKE_CURRENT_SOURCE_DIR}/include
+       ${COMMON_INCLUDES}
+)
+
+SET_TARGET_PROPERTIES(${LIB}
+       PROPERTIES
+       VERSION ${FULL_VER}
+       SOVERSION ${MAJOR_VER}
+       CLEAN_DIRECT_OUTPUT 1
+)
+INSTALL(TARGETS ${LIB} DESTINATION ${INSTALL_LIB_DIR})
+
+INSTALL(
+       DIRECTORY ${INCLUDE_DIR}/ DESTINATION ${INSTALL_INC_DIR}
+       FILES_MATCHING
+       PATTERN "*-private.h" EXCLUDE
+       PATTERN "*.h"
+)
+
+# pkg-config file
+SET(PC_DENPS "") # add package name here if you have exposed lib in your library.
+SET(PC_NAME ${LIB})
+SET(PC_REQUIRED ${PC_DENPS})
+SET(PC_LDFLAGS -l${LIB})
+
+CONFIGURE_FILE(
+       ${LIB}.pc.in
+       ${CMAKE_CURRENT_SOURCE_DIR}/${LIB}.pc
+       @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LIB}.pc DESTINATION ${INSTALL_LIB_DIR}/pkgconfig)
similarity index 94%
rename from lib/src/ttsd-worker-lib.c
rename to lib/things-service-worker/src/ttsd-worker-lib.c
index fe81165..e683f85 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "log.h"
+#include "log-private.h"
 #include "ttsd-worker-lib.h"
-#include "tizen-things-lib-dbus.h"
-
-#define TTSD_WORKER_DBUS_NAME "ttsd.worker.dbus"
-#define TTSD_WORKER_DBUS_OBJECT_PATH "/ttsd_worker_dbus_object"
-#define TTSD_WORKER_DBUS_INTERFACE "ttsd.worker.dbus"
+#include "common-worker-inf-def.h"
+#include "common-worker-inf-dbus.h"
 
 typedef struct {
        GCancellable *cancellable;
diff --git a/lib/things-service/CMakeLists.txt b/lib/things-service/CMakeLists.txt
new file mode 100644 (file)
index 0000000..17291b8
--- /dev/null
@@ -0,0 +1,63 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(CMAKE_VERBOSE_MAKEFILE 0)
+SET(LIB things-service)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(LIB_TTS_PKGS REQUIRED
+       glib-2.0
+       gio-unix-2.0
+       capi-appfw-app-common
+       dlog
+)
+
+FOREACH (flag ${LIB_TTS_PKGS_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Winline -g")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${INSTALL_LIB_DIR}")
+
+FILE(GLOB LIB_TTS_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
+
+ADD_LIBRARY(${LIB} SHARED ${LIB_TTS_SOURCE})
+TARGET_LINK_LIBRARIES(${LIB}
+       ${LIB_TTS_LDFLAGS}
+       ${COMMON_LIBS}
+)
+
+TARGET_INCLUDE_DIRECTORIES(${LIB}
+       PUBLIC
+       ${CMAKE_CURRENT_SOURCE_DIR}/include
+       ${COMMON_INCLUDES}
+)
+
+SET_TARGET_PROPERTIES(${LIB}
+       PROPERTIES
+       VERSION ${FULL_VER}
+       SOVERSION ${MAJOR_VER}
+       CLEAN_DIRECT_OUTPUT 1
+)
+INSTALL(TARGETS ${LIB} DESTINATION ${INSTALL_LIB_DIR})
+
+INSTALL(
+       DIRECTORY ${INCLUDE_DIR}/ DESTINATION ${INSTALL_INC_DIR}
+       FILES_MATCHING
+       PATTERN "*-private.h" EXCLUDE
+       PATTERN "*.h"
+)
+
+# pkg-config file
+SET(PC_DENPS "") # add package name here if you have exposed lib in your library.
+SET(PC_NAME ${LIB})
+SET(PC_REQUIRED ${PC_DENPS})
+SET(PC_LDFLAGS -l${LIB})
+
+CONFIGURE_FILE(
+       ${LIB}.pc.in
+       ${CMAKE_CURRENT_SOURCE_DIR}/${LIB}.pc
+       @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LIB}.pc DESTINATION ${INSTALL_LIB_DIR}/pkgconfig)
diff --git a/lib/things-service/include/log-private.h b/lib/things-service/include/log-private.h
new file mode 100644 (file)
index 0000000..464f099
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __LIB_THINGS_SERVICE_LOG_H__
+#define __LIB_THINGS_SERVICE_LOG_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "LIB-TS"
+
+#if !defined(_V)
+#define _V(fmt, arg...) dlog_print(DLOG_VERBOSE, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_D)
+#define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_I)
+#define _I(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_W)
+#define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#if !defined(_E)
+#define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
+#endif
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+       if (expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return val; \
+       } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+       if (expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retm_if(expr, fmt, arg...) do { \
+       if (expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+#define ret_if(expr) do { \
+       if (expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return; \
+       } \
+} while (0)
+
+#define goto_if(expr, val) do { \
+       if (expr) { \
+               _E("(%s) -> goto", #expr); \
+               goto val; \
+       } \
+} while (0)
+
+#define break_if(expr) { \
+       if (expr) { \
+               _E("(%s) -> break", #expr); \
+               break; \
+       } \
+}
+
+#define continue_if(expr) { \
+       if (expr) { \
+               _E("(%s) -> continue", #expr); \
+               continue; \
+       } \
+}
+
+#endif /* __LIB_THINGS_SERVICE_LOG_H__ */
diff --git a/lib/things-service/include/things-service.h b/lib/things-service/include/things-service.h
new file mode 100644 (file)
index 0000000..5710351
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 __LIB_THINGS_SERVICE_H__
+#define __LIB_THINGS_SERVICE_H__
+
+typedef struct _ts_data *ts_handle;
+
+int things_service_init(ts_handle *handle);
+int things_service_fini(ts_handle handle);
+int things_service_send_data(ts_handle handle, const char *json_data);
+
+#endif /* __LIB_THINGS_SERVICE_H__ */
diff --git a/lib/things-service/src/things-service.c b/lib/things-service/src/things-service.c
new file mode 100644 (file)
index 0000000..9623804
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <gio/gunixsocketaddress.h>
+#include <app_common.h>
+#include "log-private.h"
+#include "things-service.h"
+#include "common-app-inf.h"
+
+struct _ts_data {
+       int padding;
+};
+
+int things_service_init(ts_handle *handle)
+{
+       return 0;
+}
+
+int things_service_fini(ts_handle handle)
+{
+       return 0;
+}
+
+int things_service_send_data(ts_handle handle, const char *json_data)
+{
+       return 0;
+}
\ No newline at end of file
diff --git a/lib/things-service/things-service.pc.in b/lib/things-service/things-service.pc.in
new file mode 100644 (file)
index 0000000..390329b
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=@INSTALL_LIB_DIR@
+includedir=@INSTALL_INC_DIR@
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
index d64baa8..ff5c496 100644 (file)
@@ -19,6 +19,7 @@ BuildRequires:  pkgconfig(json-c)
 BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(openssl)
 BuildRequires:  pkgconfig(capi-appfw-app-control)
+BuildRequires:  pkgconfig(capi-appfw-app-common)
 
 %description
 Tizen Things daemon