init work for daemonization
authorYoungjae Shin <yj99.shin@samsung.com>
Thu, 4 Jun 2015 23:43:26 +0000 (08:43 +0900)
committeryoungman <yman.jung@samsung.com>
Tue, 3 Nov 2015 11:02:27 +0000 (20:02 +0900)
44 files changed:
CMakeLists.txt
common/ic-common.h [moved from lib/ic-common.h with 73% similarity]
common/ic-log.h [moved from lib/ic-log.h with 100% similarity]
daemon/CMakeLists.txt
daemon/icd-dbus.c [new file with mode: 0644]
daemon/icd-dbus.h [new file with mode: 0644]
daemon/icd.c [new file with mode: 0644]
daemon/icd.h [new file with mode: 0644]
daemon/org.tizen.iotcon.service.in [new file with mode: 0644]
lib/CMakeLists.txt
lib/icl-client.c [moved from lib/ic-client.c with 98% similarity]
lib/icl-client.h [moved from lib/ic-client.h with 82% similarity]
lib/icl-device.c [moved from lib/ic-device.c with 97% similarity]
lib/icl-ioty-repr.cpp [moved from lib/ic-ioty-repr.cpp with 96% similarity]
lib/icl-ioty-repr.h [moved from lib/ic-ioty-repr.h with 80% similarity]
lib/icl-ioty.cpp [moved from lib/ic-ioty.cpp with 99% similarity]
lib/icl-ioty.h [moved from lib/ic-ioty.h with 84% similarity]
lib/icl-observation.c [moved from lib/ic-observation.c with 98% similarity]
lib/icl-options.c [moved from lib/ic-options.c with 98% similarity]
lib/icl-options.h [moved from lib/ic-options.h with 82% similarity]
lib/icl-query.c [moved from lib/ic-query.c with 97% similarity]
lib/icl-query.h [moved from lib/ic-query.h with 81% similarity]
lib/icl-repr-list.c [moved from lib/ic-repr-list.c with 99% similarity]
lib/icl-repr-list.h [moved from lib/ic-repr-list.h with 84% similarity]
lib/icl-repr-obj.c [moved from lib/ic-repr-obj.c with 99% similarity]
lib/icl-repr-obj.h [moved from lib/ic-repr-obj.h with 83% similarity]
lib/icl-repr-value.c [moved from lib/ic-repr-value.c with 98% similarity]
lib/icl-repr-value.h [moved from lib/ic-repr-value.h with 89% similarity]
lib/icl-repr.c [moved from lib/ic-repr.c with 98% similarity]
lib/icl-repr.h [moved from lib/ic-repr.h with 89% similarity]
lib/icl-request.c [moved from lib/ic-request.c with 98% similarity]
lib/icl-request.h [moved from lib/ic-request.h with 86% similarity]
lib/icl-resource-types.c [moved from lib/ic-resource-types.c with 98% similarity]
lib/icl-resource-types.h [moved from lib/ic-resource-types.h with 83% similarity]
lib/icl-response.c [moved from lib/ic-response.c with 95% similarity]
lib/icl-response.h [moved from lib/ic-response.h with 82% similarity]
lib/icl-utils.c [moved from lib/ic-utils.c with 95% similarity]
lib/icl-utils.h [moved from lib/ic-utils.h with 80% similarity]
lib/icl.c [moved from lib/ic.c with 98% similarity]
lib/icl.h [moved from lib/ic.h with 63% similarity]
packaging/iotcon.manifest
packaging/iotcon.service [new file with mode: 0644]
packaging/iotcon.spec
packaging/libiotcon.manifest [new file with mode: 0644]

index 7f299ba..4b2bb45 100644 (file)
@@ -3,16 +3,16 @@ PROJECT(iotcon)
 
 INCLUDE(FindPkgConfig)
 
-SET(EXTRA_CFLAGS "-Wall -Werror-implicit-function-declaration -fvisibility=hidden")
+SET(EXTRA_CFLAGS "-Wall -Werror-implicit-function-declaration -fvisibility=hidden -fPIE")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--hash-style=both")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fvisibility=hidden")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--hash-style=both -pie")
 
 SET(CLIENT ${PROJECT_NAME})
 SET(DAEMON "${PROJECT_NAME}-daemon")
 SET(DBUS_INTERFACE "org.tizen.${PROJECT_NAME}")
 
 ADD_SUBDIRECTORY(lib)
-#ADD_SUBDIRECTORY(daemon)
+ADD_SUBDIRECTORY(daemon)
 ADD_SUBDIRECTORY(test)
similarity index 73%
rename from lib/ic-common.h
rename to common/ic-common.h
index 9b71155..50460fa 100644 (file)
 #define __IOT_CONNECTIVITY_MANAGER_INTERNAL_COMMON_H__
 
 #include "iotcon-errors.h"
-#include "ic-log.h"
 
-#ifdef API
-#undef API
+#ifndef IOTCON_DBUS_INTERFACE
+#define IOTCON_DBUS_INTERFACE "org.tizen.IoTCon"
+#warning "IOTCON_DBUS_INTERFACE is redefined"
 #endif
