From ce8f906d0be8a7522505df25453a26ea659678f4 Mon Sep 17 00:00:00 2001 From: Youngjae Shin Date: Fri, 5 Jun 2015 08:43:26 +0900 Subject: [PATCH] init work for daemonization --- CMakeLists.txt | 8 +- {lib => common}/ic-common.h | 13 +- {lib => common}/ic-log.h | 0 daemon/CMakeLists.txt | 5 +- daemon/icd-dbus.c | 209 ++++++++++++++++++++++ daemon/icd-dbus.h | 24 +++ daemon/icd.c | 41 +++++ daemon/icd.h | 25 +++ daemon/org.tizen.iotcon.service.in | 3 + lib/CMakeLists.txt | 8 +- lib/{ic-client.c => icl-client.c} | 12 +- lib/{ic-client.h => icl-client.h} | 8 +- lib/{ic-device.c => icl-device.c} | 4 +- lib/{ic-ioty-repr.cpp => icl-ioty-repr.cpp} | 9 +- lib/{ic-ioty-repr.h => icl-ioty-repr.h} | 6 +- lib/{ic-ioty.cpp => icl-ioty.cpp} | 19 +- lib/{ic-ioty.h => icl-ioty.h} | 28 ++- lib/{ic-observation.c => icl-observation.c} | 2 +- lib/{ic-options.c => icl-options.c} | 6 +- lib/{ic-options.h => icl-options.h} | 6 +- lib/{ic-query.c => icl-query.c} | 6 +- lib/{ic-query.h => icl-query.h} | 6 +- lib/{ic-repr-list.c => icl-repr-list.c} | 10 +- lib/{ic-repr-list.h => icl-repr-list.h} | 6 +- lib/{ic-repr-obj.c => icl-repr-obj.c} | 12 +- lib/{ic-repr-obj.h => icl-repr-obj.h} | 6 +- lib/{ic-repr-value.c => icl-repr-value.c} | 10 +- lib/{ic-repr-value.h => icl-repr-value.h} | 6 +- lib/{ic-repr.c => icl-repr.c} | 17 +- lib/{ic-repr.h => icl-repr.h} | 6 +- lib/{ic-request.c => icl-request.c} | 4 +- lib/{ic-request.h => icl-request.h} | 6 +- lib/{ic-resource-types.c => icl-resource-types.c} | 6 +- lib/{ic-resource-types.h => icl-resource-types.h} | 6 +- lib/{ic-response.c => icl-response.c} | 14 +- lib/{ic-response.h => icl-response.h} | 8 +- lib/{ic-utils.c => icl-utils.c} | 4 +- lib/{ic-utils.h => icl-utils.h} | 6 +- lib/{ic.c => icl.c} | 11 +- lib/{ic.h => icl.h} | 31 ++-- packaging/iotcon.manifest | 6 +- packaging/iotcon.service | 12 ++ packaging/iotcon.spec | 77 ++++++-- packaging/libiotcon.manifest | 20 +++ 44 files changed, 564 insertions(+), 168 deletions(-) rename {lib => common}/ic-common.h (73%) rename {lib => common}/ic-log.h (100%) create mode 100644 daemon/icd-dbus.c create mode 100644 daemon/icd-dbus.h create mode 100644 daemon/icd.c create mode 100644 daemon/icd.h create mode 100644 daemon/org.tizen.iotcon.service.in rename lib/{ic-client.c => icl-client.c} (98%) rename lib/{ic-client.h => icl-client.h} (82%) rename lib/{ic-device.c => icl-device.c} (97%) rename lib/{ic-ioty-repr.cpp => icl-ioty-repr.cpp} (96%) rename lib/{ic-ioty-repr.h => icl-ioty-repr.h} (80%) rename lib/{ic-ioty.cpp => icl-ioty.cpp} (99%) rename lib/{ic-ioty.h => icl-ioty.h} (84%) rename lib/{ic-observation.c => icl-observation.c} (98%) rename lib/{ic-options.c => icl-options.c} (98%) rename lib/{ic-options.h => icl-options.h} (82%) rename lib/{ic-query.c => icl-query.c} (97%) rename lib/{ic-query.h => icl-query.h} (81%) rename lib/{ic-repr-list.c => icl-repr-list.c} (99%) rename lib/{ic-repr-list.h => icl-repr-list.h} (84%) rename lib/{ic-repr-obj.c => icl-repr-obj.c} (99%) rename lib/{ic-repr-obj.h => icl-repr-obj.h} (83%) rename lib/{ic-repr-value.c => icl-repr-value.c} (98%) rename lib/{ic-repr-value.h => icl-repr-value.h} (89%) rename lib/{ic-repr.c => icl-repr.c} (98%) rename lib/{ic-repr.h => icl-repr.h} (89%) rename lib/{ic-request.c => icl-request.c} (98%) rename lib/{ic-request.h => icl-request.h} (86%) rename lib/{ic-resource-types.c => icl-resource-types.c} (98%) rename lib/{ic-resource-types.h => icl-resource-types.h} (83%) rename lib/{ic-response.c => icl-response.c} (95%) rename lib/{ic-response.h => icl-response.h} (82%) rename lib/{ic-utils.c => icl-utils.c} (95%) rename lib/{ic-utils.h => icl-utils.h} (80%) rename lib/{ic.c => icl.c} (98%) rename lib/{ic.h => icl.h} (63%) create mode 100644 packaging/iotcon.service create mode 100644 packaging/libiotcon.manifest diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f299ba..4b2bb45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/lib/ic-common.h b/common/ic-common.h similarity index 73% rename from lib/ic-common.h rename to common/ic-common.h index 9b71155..50460fa 100644 --- a/lib/ic-common.h +++ b/common/ic-common.h @@ -17,11 +17,16 @@ #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__ */ diff --git a/lib/ic-log.h b/common/ic-log.h similarity index 100% rename from lib/ic-log.h rename to common/ic-log.h diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 08f7b67..24e310a 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -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 index 0000000..3fd9c02 --- /dev/null +++ b/daemon/icd-dbus.c @@ -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 +#include + +#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[] = + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + ""; + + 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 index 0000000..ac9a3e5 --- /dev/null +++ b/daemon/icd-dbus.h @@ -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 index 0000000..ddf7929 --- /dev/null +++ b/daemon/icd.c @@ -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 + +#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 index 0000000..64f0e29 --- /dev/null +++ b/daemon/icd.h @@ -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 index 0000000..cb3f2a2 --- /dev/null +++ b/daemon/org.tizen.iotcon.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=@DBUS_INTERFACE@ +Exec=@BIN_INSTALL_DIR@/@DAEMON@ \ No newline at end of file diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 85859df..d68814e 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -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}) diff --git a/lib/ic-client.c b/lib/icl-client.c similarity index 98% rename from lib/ic-client.c rename to lib/icl-client.c index a3af898..6a5b286 100644 --- a/lib/ic-client.c +++ b/lib/icl-client.c @@ -20,12 +20,12 @@ #include #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. diff --git a/lib/ic-client.h b/lib/icl-client.h similarity index 82% rename from lib/ic-client.h rename to lib/icl-client.h index d642b96..8ff8df1 100644 --- a/lib/ic-client.h +++ b/lib/icl-client.h @@ -13,11 +13,11 @@ * 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__ */ diff --git a/lib/ic-device.c b/lib/icl-device.c similarity index 97% rename from lib/ic-device.c rename to lib/icl-device.c index 413291a..b8f1702 100644 --- a/lib/ic-device.c +++ b/lib/icl-device.c @@ -19,8 +19,8 @@ #include #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. */ diff --git a/lib/ic-ioty-repr.cpp b/lib/icl-ioty-repr.cpp similarity index 96% rename from lib/ic-ioty-repr.cpp rename to lib/icl-ioty-repr.cpp index 201d870..f611a8e 100644 --- a/lib/ic-ioty-repr.cpp +++ b/lib/icl-ioty-repr.cpp @@ -18,11 +18,10 @@ 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; diff --git a/lib/ic-ioty-repr.h b/lib/icl-ioty-repr.h similarity index 80% rename from lib/ic-ioty-repr.h rename to lib/icl-ioty-repr.h index 8888130..0a6f774 100644 --- a/lib/ic-ioty-repr.h +++ b/lib/icl-ioty-repr.h @@ -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 #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__ */ diff --git a/lib/ic-ioty.cpp b/lib/icl-ioty.cpp similarity index 99% rename from lib/ic-ioty.cpp rename to lib/icl-ioty.cpp index ef94ff7..4971f24 100644 --- a/lib/ic-ioty.cpp +++ b/lib/icl-ioty.cpp @@ -21,16 +21,15 @@ 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" diff --git a/lib/ic-ioty.h b/lib/icl-ioty.h similarity index 84% rename from lib/ic-ioty.h rename to lib/icl-ioty.h index 394ffc2..fa51691 100644 --- a/lib/ic-ioty.h +++ b/lib/icl-ioty.h @@ -13,14 +13,31 @@ * 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 #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__ diff --git a/lib/ic-observation.c b/lib/icl-observation.c similarity index 98% rename from lib/ic-observation.c rename to lib/icl-observation.c index 2bd76af..baef149 100644 --- a/lib/ic-observation.c +++ b/lib/icl-observation.c @@ -18,7 +18,7 @@ #include #include "iotcon-struct.h" -#include "ic-common.h" +#include "icl.h" API void iotcon_observers_free(iotcon_observers_h observers) { diff --git a/lib/ic-options.c b/lib/icl-options.c similarity index 98% rename from lib/ic-options.c rename to lib/icl-options.c index a5fb1bd..b63c3d2 100644 --- a/lib/ic-options.c +++ b/lib/icl-options.c @@ -19,9 +19,9 @@ #include #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() { diff --git a/lib/ic-options.h b/lib/icl-options.h similarity index 82% rename from lib/ic-options.h rename to lib/icl-options.h index caa44e2..c38e31d 100644 --- a/lib/ic-options.h +++ b/lib/icl-options.h @@ -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__ */ diff --git a/lib/ic-query.c b/lib/icl-query.c similarity index 97% rename from lib/ic-query.c rename to lib/icl-query.c index abb2cdc..25efcd1 100644 --- a/lib/ic-query.c +++ b/lib/icl-query.c @@ -20,9 +20,9 @@ #include #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() { diff --git a/lib/ic-query.h b/lib/icl-query.h similarity index 81% rename from lib/ic-query.h rename to lib/icl-query.h index b8325fb..873c1a5 100644 --- a/lib/ic-query.h +++ b/lib/icl-query.h @@ -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__ */ diff --git a/lib/ic-repr-list.c b/lib/icl-repr-list.c similarity index 99% rename from lib/ic-repr-list.c rename to lib/icl-repr-list.c index ca8bfa4..1810d92 100644 --- a/lib/ic-repr-list.c +++ b/lib/icl-repr-list.c @@ -21,11 +21,11 @@ #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) { diff --git a/lib/ic-repr-list.h b/lib/icl-repr-list.h similarity index 84% rename from lib/ic-repr-list.h rename to lib/icl-repr-list.h index 4af567d..62ddb92 100644 --- a/lib/ic-repr-list.h +++ b/lib/icl-repr-list.h @@ -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 #include @@ -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__ */ diff --git a/lib/ic-repr-obj.c b/lib/icl-repr-obj.c similarity index 99% rename from lib/ic-repr-obj.c rename to lib/icl-repr-obj.c index 7f3c287..be9db54 100644 --- a/lib/ic-repr-obj.c +++ b/lib/icl-repr-obj.c @@ -18,12 +18,12 @@ #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) diff --git a/lib/ic-repr-obj.h b/lib/icl-repr-obj.h similarity index 83% rename from lib/ic-repr-obj.h rename to lib/icl-repr-obj.h index a9ffbad..43a9438 100644 --- a/lib/ic-repr-obj.h +++ b/lib/icl-repr-obj.h @@ -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 @@ -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__ */ diff --git a/lib/ic-repr-value.c b/lib/icl-repr-value.c similarity index 98% rename from lib/ic-repr-value.c rename to lib/icl-repr-value.c index e6672cc..f2e63d2 100644 --- a/lib/ic-repr-value.c +++ b/lib/icl-repr-value.c @@ -20,11 +20,11 @@ #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) { diff --git a/lib/ic-repr-value.h b/lib/icl-repr-value.h similarity index 89% rename from lib/ic-repr-value.h rename to lib/icl-repr-value.h index 6b92cef..7828495 100644 --- a/lib/ic-repr-value.h +++ b/lib/icl-repr-value.h @@ -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 #include @@ -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__ */ diff --git a/lib/ic-repr.c b/lib/icl-repr.c similarity index 98% rename from lib/ic-repr.c rename to lib/icl-repr.c index 62d0d17..dd56c57 100644 --- a/lib/ic-repr.c +++ b/lib/icl-repr.c @@ -23,15 +23,14 @@ #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) { diff --git a/lib/ic-repr.h b/lib/icl-repr.h similarity index 89% rename from lib/ic-repr.h rename to lib/icl-repr.h index 0476652..dc20da2 100644 --- a/lib/ic-repr.h +++ b/lib/icl-repr.h @@ -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 #include @@ -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__ */ diff --git a/lib/ic-request.c b/lib/icl-request.c similarity index 98% rename from lib/ic-request.c rename to lib/icl-request.c index a9ac5d7..3fbc27b 100644 --- a/lib/ic-request.c +++ b/lib/icl-request.c @@ -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) diff --git a/lib/ic-request.h b/lib/icl-request.h similarity index 86% rename from lib/ic-request.h rename to lib/icl-request.h index eee1a82..17629fa 100644 --- a/lib/ic-request.h +++ b/lib/icl-request.h @@ -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__ */ diff --git a/lib/ic-resource-types.c b/lib/icl-resource-types.c similarity index 98% rename from lib/ic-resource-types.c rename to lib/icl-resource-types.c index 6b28fb7..bee4254 100644 --- a/lib/ic-resource-types.c +++ b/lib/icl-resource-types.c @@ -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) { diff --git a/lib/ic-resource-types.h b/lib/icl-resource-types.h similarity index 83% rename from lib/ic-resource-types.h rename to lib/icl-resource-types.h index 0f0a30a..77307bf 100644 --- a/lib/ic-resource-types.h +++ b/lib/icl-resource-types.h @@ -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__ */ diff --git a/lib/ic-response.c b/lib/icl-response.c similarity index 95% rename from lib/ic-response.c rename to lib/icl-response.c index 8965f92..82bd46c 100644 --- a/lib/ic-response.c +++ b/lib/icl-response.c @@ -18,13 +18,13 @@ #include #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) { diff --git a/lib/ic-response.h b/lib/icl-response.h similarity index 82% rename from lib/ic-response.h rename to lib/icl-response.h index 3bbf70b..3d436f7 100644 --- a/lib/ic-response.h +++ b/lib/icl-response.h @@ -13,12 +13,12 @@ * 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__ */ diff --git a/lib/ic-utils.c b/lib/icl-utils.c similarity index 95% rename from lib/ic-utils.c rename to lib/icl-utils.c index dc05f58..072fab4 100644 --- a/lib/ic-utils.c +++ b/lib/icl-utils.c @@ -18,8 +18,8 @@ #include #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) { diff --git a/lib/ic-utils.h b/lib/icl-utils.h similarity index 80% rename from lib/ic-utils.h rename to lib/icl-utils.h index cba63b6..ce95e9d 100644 --- a/lib/ic-utils.h +++ b/lib/icl-utils.h @@ -13,11 +13,11 @@ * 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__ */ diff --git a/lib/ic.c b/lib/icl.c similarity index 98% rename from lib/ic.c rename to lib/icl.c index 77b1844..59e66d3 100644 --- a/lib/ic.c +++ b/lib/icl.c @@ -22,12 +22,11 @@ #include #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 diff --git a/lib/ic.h b/lib/icl.h similarity index 63% rename from lib/ic.h rename to lib/icl.h index d97e96f..fc1ae29 100644 --- a/lib/ic.h +++ b/lib/icl.h @@ -13,32 +13,23 @@ * 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__ */ diff --git a/packaging/iotcon.manifest b/packaging/iotcon.manifest index 5e0c7a6..8edd8d6 100644 --- a/packaging/iotcon.manifest +++ b/packaging/iotcon.manifest @@ -6,18 +6,16 @@ + + - - - - diff --git a/packaging/iotcon.service b/packaging/iotcon.service new file mode 100644 index 0000000..243a64b --- /dev/null +++ b/packaging/iotcon.service @@ -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 diff --git a/packaging/iotcon.spec b/packaging/iotcon.spec index 10d6899..33c7e4b 100644 --- a/packaging/iotcon.spec +++ b/packaging/iotcon.spec @@ -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 index 0000000..3ba0099 --- /dev/null +++ b/packaging/libiotcon.manifest @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + -- 2.7.4