Remove all cpp code
authoryoungman <yman.jung@samsung.com>
Fri, 24 Jul 2015 11:04:19 +0000 (20:04 +0900)
committeryoungman <yman.jung@samsung.com>
Tue, 3 Nov 2015 11:08:19 +0000 (20:08 +0900)
Change-Id: Ie64381f2731294c348ba3072007854db89608e21
Signed-off-by: youngman <yman.jung@samsung.com>
15 files changed:
CMakeLists.txt
common/ic-common.h
common/ic-utils.c
common/ic-utils.h
daemon/CMakeLists.txt
daemon/icd-ioty-repr.cpp [deleted file]
daemon/icd-ioty-repr.h [deleted file]
daemon/icd-ioty.c
lib/CMakeLists.txt
lib/icl-dbus-type.c
lib/icl-ioty.cpp [deleted file]
lib/icl-repr.c
lib/icl-resource.c [moved from lib/icl.c with 99% similarity]
lib/icl-resource.h [moved from lib/icl-ioty.h with 75% similarity]
lib/icl-response.c

index 6d58b4e..946d8ac 100644 (file)
@@ -1,13 +1,11 @@
 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")
index af41829..d926e05 100644 (file)
 #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"
index 7be7660..9701818 100644 (file)
@@ -16,6 +16,8 @@
 #include <string.h>
 #include <errno.h>
 
+#include "iotcon-constant.h"
+#include "ic-common.h"
 #include "ic-log.h"
 #include "ic-utils.h"
 
@@ -53,3 +55,28 @@ char* ic_utils_dbus_decode_str(char *src)
 }
 
 
+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;
+}
+
+
+
index 423bcaa..3cb76f2 100644 (file)
 #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__ */
index 45af5bd..a31ac9a 100644 (file)
@@ -1,7 +1,7 @@
 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
@@ -12,7 +12,6 @@ INCLUDE_DIRECTORIES(${daemon_pkgs_INCLUDE_DIRS})
 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}\"")
 
diff --git a/daemon/icd-ioty-repr.cpp b/daemon/icd-ioty-repr.cpp
deleted file mode 100644 (file)
index ed2c93c..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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;
-}
diff --git a/daemon/icd-ioty-repr.h b/daemon/icd-ioty-repr.h
deleted file mode 100644 (file)
index 6f67793..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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__ */
-
index f067b8b..35c464a 100644 (file)
@@ -28,7 +28,6 @@
 #include "iotcon.h"
 #include "ic-utils.h"
 #include "icd.h"
-#include "icd-ioty-repr.h"
 #include "icd-ioty.h"
 #include "icd-ioty-ocprocess.h"
 
@@ -152,39 +151,15 @@ int icd_ioty_unregister_resource(OCResourceHandle resource_handle)
 }
 
 
-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;
        }
 
@@ -199,6 +174,7 @@ int icd_ioty_bind_interface(OCResourceHandle resourceHandle, iotcon_interface_e
        return IOTCON_ERROR_NONE;
 }
 
+
 int icd_ioty_bind_type(OCResourceHandle resource_handle, const char *resource_type)
 {
        OCStackResult ret;
index 3831ec6..016f7a2 100644 (file)
@@ -1,7 +1,7 @@
 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
index d8578eb..a21ed79 100644 (file)
@@ -21,8 +21,8 @@
 #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"
diff --git a/lib/icl-ioty.cpp b/lib/icl-ioty.cpp
deleted file mode 100644 (file)
index d7d5e4e..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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;
-}
-
index aa022b0..9a76ef0 100644 (file)
@@ -25,8 +25,8 @@
 #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"
@@ -298,9 +298,9 @@ static JsonObject* _icl_repr_data_generate_json(iotcon_repr_h cur_repr,
                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;
@@ -570,6 +570,26 @@ iotcon_repr_h icl_repr_create_repr(const char *json_string)
 }
 
 
+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)
 {
@@ -609,7 +629,7 @@ int icl_repr_parse_resource_property(JsonObject *prop_obj,
                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)
similarity index 99%
rename from lib/icl.c
rename to lib/icl-resource.c
index ac45abf..0cd5504 100644 (file)
--- a/lib/icl.c
@@ -25,8 +25,8 @@
 #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"
similarity index 75%
rename from lib/icl-ioty.h
rename to lib/icl-resource.h
index 1d828ef..36c04e5 100644 (file)
@@ -13,8 +13,8 @@
  * 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"
@@ -37,7 +37,4 @@ struct icl_resource {
        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__*/
index e480965..0a5c70f 100644 (file)
@@ -22,7 +22,7 @@
 #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"