-#define API __attribute__((visibility("default")))
+
+#define IOTCON_DBUS_OBJPATH "/org/tizen/IoTCon/GDBus"
+
+#define IOTCON_DBUS_METHOD1 "subscribe"
+#define IOTCON_DBUS_METHOD2 "subscribe"
+#define IOTCON_DBUS_METHOD3 "subscribe"
 
 #endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_COMMON_H__ */
similarity index 100%
rename from lib/ic-log.h
rename to common/ic-log.h
index 08f7b67..24e310a 100644 (file)
@@ -1,4 +1,5 @@
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/include)
 
 SET(OCLIB "oc")
 SET(OCLOGGER "oc_logger")
@@ -12,7 +13,7 @@ pkg_check_modules(daemon_pkgs REQUIRED gio-2.0 dlog)
 INCLUDE_DIRECTORIES(${daemon_pkgs_INCLUDE_DIRS})
 LINK_DIRECTORIES(${daemon_pkgs_LIBRARY_DIRS})
 
-ADD_DEFINITIONS("-DENOTICE_DBUS_INTERFACE=\"${DBUS_INTERFACE}\"")
+ADD_DEFINITIONS("-DIOTCON_DBUS_INTERFACE=\"${DBUS_INTERFACE}\"")
 
 ADD_EXECUTABLE(${DAEMON} ${DAEMON_SRCS})
 TARGET_LINK_LIBRARIES(${DAEMON} ${daemon_pkgs_LIBRARIES} ${OCLIB} ${OCLOGGER}
diff --git a/daemon/icd-dbus.c b/daemon/icd-dbus.c
new file mode 100644 (file)
index 0000000..3fd9c02
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#include <stdlib.h>
+#include <gio/gio.h>
+
+#include "icd.h"
+#include "icd-dbus.h"
+
+static GDBusConnection *icd_dbus_conn;
+
+int icd_dbus_publish(const char *key, const char *data)
+{
+       gboolean ret;
+       GError *error = NULL;
+       int res = 0;
+       char *path = NULL;
+
+       ret = g_dbus_connection_emit_signal(icd_dbus_conn,
+                       NULL, /* destination bus name */
+                       "/",
+                       IOTCON_DBUS_INTERFACE,
+                       key,
+                       g_variant_new("(s)", data),
+                       &error);
+       if (FALSE == ret)
+       {
+               ERR("g_dbus_connection_emit_signal() Fail(%s)", error->message);
+               g_error_free(error);
+               return -1;
+       }
+
+       if (FALSE == g_dbus_connection_flush_sync(icd_dbus_conn, NULL, &error))
+       {
+               ERR("g_dbus_connection_flush_sync() Fail(%s)", error->message);
+               g_error_free(error);
+       }
+
+       if (path)
+               free(path);
+
+       return 0;
+}
+
+static void _dbus_handle_method_call(GDBusConnection *connection,
+               const gchar *sender,
+               const gchar *object_path,
+               const gchar *interface_name,
+               const gchar *method_name,
+               GVariant *parameters,
+               GDBusMethodInvocation *invocation,
+               gpointer user_data)
+{
+       const gchar *key = NULL;
+
+       if (0 == g_strcmp0(method_name, IOTCON_DBUS_METHOD1)) {
+               g_variant_get(parameters, "(&s)", &key);
+               if (NULL == key) {
+                       ERR("key is NULL");
+                       // TODO: handle error
+               }
+
+               //icd_handler_subscribe(key);
+
+               // TODO: handle disconnect without unsubscribe
+
+               g_dbus_method_invocation_return_value(invocation, NULL);
+       }
+       else if (0 == g_strcmp0(method_name, IOTCON_DBUS_METHOD2)) {
+               g_variant_get(parameters, "(&s)", &key);
+               if (NULL == key) {
+                       ERR("key is NULL");
+                       // TODO: handle error
+               }
+
+               //icd_handler_unsubscribe(key);
+
+               g_dbus_method_invocation_return_value(invocation, NULL);
+       }
+       else if (0 == g_strcmp0(method_name, IOTCON_DBUS_METHOD3)) {
+               const gchar *data = NULL;
+
+               g_variant_get(parameters, "(&s&s)", &key, &data);
+               if (NULL == key) {
+                       ERR("key is NULL");
+                       // TODO: handle error
+               }
+
+               //icd_handler_publish(key, data);
+
+               g_dbus_method_invocation_return_value(invocation, NULL);
+       }
+       else {
+               g_dbus_method_invocation_return_error(invocation,
+                       G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD,
+                       "Method %s is not implemented on interface %s", method_name, interface_name);
+       }
+}
+
+
+static const GDBusInterfaceVTable interface_vtable =
+{
+       _dbus_handle_method_call,
+       NULL,
+       NULL
+};
+
+
+static void _dbus_on_bus_acquired(GDBusConnection *conn, const gchar *name,
+               gpointer user_data)
+{
+       guint registration_id;
+       GError *error = NULL;
+       GDBusNodeInfo *introspection_data = user_data;
+
+       FN_CALL;
+
+       icd_dbus_conn = conn;
+
+       registration_id = g_dbus_connection_register_object(conn,
+               IOTCON_DBUS_OBJPATH,
+               introspection_data->interfaces[0],
+               &interface_vtable,
+               NULL,/* user_data */
+               NULL,/* user_data_free_func */
+               &error);
+       if (0 == registration_id)
+       {
+               ERR("g_dbus_connection_register_object() Fail(%s)", error->message);
+               g_error_free(error);
+       }
+}
+
+static void _dbus_on_name_lost(GDBusConnection *connection, const gchar *name,
+               gpointer user_data)
+{
+       DBG("Lost the name %s", name);
+}
+
+static void _dbus_on_name_acquired(GDBusConnection *connection, const gchar *name,
+               gpointer user_data)
+{
+       DBG("Acquired the name %s", name);
+}
+
+unsigned int icd_dbus_init()
+{
+       guint id;
+       GError *error = NULL;
+       GDBusNodeInfo *introspection_data = NULL;
+
+       const gchar introspection_xml[] =
+       "<node>"
+       "       <interface name='"IOTCON_DBUS_INTERFACE"'>"
+       "               <method name='"IOTCON_DBUS_METHOD1"'>"
+       "                       <arg type='s' name='key' direction='in'/>"
+       "               </method>"
+       "               <method name='"IOTCON_DBUS_METHOD2"'>"
+       "                       <arg type='s' name='key' direction='in'/>"
+       "               </method>"
+       "               <method name='"IOTCON_DBUS_METHOD3"'>"
+       "                       <arg type='s' name='key' direction='in'/>"
+       "                       <arg type='s' name='data' direction='in'/>"
+       "               </method>"
+       "       </interface>"
+       "</node>";
+
+       introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, &error);
+       if (NULL == introspection_data)
+       {
+               ERR("g_dbus_node_info_new_for_xml() Fail(%s)", error->message);
+               g_error_free(error);
+               return -1;
+       }
+
+       id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                       IOTCON_DBUS_INTERFACE,
+                       G_BUS_NAME_OWNER_FLAGS_REPLACE,
+                       _dbus_on_bus_acquired,
+                       _dbus_on_name_acquired,
+                       _dbus_on_name_lost,
+                       introspection_data,
+                       (GDestroyNotify)g_dbus_node_info_unref);
+       if (0 == id)
+       {
+               ERR("g_bus_own_name() Fail");
+               return 0;
+       }
+
+       return id;
+}
+
+void icd_dbus_deinit(unsigned int id)
+{
+       g_bus_unown_name(id);
+}
+
diff --git a/daemon/icd-dbus.h b/daemon/icd-dbus.h
new file mode 100644 (file)
index 0000000..ac9a3e5
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __IOT_CONNECTIVITY_MANAGER_DAEMON_DBUS_H__
+#define __IOT_CONNECTIVITY_MANAGER_DAEMON_DBUS_H__
+
+int icd_dbus_publish(const char *key, const char *data);
+unsigned int icd_dbus_init();
+void icd_dbus_deinit(unsigned int id);
+
+
+#endif //__IOT_CONNECTIVITY_MANAGER_DAEMON_DBUS_H__
diff --git a/daemon/icd.c b/daemon/icd.c
new file mode 100644 (file)
index 0000000..ddf7929
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#include <gio/gio.h>
+
+#include "icd.h"
+#include "icd-dbus.h"
+
+
+int main(int argc, char **argv)
+{
+       guint id;
+       GMainLoop *loop;
+
+#if !GLIB_CHECK_VERSION(2,35,0)
+       g_type_init();
+#endif
+
+       loop = g_main_loop_new(NULL, FALSE);
+
+       id = icd_dbus_init();
+
+       g_main_loop_run(loop);
+
+       icd_dbus_deinit(id);
+       g_main_loop_unref(loop);
+
+       return 0;
+}
diff --git a/daemon/icd.h b/daemon/icd.h
new file mode 100644 (file)
index 0000000..64f0e29
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __IOT_CONNECTIVITY_MANAGER_DAEMON_H__
+#define __IOT_CONNECTIVITY_MANAGER_DAEMON_H__
+
+#include "ic-common.h"
+
+#define IC_DAEMON
+#include "ic-log.h"
+
+
+#endif //__IOT_CONNECTIVITY_MANAGER_DAEMON_H__
diff --git a/daemon/org.tizen.iotcon.service.in b/daemon/org.tizen.iotcon.service.in
new file mode 100644 (file)
index 0000000..cb3f2a2
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=@DBUS_INTERFACE@
+Exec=@BIN_INSTALL_DIR@/@DAEMON@
\ No newline at end of file
index 85859df..d68814e 100644 (file)
@@ -1,3 +1,4 @@
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/)
 INCLUDE_DIRECTORIES(include)
 
 FILE(GLOB CLIENT_SRCS *.c *.cpp)
