CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(iotcon)
+PROJECT(iotcon C)
INCLUDE(FindPkgConfig)
SET(EXTRA_CFLAGS "-Wall -Werror-implicit-function-declaration -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fvisibility=hidden")
-
SET(CLIENT ${PROJECT_NAME})
SET(DAEMON "${PROJECT_NAME}-daemon")
SET(DBUS_INTERFACE "org.tizen.${PROJECT_NAME}.dbus")
#define IC_DBUS_SIGNAL_PLATFORM "PLATFORM"
#define IC_DBUS_SIGNAL_PRESENCE "PRESENCE"
-#define IC_INTERFACE_DEFAULT "oic.if.baseline";
-#define IC_INTERFACE_LINK "oic.if.ll";
-#define IC_INTERFACE_BATCH "oic.if.b";
-#define IC_INTERFACE_GROUP "oc.mi.grp";
+#define IC_INTERFACE_DEFAULT "oic.if.baseline"
+#define IC_INTERFACE_LINK "oic.if.ll"
+#define IC_INTERFACE_BATCH "oic.if.b"
+#define IC_INTERFACE_GROUP "oc.mi.grp"
#define IC_JSON_KEY_OC "oc"
#define IC_JSON_KEY_URI_PATH "href"
#include <string.h>
#include <errno.h>
+#include "iotcon-constant.h"
+#include "ic-common.h"
#include "ic-log.h"
#include "ic-utils.h"
}
+int ic_utils_convert_interface_flag(iotcon_interface_e src, char **dest)
+{
+ switch (src) {
+ case IOTCON_INTERFACE_DEFAULT:
+ *dest = IC_INTERFACE_DEFAULT;
+ break;
+ case IOTCON_INTERFACE_LINK:
+ *dest = IC_INTERFACE_LINK;
+ break;
+ case IOTCON_INTERFACE_BATCH:
+ *dest = IC_INTERFACE_BATCH;
+ break;
+ case IOTCON_INTERFACE_GROUP:
+ *dest = IC_INTERFACE_GROUP;
+ break;
+ case IOTCON_INTERFACE_NONE:
+ default:
+ ERR("Invalid interface(%d)", src);
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+ return IOTCON_ERROR_NONE;
+}
+
+
+
#ifndef __IOT_CONNECTIVITY_MANAGER_INTERNAL_COMMON_UTILITY_H__
#define __IOT_CONNECTIVITY_MANAGER_INTERNAL_COMMON_UTILITY_H__
+#include "iotcon-constant.h"
+
#define IC_STR_EQUAL 0
#define IC_STR_NULL "(NULL)"
char* ic_utils_strdup(const char *src);
const char* ic_utils_dbus_encode_str(const char *src);
char* ic_utils_dbus_decode_str(char *src);
+int ic_utils_convert_interface_flag(iotcon_interface_e src, char **dest);
#endif /* __IOT_CONNECTIVITY_MANAGER_INTERNAL_COMMON_UTILITY_H__ */
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/include)
-FILE(GLOB DAEMON_SRCS *.c *.cpp ${CMAKE_SOURCE_DIR}/common/*.c)
+FILE(GLOB DAEMON_SRCS *.c ${CMAKE_SOURCE_DIR}/common/*.c)
SET(DAEMON_SRCS ${DAEMON_SRCS} ${CMAKE_SOURCE_DIR}/common/ic-dbus.c)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/common/ic-dbus.c
LINK_DIRECTORIES(${daemon_pkgs_LIBRARY_DIRS})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--hash-style=both -pie")
ADD_DEFINITIONS("-DIOTCON_DBUS_INTERFACE=\"${DBUS_INTERFACE}\"")
+++ /dev/null
-/*
- * 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 <OCApi.h>
-#include <OCPlatform.h>
-
-extern "C" {
-#include <glib.h>
-#include "iotcon-struct.h"
-#include "ic-common.h"
-#include "ic-utils.h"
-#include "icd.h"
-#include "icd-ioty-repr.h"
-}
-
-using namespace std;
-using namespace OC;
-
-int icd_ioty_repr_parse_json(const char *repr_json, OCRepresentation &ocRep)
-{
- int ret = IOTCON_ERROR_NONE;
- MessageContainer info;
-
- try {
- info.setJSONRepresentation(repr_json);
-
- const vector<OCRepresentation> &reps = info.representations();
- if (0 < reps.size()) {
- vector<OCRepresentation>::const_iterator itr = reps.begin();
- vector<OCRepresentation>::const_iterator back = reps.end();
- ocRep = *itr;
- ++itr;
-
- for (; itr != back; ++itr)
- ocRep.addChild(*itr);
- } else {
- ERR("Invalid parameter(%s)", repr_json);
- ret = IOTCON_ERROR_INVALID_PARAMETER;
- }
- } catch (exception &e) {
- ERR("setJSONRepresentation() Fail(%s)", e.what());
- ret = IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-
-int icd_ioty_repr_generate_json(OCRepresentation ocRep, char **json)
-{
- RETV_IF(NULL == json, IOTCON_ERROR_INVALID_PARAMETER);
-
- *json = ic_utils_strdup(ocRep.getJSONRepresentation().c_str());
- if (NULL == *json) {
- ERR("ic_utils_strdup() Fail");
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- return IOTCON_ERROR_NONE;
-}
-
-
-int icd_ioty_repr_generate_gvariant_builder(const OCRepresentation &ocRep,
- GVariantBuilder **builder)
-{
- int ret;
- unsigned int i;
- char *repr_json;
- OCRepresentation ocChild;
-
- *builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
-
- DBG("numberOfAttributes : %d", ocRep.numberOfAttributes());
- ret = icd_ioty_repr_generate_json(ocRep, &repr_json);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("icd_ioty_repr_generate_json() Fail(%d)", ret);
- g_variant_builder_unref(*builder);
- return ret;
- }
- g_variant_builder_add(*builder, "s", repr_json);
- free(repr_json);
-
- vector<OCRepresentation> childList = ocRep.getChildren();
-
- for (i = 0; i < childList.size(); i++) {
- ocChild = childList.at(i);
- ret = icd_ioty_repr_generate_json(ocChild, &repr_json);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("icd_ioty_repr_generate_json() Fail(%d)", ret);
- g_variant_builder_unref(*builder);
- return ret;
- }
- g_variant_builder_add(*builder, "s", repr_json);
- free(repr_json);
- }
-
- return IOTCON_ERROR_NONE;
-}
+++ /dev/null
-/*
- * 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_LIBRARY_IOTIVITY_REPRESENTATION_H__
-#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_REPRESENTATION_H__
-
-#endif /* __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_REPRESENTATION_H__ */
-
#include "iotcon.h"
#include "ic-utils.h"
#include "icd.h"
-#include "icd-ioty-repr.h"
#include "icd-ioty.h"
#include "icd-ioty-ocprocess.h"
}
-static int _ioty_convert_interface_flag(iotcon_interface_e src, const char **dest)
-{
- switch (src) {
- case IOTCON_INTERFACE_DEFAULT:
- *dest = IC_INTERFACE_DEFAULT;
- break;
- case IOTCON_INTERFACE_LINK:
- *dest = IC_INTERFACE_LINK;
- break;
- case IOTCON_INTERFACE_BATCH:
- *dest = IC_INTERFACE_BATCH;
- break;
- case IOTCON_INTERFACE_GROUP:
- *dest = IC_INTERFACE_GROUP;
- break;
- case IOTCON_INTERFACE_NONE:
- default:
- ERR("Invalid interface(%d)", src);
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
- return IOTCON_ERROR_NONE;
-}
-
-
int icd_ioty_bind_interface(OCResourceHandle resourceHandle, iotcon_interface_e iface)
{
int ret;
OCStackResult result;
- const char *resource_interface;
+ char *resource_interface;
- ret = _ioty_convert_interface_flag(iface, &resource_interface);
+ ret = ic_utils_convert_interface_flag(iface, &resource_interface);
if (IOTCON_ERROR_NONE != ret) {
- ERR("_ioty_convert_interface_flag(%d) Fail(%d)", iface, ret);
+ ERR("ic_utils_convert_interface_flag(%d) Fail(%d)", iface, ret);
return ret;
}
return IOTCON_ERROR_NONE;
}
+
int icd_ioty_bind_type(OCResourceHandle resource_handle, const char *resource_type)
{
OCStackResult ret;
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/)
INCLUDE_DIRECTORIES(include)
-FILE(GLOB CLIENT_SRCS *.c *.cpp ${CMAKE_SOURCE_DIR}/common/*.c)
+FILE(GLOB CLIENT_SRCS *.c ${CMAKE_SOURCE_DIR}/common/*.c)
SET(CLIENT_SRCS ${CLIENT_SRCS} ${CMAKE_SOURCE_DIR}/common/ic-dbus.c)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/common/ic-dbus.c
#include "iotcon.h"
#include "ic-utils.h"
#include "icl.h"
+#include "icl-resource.h"
#include "icl-resource-types.h"
-#include "icl-ioty.h"
#include "icl-options.h"
#include "icl-query.h"
#include "icl-request.h"
+++ /dev/null
-/*
- * 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 <OCApi.h>
-
-extern "C" {
-#include "iotcon-constant.h"
-#include "ic-utils.h"
-#include "icl.h"
-}
-
-using namespace std;
-using namespace OC;
-
-static int _icl_ioty_convert_interface_flag(iotcon_interface_e src, string &dest)
-{
- switch (src) {
- case IOTCON_INTERFACE_GROUP:
- dest = GROUP_INTERFACE;
- break;
- case IOTCON_INTERFACE_BATCH:
- dest = BATCH_INTERFACE;
- break;
- case IOTCON_INTERFACE_LINK:
- dest = LINK_INTERFACE;
- break;
- case IOTCON_INTERFACE_DEFAULT:
- dest = DEFAULT_INTERFACE;
- break;
- case IOTCON_INTERFACE_NONE:
- default:
- ERR("Invalid interface");
- dest = "";
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
- return IOTCON_ERROR_NONE;
-}
-
-
-extern "C" int icl_ioty_convert_interface_string(const char *src, iotcon_interface_e *dest)
-{
- RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
-
- if (IC_STR_EQUAL == strcmp(DEFAULT_INTERFACE.c_str(), src)) {
- *dest = IOTCON_INTERFACE_DEFAULT;
- } else if (IC_STR_EQUAL == strcmp(LINK_INTERFACE.c_str(), src)) {
- *dest = IOTCON_INTERFACE_LINK;
- } else if (IC_STR_EQUAL == strcmp(BATCH_INTERFACE.c_str(), src)) {
- *dest = IOTCON_INTERFACE_BATCH;
- } else if (IC_STR_EQUAL == strcmp(GROUP_INTERFACE.c_str(), src)) {
- *dest = IOTCON_INTERFACE_GROUP;
- } else {
- ERR("Invalid interface");
- *dest = IOTCON_INTERFACE_NONE;
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- return IOTCON_ERROR_NONE;
-}
-
-extern "C" int icl_ioty_convert_interface_flag(iotcon_interface_e src, char **dest)
-{
- FN_CALL;
- int ret;
- string iface_str;
-
- ret = _icl_ioty_convert_interface_flag(src, iface_str);
- if (IOTCON_ERROR_NONE != ret) {
- ERR("_icd_ioty_convert_interface_flag() Fail(%d)", ret);
- *dest = NULL;
- return ret;
- }
-
- *dest = ic_utils_strdup(iface_str.c_str());
- if (NULL == *dest) {
- ERR("ic_utils_strdup() Fail");
- return IOTCON_ERROR_INVALID_PARAMETER;
- }
-
- return IOTCON_ERROR_NONE;
-}
-
#include "iotcon-representation.h"
#include "ic-utils.h"
#include "icl.h"
+#include "icl-resource.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"
for (i = 1; i <= ICL_INTERFACE_MAX; i = i << 1) {
if (IOTCON_INTERFACE_NONE == (ifaces & i)) /* this interface not exist */
continue;
- ret = icl_ioty_convert_interface_flag((ifaces & i), &iface_str);
+ ret = ic_utils_convert_interface_flag((ifaces & i), &iface_str);
if (IOTCON_ERROR_NONE != ret) {
- ERR("icl_ioty_convert_interface_flag(%d) Fail(%d)", i, ret);
+ ERR("ic_utils_convert_interface_flag(%d) Fail(%d)", i, ret);
json_object_unref(repr_obj);
json_array_unref(if_array);
return NULL;
}
+static int _icl_repr_convert_interface_string(const char *src, iotcon_interface_e *dest)
+{
+ RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
+
+ if (IC_STR_EQUAL == strcmp(IC_INTERFACE_DEFAULT, src)) {
+ *dest = IOTCON_INTERFACE_DEFAULT;
+ } else if (IC_STR_EQUAL == strcmp(IC_INTERFACE_LINK, src)) {
+ *dest = IOTCON_INTERFACE_LINK;
+ } else if (IC_STR_EQUAL == strcmp(IC_INTERFACE_BATCH, src)) {
+ *dest = IOTCON_INTERFACE_BATCH;
+ } else {
+ ERR("Invalid Interface");
+ return IOTCON_ERROR_INVALID_PARAMETER;
+ }
+
+ return IOTCON_ERROR_NONE;
+}
+
+
int icl_repr_parse_resource_property(JsonObject *prop_obj,
iotcon_resource_types_h *types, int *ifaces)
{
if_count = json_array_get_length(iface_array);
for (if_index = 0; if_index < if_count; if_index++) {
const char *iface_str = json_array_get_string_element(iface_array, if_index);
- ret = icl_ioty_convert_interface_string(iface_str, &iface_flag);
+ ret = _icl_repr_convert_interface_string(iface_str, &iface_flag);
if (IOTCON_ERROR_NONE != ret) {
ERR("icl_ioty_convert_interface_string() Fail(%d)", ret);
if (res_types)
#include "iotcon.h"
#include "ic-utils.h"
#include "icl-resource-types.h"
+#include "icl-resource.h"
#include "icl-request.h"
-#include "icl-ioty.h"
#include "icl-repr.h"
#include "icl-dbus.h"
#include "icl-dbus-type.h"
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_H__
-#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_H__
+#ifndef __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_H__
+#define __IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_H__
#include "iotcon.h"
#include "icl-dbus.h"
iotcon_resource_h children[IOTCON_CONTAINED_RESOURCES_MAX];
};
-int icl_ioty_convert_interface_flag(iotcon_interface_e src, char **dest);
-int icl_ioty_convert_interface_string(const char *src, iotcon_interface_e *dest);
-
-#endif /*__IOT_CONNECTIVITY_MANAGER_LIBRARY_IOTIVITY_H__*/
+#endif /*__IOT_CONNECTIVITY_MANAGER_LIBRARY_RESOURCE_H__*/
#include "icl.h"
#include "icl-dbus.h"
#include "icl-dbus-type.h"
-#include "icl-ioty.h"
+#include "icl-resource.h"
#include "icl-repr.h"
#include "icl-options.h"
#include "icl-request.h"