INCLUDE(FindPkgConfig)
pkg_check_modules(DAEMON_PKGS REQUIRED
- glib-2.0
- dlog
libtzplatform-config
+ gio-2.0
+ gio-unix-2.0
)
FOREACH (flag ${DAEMON_PKGS_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}/src/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-ADD_EXECUTABLE(${DAEMON} ${DAEMON_SOURCE})
+ADD_CUSTOM_COMMAND(
+ WORKING_DIRECTORY
+ OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/tizen-things-daemon-dbus.c
+ COMMAND gdbus-codegen
+ --generate-c-code tizen-things-daemon-dbus
+ --c-generate-object-manager
+ --generate-docbook generated-docs
+ ${CMAKE_CURRENT_SOURCE_DIR}/tizen-things-daemon-dbus.xml
+ COMMENT "Generating GDBus .c/.h")
+
+
+
+ADD_EXECUTABLE(${DAEMON} ${DAEMON_SOURCE} ${CMAKE_CURRENT_SOURCE_DIR}/tizen-things-daemon-dbus.c)
TARGET_LINK_LIBRARIES(${DAEMON} ${DAEMON_PKGS_LDFLAGS} -lm)
# Install
* limitations under the License.
*/
-
int main(int argc, char* argv[])
{
--- /dev/null
+<?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>
+
INCLUDE(FindPkgConfig)
pkg_check_modules(LIB_TTS_PKGS REQUIRED
glib-2.0
+ dbus-1
+ gio-2.0
dlog
)
--- /dev/null
+/*
+ * 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 __TT_DAEMON_SYS_INFO_LOG_H__
+#define __TT_DAEMON_SYS_INFO_LOG_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TTSD_LIB"
+
+#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 /* __TT_DAEMON_SYS_INFO_LOG_H__ */
+++ /dev/null
-#ifndef __TT_SERVICE_LIB_H__
-#define __TT_SERVICE_LIB_H__
-
-int test_API(void);
-
-#endif /* __TT_SERVICE_LIB_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Junkyu Han <junkyu.han@samsung.com>
+ *
+ * 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 __TTSD_WORKER_LIB_H__
+#define __TTSD_WORKER_LIB_H__
+
+int ttsd_worker_submit_report(char *report);
+
+#endif /* __TTSD_WORKER_LIB_H__ */
+++ /dev/null
-#include <glib.h>
-
-int test_API(void)
-{
- return 0;
-}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Junkyu Han <junkyu.han@samsung.com>
+ *
+ * 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>
+#include <gio/gio.h>
+
+#include "log.h"
+#include "ttsd-worker-lib.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"
+
+typedef struct {
+ GCancellable *cancellable;
+ GDBusConnection *client_bus;
+ GDBusProxy *client_bus_proxy;
+} dbus_h;
+
+static dbus_h *__make_dbus_connection(void);
+static void __destroy_dbus_connection(dbus_h *h);
+
+static void __destroy_dbus_connection(dbus_h *h)
+{
+ _D("Destory the DBus Connection");
+ if (h->cancellable) {
+ g_cancellable_cancel(h->cancellable);
+ g_object_unref(h->cancellable);
+ }
+ if (h->client_bus_proxy) {
+ g_object_unref(h->client_bus_proxy);
+ }
+ if (h->client_bus) {
+ g_object_unref(h->client_bus);
+ }
+}
+
+static dbus_h *__make_dbus_connection(void)
+{
+ dbus_h *h = NULL;
+ GError *error = NULL;
+
+ _D("Make the DBus Connection");
+
+ h = malloc(sizeof(dbus_h));
+ if (!h)
+ return NULL;
+
+ h->cancellable = g_cancellable_new();
+
+ h->client_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, h->cancellable, &error);
+ if (!h->client_bus) {
+ if (error)
+ _E("Couldn't connect to the System bus[%s]", error->message);
+ goto ERROR;
+ }
+
+ h->client_bus_proxy = g_dbus_proxy_new_sync(h->client_bus, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, TTSD_WORKER_DBUS_NAME, TTSD_WORKER_DBUS_OBJECT_PATH,
+ TTSD_WORKER_DBUS_INTERFACE, h->cancellable, &error);
+ if (!h->client_bus_proxy) {
+ if (error)
+ _E("Fail to create the proxy object because of %s", error->message);
+ goto ERROR;
+ }
+
+ return h;
+
+ERROR:
+ if (error)
+ g_error_free(error);
+
+ __destroy_dbus_connection(h);
+
+ return NULL;
+}
+
+int ttsd_worker_submit_report(char *report)
+{
+ dbus_h *h = NULL;
+ GError *g_error = NULL;
+
+ h = __make_dbus_connection();
+ if (!h) {
+ _E("Failed to make dbus connection");
+ return -1;
+ }
+
+ g_dbus_proxy_call_sync(h->client_bus_proxy, "ttsd_worker_submit_report",
+ g_variant_new("(s)", report), G_DBUS_CALL_FLAGS_NONE, -1, h->cancellable, &g_error);
+
+ if (g_error) {
+ _E("DBus proxy call is failed[%s]", g_error->message);
+ g_error_free(g_error);
+ return -1;
+ }
+
+ __destroy_dbus_connection(h);
+
+ return 0;
+}
[Unit]
-Description=Things Daemon
+Description=Things Service Daemon
[Service]
Type=idle
License: Flora-1.1
Provides: %{name} = %{version}-%{release}
Source0: %{name}-%{version}.tar.gz
-Source1: %{name}.service
+Source1: %{name}.service
BuildRequires: cmake
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(ecore)
BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(gio-unix-2.0)
BuildRequires: pkgconfig(libtzplatform-config)
%description