@@ -6,18 +7,17 @@ pkg_check_modules(client_pkgs REQUIRED glib-2.0 dlog json-glib-1.0 capi-base-com
 INCLUDE_DIRECTORIES(${client_pkgs_INCLUDE_DIRS})
 LINK_DIRECTORIES(${client_pkgs_LIBRARY_DIRS})
 
-ADD_DEFINITIONS("-DENOTICE_DBUS_INTERFACE=\"${DBUS_INTERFACE}\"")
+ADD_DEFINITIONS("-DIOTCON_DBUS_INTERFACE=\"${DBUS_INTERFACE}\"")
 
 ADD_LIBRARY(${CLIENT} SHARED ${CLIENT_SRCS})
-TARGET_LINK_LIBRARIES(${CLIENT}
-       ${client_pkgs_LIBRARIES}
+TARGET_LINK_LIBRARIES(${CLIENT}        ${client_pkgs_LIBRARIES}
        oc octbstack coap oc_logger_core oc_logger pthread)
 SET_TARGET_PROPERTIES(${CLIENT} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER})
 INSTALL(TARGETS ${CLIENT} DESTINATION ${LIB_INSTALL_DIR})
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 CONFIGURE_FILE(${CLIENT}.pc.in ${CLIENT}.pc @ONLY)
-INSTALL(FILES ${CLIENT}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(FILES ${CLIENT}.pc DESTINATION lib/pkgconfig)
 
 FILE(GLOB CLIENT_HEADER include/*.h)
 INSTALL(FILES ${CLIENT_HEADER} DESTINATION ${INCLUDE_INSTALL_DIR}/${CLIENT})
similarity index 98%
rename from lib/ic-client.c
rename to lib/icl-client.c
index a3af898..6a5b286 100644 (file)
 #include <glib.h>
 
 #include "iotcon-struct.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-ioty.h"
-#include "ic-options.h"
-#include "ic-resource-types.h"
-#include "ic-client.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-ioty.h"
+#include "icl-options.h"
+#include "icl-resource-types.h"
+#include "icl-client.h"
 
 /* host address should begin with "coap://"
  * The length of resource_type should be less than or equal to 61.
similarity index 82%
rename from lib/ic-client.h
rename to lib/icl-client.h
index d642b96..8ff8df1 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_CLIENT_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_CLIENT_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_CLIENT_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_CLIENT_H__
 
 #include "iotcon-struct.h"
-#include "ic-options.h"
+#include "icl-options.h"
 
 typedef void* iotcon_observe_h;
 
@@ -32,4 +32,4 @@ struct ic_remote_resource {
        iotcon_observe_h observe_handle;
 };
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_CLIENT_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_CLIENT_H__ */
similarity index 97%
rename from lib/ic-device.c
rename to lib/icl-device.c
index 413291a..b8f1702 100644 (file)
@@ -19,8 +19,8 @@
 #include <glib.h>
 
 #include "iotcon.h"
-#include "ic-common.h"
-#include "ic-ioty.h"
+#include "icl.h"
+#include "icl-ioty.h"
 
 /* The length of manufacturer_name should be less than and equal to 16.
  * The length of manufacturer_url should be less than and equal to 32. */
similarity index 96%
rename from lib/ic-ioty-repr.cpp
rename to lib/icl-ioty-repr.cpp
index 201d870..f611a8e 100644 (file)
 
 extern "C" {
 #include "iotcon-struct.h"
-#include "ic.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-repr.h"
-#include "ic-ioty-repr.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-repr.h"
+#include "icl-ioty-repr.h"
 }
 
 using namespace OC;
similarity index 80%
rename from lib/ic-ioty-repr.h
rename to lib/icl-ioty-repr.h
index 8888130..0a6f774 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_IOTIVITY_REPRESENTATION_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_IOTIVITY_REPRESENTATION_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_REPRESENTATION_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_REPRESENTATION_H__
 
 #include <OCRepresentation.h>
 #include "iotcon-struct.h"
@@ -23,5 +23,5 @@ void ic_ioty_repr_found_device_cb(const OC::OCRepresentation& ocRep);
 iotcon_repr_h ic_ioty_repr_generate_repr(const OC::OCRepresentation& ocRep);
 int ic_ioty_repr_parse(iotcon_repr_h repr, OC::OCRepresentation &ocRep);
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_IOTIVITY_REPRESENTATION_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_REPRESENTATION_H__ */
 
similarity index 99%
rename from lib/ic-ioty.cpp
rename to lib/icl-ioty.cpp
index ef94ff7..4971f24 100644 (file)
 
 extern "C" {
 #include "iotcon-struct.h"
-#include "ic.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-client.h"
-#include "ic-request.h"
-#include "ic-response.h"
-#include "ic-resource-types.h"
-#include "ic-repr.h"
-#include "ic-ioty-repr.h"
-#include "ic-ioty.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-client.h"
+#include "icl-request.h"
+#include "icl-response.h"
+#include "icl-resource-types.h"
+#include "icl-repr.h"
+#include "icl-ioty-repr.h"
+#include "icl-ioty.h"
 }
 
 #define IC_UNICAST_RESOURCE_DISCOVERY ":5683/oc/core"
similarity index 84%
rename from lib/ic-ioty.h
rename to lib/icl-ioty.h
index 394ffc2..fa51691 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_IOTIVITY_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_IOTIVITY_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_H__
 
 #include <stdint.h>
 
 #include "iotcon.h"
-#include "ic.h"
-#include "ic-response.h"
+#include "icl-response.h"
+
+struct ic_notify_msg {
+       int error_code;
+       iotcon_interface_e iface;
+       iotcon_repr_h repr;
+};
+
+struct ic_resource {
+       char *uri;
+       char *host;
+       bool is_observable;
+       iotcon_resource_types_h types;
+       int ifaces;
+       void *handle;
+       iotcon_request_handler_cb cb;
+       void *user_data;
+       iotcon_resource_h children[IOTCON_CONTAINED_RESOURCES_MAX];
+};
 
 void ic_ioty_config(const char *addr, unsigned short port);
 
@@ -44,7 +61,6 @@ int ic_ioty_get_device_info(const char *host_address, iotcon_device_info_cb cb,
 
 int ic_ioty_send_notify(void *resource, struct ic_notify_msg *msg,
                iotcon_observers_h observers);
-
 int ic_ioty_send_res_response_data(struct ic_resource_response *resp);
 
 const iotcon_presence_h ic_ioty_subscribe_presence(const char *host_address,
@@ -79,4 +95,4 @@ int ic_ioty_convert_interface_flag(iotcon_interface_e src, char **dest);
 int ic_ioty_convert_interface_string(const char *src, iotcon_interface_e *dest);
 
 
-#endif //__IOT_CONNECTIVITY_MANAGER_INTERNAL_IOTIVITY_H__
+#endif //__IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_H__
similarity index 98%
rename from lib/ic-observation.c
rename to lib/icl-observation.c
index 2bd76af..baef149 100644 (file)
@@ -18,7 +18,7 @@
 #include <glib.h>
 
 #include "iotcon-struct.h"
-#include "ic-common.h"
+#include "icl.h"
 
 API void iotcon_observers_free(iotcon_observers_h observers)
 {
similarity index 98%
rename from lib/ic-options.c
rename to lib/icl-options.c
index a5fb1bd..b63c3d2 100644 (file)
@@ -19,9 +19,9 @@
 #include <glib.h>
 
 #include "iotcon-struct.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-options.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-options.h"
 
 API iotcon_options_h iotcon_options_new()
 {
similarity index 82%
rename from lib/ic-options.h
rename to lib/icl-options.h
index caa44e2..c38e31d 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_OPTIONS_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_OPTIONS_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_OPTIONS_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_OPTIONS_H__
 
 #include "iotcon-struct.h"
 
@@ -26,4 +26,4 @@ struct ic_options {
 void ic_options_free(iotcon_options_h options);
 iotcon_options_h ic_options_ref(iotcon_options_h options);
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_OPTIONS_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_OPTIONS_H__ */
similarity index 97%
rename from lib/ic-query.c
rename to lib/icl-query.c
index abb2cdc..25efcd1 100644 (file)
@@ -20,9 +20,9 @@
 #include <glib.h>
 
 #include "iotcon-struct.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-query.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-query.h"
 
 API iotcon_query_h iotcon_query_new()
 {
similarity index 81%
rename from lib/ic-query.h
rename to lib/icl-query.h
index b8325fb..873c1a5 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_QUERY_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_QUERY_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_QUERY_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_QUERY_H__
 
 #include "iotcon-struct.h"
 
@@ -23,4 +23,4 @@ struct ic_query {
        GHashTable *hash;
 };
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_QUERY_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_QUERY_H__ */
similarity index 99%
rename from lib/ic-repr-list.c
rename to lib/icl-repr-list.c
index ca8bfa4..1810d92 100644 (file)
 #include "iotcon-struct.h"
 #include "iotcon-constant.h"
 #include "iotcon-representation.h"
-#include "ic-common.h"
-#include "ic-repr-obj.h"
-#include "ic-repr.h"
-#include "ic-repr-value.h"
-#include "ic-repr-list.h"
+#include "icl.h"
+#include "icl-repr-obj.h"
+#include "icl-repr.h"
+#include "icl-repr-value.h"
+#include "icl-repr-list.h"
 
 void ic_list_inc_ref_count(iotcon_list_h val)
 {
similarity index 84%
rename from lib/ic-repr-list.h
rename to lib/icl-repr-list.h
index 4af567d..62ddb92 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_LIST_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_LIST_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_LIST_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_LIST_H__
 
 #include <glib.h>
 #include <json-glib/json-glib.h>
@@ -37,4 +37,4 @@ iotcon_list_h ic_list_clone(iotcon_list_h list);
 
 void ic_list_inc_ref_count(iotcon_list_h val);
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_LIST_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_LIST_H__ */
similarity index 99%
rename from lib/ic-repr-obj.c
rename to lib/icl-repr-obj.c
index 7f3c287..be9db54 100644 (file)
 #include "iotcon-struct.h"
 #include "iotcon-constant.h"
 #include "iotcon-representation.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-repr-list.h"
-#include "ic-repr-value.h"
-#include "ic-repr.h"
-#include "ic-repr-obj.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-repr-list.h"
+#include "icl-repr-value.h"
+#include "icl-repr.h"
+#include "icl-repr-obj.h"
 
 int ic_obj_del_value(iotcon_repr_h repr, const char *key,
                iotcon_types_e value_type)
similarity index 83%
rename from lib/ic-repr-obj.h
rename to lib/icl-repr-obj.h
index a9ffbad..43a9438 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_OBJECT_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_OBJECT_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_OBJECT_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_OBJECT_H__
 
 #include <json-glib/json-glib.h>
 
@@ -30,4 +30,4 @@ int ic_obj_set_value(iotcon_repr_h repr, const char *key, iotcon_value_h value);
 JsonObject* ic_obj_to_json(iotcon_repr_h repr);
 iotcon_repr_h ic_obj_from_json(JsonObject *obj);
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_OBJECT_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_OBJECT_H__ */
similarity index 98%
rename from lib/ic-repr-value.c
rename to lib/icl-repr-value.c
index e6672cc..f2e63d2 100644 (file)
 
 #include "iotcon-struct.h"
 #include "iotcon-representation.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-repr.h"
-#include "ic-repr-list.h"
-#include "ic-repr-value.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-repr.h"
+#include "icl-repr-list.h"
+#include "icl-repr-value.h"
 
 static iotcon_value_h _ic_value_new(int type)
 {
similarity index 89%
rename from lib/ic-repr-value.h
rename to lib/icl-repr-value.h
index 6b92cef..7828495 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_VALUE_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_VALUE_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_VALUE_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_VALUE_H__
 
 #include <stdbool.h>
 #include <json-glib/json-glib.h>
@@ -68,4 +68,4 @@ void ic_value_free(gpointer data);
 
 iotcon_value_h ic_value_clone(iotcon_value_h src);
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_VALUE_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_VALUE_H__ */
similarity index 98%
rename from lib/ic-repr.c
rename to lib/icl-repr.c
index 62d0d17..dd56c57 100644 (file)
 
 #include "iotcon-struct.h"
 #include "iotcon-representation.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-resource-types.h"
-#include "ic-ioty.h"
-#include "ic.h"
-#include "ic-repr-list.h"
-#include "ic-repr-value.h"
-#include "ic-repr-obj.h"
-#include "ic-repr.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-resource-types.h"
+#include "icl-ioty.h"
+#include "icl-repr-list.h"
+#include "icl-repr-value.h"
+#include "icl-repr-obj.h"
+#include "icl-repr.h"
 
 void ic_repr_inc_ref_count(iotcon_repr_h val)
 {
similarity index 89%
rename from lib/ic-repr.h
rename to lib/icl-repr.h
index 0476652..dc20da2 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_H__
 
 #include <stdbool.h>
 #include <glib.h>
@@ -55,4 +55,4 @@ iotcon_repr_h ic_repr_parse_json(const char *json_string);
 
 void ic_repr_inc_ref_count(iotcon_repr_h val);
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_REPRESENTATION_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_REPRESENTATION_H__ */
similarity index 98%
rename from lib/ic-request.c
rename to lib/icl-request.c
index a9ac5d7..3fbc27b 100644 (file)
@@ -15,8 +15,8 @@
  */
 #include "iotcon-struct.h"
 #include "iotcon-constant.h"
-#include "ic-common.h"
-#include "ic-request.h"
+#include "icl.h"
+#include "icl-request.h"
 
 /* The content of the request should not be freed by user. */
 API int iotcon_request_get_uri(iotcon_request_h request, char **uri)
similarity index 86%
rename from lib/ic-request.h
rename to lib/icl-request.h
index eee1a82..17629fa 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_REQUEST_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_REQUEST_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_REQUEST_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_REQUEST_H__
 
 #include "iotcon-struct.h"
 #include "iotcon-constant.h"
@@ -39,4 +39,4 @@ struct ic_resource_request {
        oc_resource_h resource_handle;
 };
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_REQUEST_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_REQUEST_H__ */
similarity index 98%
rename from lib/ic-resource-types.c
rename to lib/icl-resource-types.c
index 6b28fb7..bee4254 100644 (file)
@@ -20,9 +20,9 @@
 
 #include "iotcon-struct.h"
 #include "iotcon-constant.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-resource-types.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-resource-types.h"
 
 iotcon_resource_types_h ic_resource_types_ref(iotcon_resource_types_h types)
 {
similarity index 83%
rename from lib/ic-resource-types.h
rename to lib/icl-resource-types.h
index 0f0a30a..77307bf 100644 (file)
@@ -13,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_RESOURCE_TYPES_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_RESOURCE_TYPES_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_TYPES_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_TYPES_H__
 
 #include "iotcon-struct.h"
 
@@ -27,4 +27,4 @@ iotcon_resource_types_h ic_resource_types_ref(iotcon_resource_types_h res_types)
 const char* ic_resource_types_get_nth_data(iotcon_resource_types_h res_types, int index);
 unsigned int ic_resource_types_get_length(iotcon_resource_types_h res_types);
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_RESOURCE_TYPES_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_TYPES_H__ */
similarity index 95%
rename from lib/ic-response.c
rename to lib/icl-response.c
index 8965f92..82bd46c 100644 (file)
 #include <glib.h>
 
 #include "iotcon.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-ioty.h"
-#include "ic-repr.h"
-#include "ic-options.h"
-#include "ic-request.h"
-#include "ic-response.h"
+#include "icl.h"
+#include "icl-utils.h"
+#include "icl-ioty.h"
+#include "icl-repr.h"
+#include "icl-options.h"
+#include "icl-request.h"
+#include "icl-response.h"
 
 API iotcon_response_h iotcon_response_new(iotcon_request_h request_h)
 {
similarity index 82%
rename from lib/ic-response.h
rename to lib/icl-response.h
index 3bbf70b..3d436f7 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_RESPONSE_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_RESPONSE_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESPONSE_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESPONSE_H__
 
 #include "iotcon-struct.h"
 #include "iotcon-constant.h"
-#include "ic-request.h"
+#include "icl-request.h"
 
 struct ic_resource_response {
        char *new_uri;
@@ -31,4 +31,4 @@ struct ic_resource_response {
        oc_resource_h resource_handle;
 };
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_RESPONSE_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESPONSE_H__ */
similarity index 95%
rename from lib/ic-utils.c
rename to lib/icl-utils.c
index dc05f58..072fab4 100644 (file)
@@ -18,8 +18,8 @@
 #include <errno.h>
 
 #include "iotcon.h"
-#include "ic-common.h"
-#include "ic-utils.h"
+#include "icl.h"
+#include "icl-utils.h"
 
 char* ic_utils_strdup(const char *src)
 {
similarity index 80%
rename from lib/ic-utils.h
rename to lib/icl-utils.h
index cba63b6..ce95e9d 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_UTILITY_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_UTILITY_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_UTILITY_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_UTILITY_H__
 
 #define IC_STR_EQUAL 0
 
 char* ic_utils_strdup(const char *src);
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_UTILITY_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_UTILITY_H__ */
similarity index 98%
rename from lib/ic.c
rename to lib/icl.c
index 77b1844..59e66d3 100644 (file)
--- a/lib/ic.c
+++ b/lib/icl.c
 #include <glib-object.h>
 
 #include "iotcon.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "ic-resource-types.h"
-#include "ic-ioty.h"
-#include "ic-repr.h"
-#include "ic.h"
+#include "icl-utils.h"
+#include "icl-resource-types.h"
+#include "icl-ioty.h"
+#include "icl-repr.h"
+#include "icl.h"
 
 /**
  * @brief global context
similarity index 63%
rename from lib/ic.h
rename to lib/icl.h
index d97e96f..fc1ae29 100644 (file)
--- a/lib/ic.h
+++ b/lib/icl.h
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_H__
-#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_H__
 
 #include "iotcon.h"
+#include "ic-common.h"
+#include "ic-log.h"
+
+#ifdef API
+#undef API
+#endif
+#define API __attribute__((visibility("default")))
+
 
 #define IC_INTERFACE_MAX (IOTCON_INTERFACE_DEFAULT | IOTCON_INTERFACE_LINK | \
                IOTCON_INTERFACE_BATCH | IOTCON_INTERFACE_GROUP)
 
-struct ic_resource {
-       char *uri;
-       char *host;
-       bool is_observable;
-       iotcon_resource_types_h types;
-       int ifaces;
-       void *handle;
-       iotcon_request_handler_cb cb;
-       void *user_data;
-       iotcon_resource_h children[IOTCON_CONTAINED_RESOURCES_MAX];
-};
-
-struct ic_notify_msg {
-       int error_code;
-       iotcon_interface_e iface;
-       iotcon_repr_h repr;
-};
 
 iotcon_resource_h ic_get_resource_handler_data(void *handle);
 
-#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_H__ */
+#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_H__ */
index 5e0c7a6..8edd8d6 100644 (file)
@@ -6,18 +6,16 @@
                        <smack permit="dbus" type="rwx" />
                        <smack permit="system::use_internet" type="rw" />
                        <smack permit="connman::get" type="rw" />
+                       <smack permit="libiotcon" type="rwx" />
                </permit>
                <request>
                        <smack request="connman::get" type="rw" />
                        <smack request="dbus" type="rwx" />
+                       <smack request="libiotcon" type="rwxt" />
                        <smack request="_" type="rw" />
                        <smack request="system::use_internet" type="rw" />
                </request>
        </define>
-       <assign>
-               <filesystem path="/usr/lib/libiotcon.so*" label="_" exec_label="_"/>
-       </assign>
-
        <request>
                <domain name="iotcon" />
        </request>
diff --git a/packaging/iotcon.service b/packaging/iotcon.service
new file mode 100644 (file)
index 0000000..243a64b
--- /dev/null
@@ -0,0 +1,12 @@
+[Unit]
+Description=IoT Connectivity Manager
+After=system-server.service
+Requires=system-server.service
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/iotcon-daemon
+KillSignal=SIGKILL
+
+[Install]
+WantedBy=multi-user.target
index 10d6899..33c7e4b 100644 (file)
@@ -5,7 +5,9 @@ Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
+Source1:    %{name}.service
 Source1001: %{name}.manifest
+Source1002: lib%{name}.manifest
 BuildRequires:  cmake
 BuildRequires:  boost-devel
 BuildRequires:  iotivity-devel
@@ -13,22 +15,44 @@ BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(json-glib-1.0)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(capi-base-common)
-
+%define _unitdir /usr/lib/systemd/system
 
 %description
-IoT Connectivity Manager and Library
+IoT Connectivity Manager Daemon
+
+
+%package lib
+Summary:    IoT Connectivity Library
+Group:      Network & Connectivity/Libraries
+Requires:   %{name} = %{version}
+
+%description lib
+Tizen event notification service Client library for applications.
+
 
 %package devel
 Summary:    IoT Connectivity Manager (devel)
 Group:      Network & Connectivity/Development
-Requires:   %{name} = %{version}
+Requires:   %{name}-lib = %{version}
 
 %description devel
 IoT Connectivity Manager development Kit
 
+
+%package test
+Summary:    IoT Connectivity Manager (test)
+Group:      Network & Connectivity/Development
+Requires:   %{name}-lib = %{version}
+
+%description test
+IoT Connectivity Manager Test Programs
+
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
+cp %{SOURCE1002} .
+
 
 %build
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
@@ -36,26 +60,57 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 
 
 %install
+rm -rf %{buildroot}/BUILD/%{name}*
 %make_install
 
-%post -p /sbin/ldconfig
+mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
+cp -af %{SOURCE1} %{buildroot}%{_unitdir}/
+ln -s ../%{name}.service %{buildroot}%{_unitdir}/multi-user.target.wants/%{name}.service
+
+%post
+systemctl daemon-reload
+if [ $1 == 1 ]; then
+    systemctl restart %{name}.service
+fi
+
+%postun
+/sbin/ldconfig
+if [ $1 == 0 ]; then
+    systemctl stop %{name}.service
+fi
+systemctl daemon-reload
+
+
+%post lib -p /sbin/ldconfig
+%postun lib -p /sbin/ldconfig
 
-%postun -p /sbin/ldconfig
 
 %files
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
+%{_unitdir}/%{name}.service
+%{_unitdir}/multi-user.target.wants/%{name}.service
+%{_bindir}/%{name}-daemon
+%{_datadir}/dbus-1/services/org.tizen.%{name}.service
+%license LICENSE.APLv2
+
+%files lib
+%manifest lib%{name}.manifest
+%defattr(-,root,root,-)
 %{_libdir}/lib%{name}.so.*
 %license LICENSE.APLv2
-%{_bindir}/crud-test-client
-%{_bindir}/crud-test-server
-%{_bindir}/device-test-client
-%{_bindir}/device-test-server
-%{_bindir}/repr-test-client
-%{_bindir}/repr-test-server
 
 %files devel
+%defattr(-,root,root,-)
 %{_libdir}/lib%{name}.so
 %{_libdir}/pkgconfig/%{name}.pc
 %{_includedir}/%{name}/*.h
 
+%files test
+%defattr(-,root,root,-)
+%{_bindir}/crud-test-client
+%{_bindir}/crud-test-server
+%{_bindir}/device-test-client
+%{_bindir}/device-test-server
+%{_bindir}/repr-test-client
+%{_bindir}/repr-test-server
diff --git a/packaging/libiotcon.manifest b/packaging/libiotcon.manifest
new file mode 100644 (file)
index 0000000..3ba0099
--- /dev/null
@@ -0,0 +1,20 @@
+<manifest>
+       <define>
+               <domain name="libiotcon" />
+               <permit>
+                       <smack permit="_" type="rw" />
+                       <smack permit="dbus" type="rwx" />
+               </permit>
+               <request>
+                       <smack request="dbus" type="rwx" />
+                       <smack request="_" type="rw" />
+                       <smack request="enotice" type="rwxat" />
+               </request>
+       </define>
+       <assign>
+               <filesystem path="/usr/lib/libiotcon.so*" label="_" exec_label="_"/>
+       </assign>
+       <request>
+               <domain name="libiotcon" />
+       </request>
+</manifest>