Seperate the daemon package
authorsaerome.kim <saerome.kim@samsung.com>
Fri, 4 May 2018 05:25:31 +0000 (14:25 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:40:01 +0000 (19:40 +0900)
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
100 files changed:
CMakeLists.txt
LICENSE [deleted file]
README.md [deleted file]
capi-network-mdg.pc.in [moved from capi/capi-network-mdg.pc.in with 100% similarity]
capi/CMakeLists.txt [deleted file]
capi/src/gen.sh [deleted file]
capi/src/mdg_gdbus.xml [deleted file]
capi/unittest/CMakeLists.txt [deleted file]
capi/unittest/mdg_unit_test.cpp [deleted file]
doc/mdg_doc.h [moved from capi/doc/mdg_doc.h with 100% similarity]
include/mdg.h [moved from capi/include/mdg.h with 100% similarity]
include/mdg_internal.h [moved from capi/include/mdg_internal.h with 100% similarity]
install.sh [deleted file]
material/gbs-configure/gbs.4.0.tm1.conf [deleted file]
material/iotcon/iotcon-0.3.20-0.armv7l.rpm [deleted file]
material/iotcon/iotcon-debuginfo-0.3.20-0.armv7l.rpm [deleted file]
material/iotcon/iotcon-debugsource-0.3.20-0.armv7l.rpm [deleted file]
material/iotcon/iotcon-devel-0.3.20-0.armv7l.rpm [deleted file]
material/iotcon/iotcon-test-0.3.20-0.armv7l.rpm [deleted file]
material/iotcon/iotcon-test-debuginfo-0.3.20-0.armv7l.rpm [deleted file]
material/iotivity-mot-enabled/iotivity-1.2.1-9.armv7l.rpm [deleted file]
material/iotivity-mot-enabled/iotivity-debuginfo-1.2.1-9.armv7l.rpm [deleted file]
material/iotivity-mot-enabled/iotivity-debugsource-1.2.1-9.armv7l.rpm [deleted file]
material/iotivity-mot-enabled/iotivity-devel-1.2.1-9.armv7l.rpm [deleted file]
material/iotivity-mot-enabled/iotivity-devel-debuginfo-1.2.1-9.armv7l.rpm [deleted file]
material/iotivity-mot-enabled/iotivity-service-1.2.1-9.armv7l.rpm [deleted file]
material/iotivity-mot-enabled/iotivity-service-debuginfo-1.2.1-9.armv7l.rpm [deleted file]
material/iotivity-mot-enabled/iotivity-test-1.2.1-9.armv7l.rpm [deleted file]
material/iotivity-mot-enabled/iotivity-test-debuginfo-1.2.1-9.armv7l.rpm [deleted file]
material/mdbus2 [deleted file]
material/script/d2d_build.sh [deleted file]
material/script/d2d_install.sh [deleted file]
packaging/capi-network-mdg-devel.manifest [moved from packaging/d2d-manager.manifest with 100% similarity]
packaging/capi-network-mdg.spec [new file with mode: 0644]
packaging/d2d-manager-devel.manifest [deleted file]
packaging/d2d-manager.spec [deleted file]
packaging/ma.service [deleted file]
packaging/mdgd.service [deleted file]
packaging/net.ma.service [deleted file]
packaging/net.mdgd.service [deleted file]
src/gen.sh [moved from src/mdg-manager/src/gen.sh with 100% similarity]
src/mdg-manager/CMakeLists.txt [deleted file]
src/mdg-manager/include/mdgd_context.h [deleted file]
src/mdg-manager/include/mdgd_db.h [deleted file]
src/mdg-manager/include/mdgd_enum.h [deleted file]
src/mdg-manager/include/mdgd_gdbus.h [deleted file]
src/mdg-manager/include/mdgd_gdbus_group.h [deleted file]
src/mdg-manager/include/mdgd_group.h [deleted file]
src/mdg-manager/include/mdgd_iot.h [deleted file]
src/mdg-manager/include/mdgd_log.h [deleted file]
src/mdg-manager/include/mdgd_manager.h [deleted file]
src/mdg-manager/include/mdgd_mot_agent.h [deleted file]
src/mdg-manager/include/mdgd_resource.h [deleted file]
src/mdg-manager/include/mdgd_util.h [deleted file]
src/mdg-manager/oic_svr_db_mdgd_manager.dat [deleted file]
src/mdg-manager/oic_svr_db_mdgd_manager.json [deleted file]
src/mdg-manager/src/mdgd_context.c [deleted file]
src/mdg-manager/src/mdgd_db.c [deleted file]
src/mdg-manager/src/mdgd_gdbus.c [deleted file]
src/mdg-manager/src/mdgd_gdbus_group.c [deleted file]
src/mdg-manager/src/mdgd_group.c [deleted file]
src/mdg-manager/src/mdgd_iot.cpp [deleted file]
src/mdg-manager/src/mdgd_log.c [deleted file]
src/mdg-manager/src/mdgd_manager.c [deleted file]
src/mdg-manager/src/mdgd_mot_agent.c [deleted file]
src/mdg-manager/src/mdgd_resource.c [deleted file]
src/mdg-manager/src/mdgd_util.c [deleted file]
src/mdg.c [moved from capi/src/mdg.c with 100% similarity]
src/mdg_dbus.c [moved from capi/src/mdg_dbus.c with 100% similarity]
src/mdg_dbus.h [moved from capi/src/mdg_dbus.h with 100% similarity]
src/mdg_debug.h [moved from capi/src/mdg_debug.h with 100% similarity]
src/mdg_gdbus.xml [moved from src/mdg-manager/src/mdg_gdbus.xml with 100% similarity]
src/mdg_private.h [moved from capi/src/mdg_private.h with 100% similarity]
src/mdg_util.c [moved from capi/src/mdg_util.c with 100% similarity]
src/mdg_util.h [moved from capi/src/mdg_util.h with 100% similarity]
src/mot-agent/CMakeLists.txt [deleted file]
src/mot-agent/introspection/enabler.xml [deleted file]
src/mot-agent/introspection/gen.sh [deleted file]
src/mot-agent/introspection/ma.xml [deleted file]
src/mot-agent/ma-log.h [deleted file]
src/mot-agent/ma-service-interface.c [deleted file]
src/mot-agent/ma-service-interface.h [deleted file]
src/mot-agent/ma-service.c [deleted file]
src/mot-agent/ma-service.h [deleted file]
src/mot-agent/ma-subowner.c [deleted file]
src/mot-agent/ma-subowner.h [deleted file]
src/mot-agent/ma-util.c [deleted file]
src/mot-agent/ma-util.h [deleted file]
src/mot-agent/ma.c [deleted file]
src/mot-agent/ma.h [deleted file]
src/mot-agent/oic_svr_db_ma.dat [deleted file]
src/mot-agent/oic_svr_db_ma.json [deleted file]
test.pcap [deleted file]
test/CMakeLists.txt [moved from capi/test/CMakeLists.txt with 100% similarity]
test/common.h [moved from capi/test/common.h with 100% similarity]
test/main.c [moved from capi/test/main.c with 100% similarity]
test/mdg-manager.c [moved from capi/test/mdg-manager.c with 99% similarity]
test/mdg-test.c [moved from capi/test/mdg-test.c with 100% similarity]
test/menu.c [moved from capi/test/menu.c with 100% similarity]
test/menu.h [moved from capi/test/menu.h with 100% similarity]

index 1f09101..9888373 100644 (file)
@@ -1,46 +1,82 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(d2d-manager-daemon C CXX)
+SET(CAPI_MDG "capi-network-mdg")
 
-MESSAGE("===================================================================")
-MESSAGE("Making...common configuration")
-MESSAGE("===================================================================")
+PROJECT(${CAPI_MDG} C CXX)
 
-MESSAGE(" - Set include folder")
-INCLUDE(FindPkgConfig)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/capi/include)
+MESSAGE(" - Defining...configuration variables")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(LIB ${LIB_PATH})
+SET(LIBDIR ${PREFIX}/${LIB_PATH})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
 
 MESSAGE(" - Checking...packages dependency")
-SET(COMMON_DEPS glib-2.0 gio-2.0 gio-unix-2.0 dlog dbus-1 iotivity uuid capi-base-common capi-system-info vconf boost gmock sqlite3 capi-system-system-settings)
-IF (LINUX)
-    PKG_CHECK_MODULES(daemon_pkgs REQUIRED ${COMMON_DEPS})
-    ADD_DEFINITIONS("-DLINUX")
-ELSE ()
-    SET(TIZEN_DEPS dlog libtzplatform-config)
-    PKG_CHECK_MODULES(daemon_pkgs REQUIRED ${COMMON_DEPS} ${TIZEN_DEPS})
-    ADD_DEFINITIONS("-DUSE_DLOG")
-    ADD_DEFINITIONS("-DSUPPORT_BASE64_ENCODING")
-ENDIF()
-
-MESSAGE(" - Adding external C flags")
-FOREACH(flag ${daemon_pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-       SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
+SET(COMMON_DEPS dlog gio-2.0 glib-2.0 gio-unix-2.0 capi-system-info)
+SET(PC_DEPS "")
+
+MESSAGE(" - Making...build configuration")
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${CAPI_MDG} REQUIRED ${COMMON_DEPS})
+FOREACH(flag ${${CAPI_MDG}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fpic -std=gnu99")
-SET(CMAKE_CXX_FLAGS "${EXTRA_CXXFLAGS} -std=gnu++11 -fPIC -fvisibility=hidden")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
-
-MESSAGE(" - Define...iotivity macro")
-ADD_DEFINITIONS("-D__TIZEN__")
-ADD_DEFINITIONS("-DMULTIPLE_OWNER=1")
-ADD_DEFINITIONS("-D__WITH_TLS__")
-ADD_DEFINITIONS("-DWITH_TCP")
-ADD_DEFINITIONS("-D__WITH_DTLS__")
-ADD_DEFINITIONS("-DTCP_ADAPTER")
-
-MESSAGE(" - Start building src directories")
-ADD_SUBDIRECTORY(src/mot-agent)
-ADD_SUBDIRECTORY(src/mdg-manager)
-ADD_SUBDIRECTORY(capi)
+IF(BUILD_GCOV)
+       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fvisibility=hidden -fprofile-arcs -ftest-coverage")
+ELSE(BUILD_GCOV)
+       SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fvisibility=hidden")
+ENDIF(BUILD_GCOV)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -g -fvisibility=hidden")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" STREQUAL "arm")
+    ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIBDIR}")
+
+MESSAGE(" - Generating...d-bus code")
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+                " \\
+                --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/mdg_gdbus \\
+                --interface-prefix org.tizen.mdg. \\
+                ${CMAKE_CURRENT_SOURCE_DIR}/src/mdg_gdbus.xml \\
+                ")
+
+MESSAGE(" - Building...shared library")
+SET(SOURCES src/mdg.c
+            src/mdg_gdbus.c
+            src/mdg_util.c
+            src/mdg_dbus.c)
+ADD_LIBRARY(${CAPI_MDG} SHARED ${SOURCES})
+TARGET_LINK_LIBRARIES(${CAPI_MDG} ${${CAPI_MDG}_LDFLAGS} pthread)
+
+MESSAGE(" - Installing...the library and header files")
+INSTALL(TARGETS ${CAPI_MDG} DESTINATION lib)
+INSTALL(
+        DIRECTORY include/ DESTINATION include
+        FILES_MATCHING
+        PATTERN "include/*.h"
+        )
+
+SET(PC_NAME ${CAPI_MDG})
+SET(PC_REQUIRED ${PC_DEPS})
+SET(PC_LDFLAGS -l${CAPI_MDG})
+
+CONFIGURE_FILE(
+    ${CAPI_MDG}.pc.in
+    ${CMAKE_CURRENT_SOURCE_DIR}/${CAPI_MDG}.pc
+    @ONLY
+)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CAPI_MDG}.pc DESTINATION lib/pkgconfig)
+
+ADD_SUBDIRECTORY(test)
diff --git a/LICENSE b/LICENSE
deleted file mode 100644 (file)
index d645695..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   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.
diff --git a/README.md b/README.md
deleted file mode 100644 (file)
index 9224658..0000000
--- a/README.md
+++ /dev/null
@@ -1,349 +0,0 @@
-# d2d-manager\r
-To test d2d-manager and sample apps, you must build iotivity locally with following modifications:\r
-\r
-### 1. build_common/SConscript\r
-```sh\r
-defines.append('-DMULTIPLE_OWNER=1')\r
-```\r
-### 2. packaging/iotivity.spec\r
-```sh\r
---- a/packaging/iotivity.spec\r
-+++ b/packaging/iotivity.spec\r
-@@ -1,6 +1,6 @@\r
- Name: iotivity\r
- Version: 1.2.1\r
--Release: 0\r
-+Release: 9\r
- Summary: Samsung IoT Connectivity\r
- Group: Network & Connectivity / IoT Connectivity\r
- License: Apache-2.0\r
-@@ -37,7 +37,7 @@ Source1002: %{name}-test.manifest\r
\r
- # default is RELEASE mode.\r
- # If DEBUG mode is needed, please use tizen_build_devel_mode\r
--%define RELEASE True\r
-+%define RELEASE False\r
- # For Example\r
- %if %{RELEASE} == "True"\r
- %define build_mode release\r
-@@ -89,7 +89,7 @@ Source1002: %{name}-test.manifest\r
- %{!?BLE_CUSTOM_ADV: %define BLE_CUSTOM_ADV False}\r
- %{!?BLE_DIVISION: %define BLE_DIVISION VD}\r
- %{!?BLE_TIZEN_30: %define BLE_TIZEN_30 True}\r
--%{!?MULTIPLE_OWNER: %define MULTIPLE_OWNER 0}\r
-+%{!?MULTIPLE_OWNER: %define MULTIPLE_OWNER 1}\r
\r
- BuildRequires:  expat-devel\r
- BuildRequires:  python, libcurl-devel\r
-@@ -194,7 +194,7 @@ scons %{JOB} --prefix=%{_prefix} \\r
- mkdir -p %{buildroot}/%{_datadir}/license\r
- cp LICENSE %{buildroot}/%{_datadir}/license/%{name}\r
- %endif\r
--rm -rf %{buildroot}\r
-+#rm -rf %{buildroot}\r
- CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ;\r
- scons install --install-sandbox=%{buildroot} --prefix=%{_prefix} \\r
-     ES_TARGET_ENROLLEE=%{ES_TARGET_ENROLLEE} \\r
-@@ -259,6 +259,14 @@ cp ./resource/csdk/security/include/*.h %{buildroot}%{_includedir}\r
- cp ./resource/csdk/connectivity/api/*.h %{buildroot}%{_includedir}/\r
- cp ./resource/csdk/security/include/internal/*.h %{buildroot}%{_includedir}/\r
- cp ./resource/csdk/security/provisioning/include/oxm/*.h %{buildroot}%{_includedir}\r
-+cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/provisioningclient %{ex_install_dir}/provision-sample/\r
-+cp ./resource/csdk/security/provisioning/sample/oic_svr_db_client.dat %{ex_install_dir}/provision-sample/\r
-+%if 0%{MULTIPLE_OWNER} == 1\r
-+cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/subownerclient %{ex_install_dir}/provision-sample/\r
-+cp ./resource/csdk/security/provisioning/sample/oic_svr_db_subowner_client.dat %{ex_install_dir}/provision-sample/\r
-+cp out/%{TARGET_OS}/%{TARGET_ARCH}/%{build_mode}/resource/csdk/security/provisioning/sample/sampleserver_preconfpin %{ex_install_dir}/provision-sample/\r
-+cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_preconfpin.dat %{ex_install_dir}/provision-sample/\r
-+%endif\r
- cp ./resource/csdk/security/provisioning/include/internal/*.h %{buildroot}%{_includedir}\r
- cp ./resource/csdk/security/provisioning/include/*.h %{buildroot}%{_includedir}\r
- cp ./resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat %{buildroot}%{_libdir}/oic_svr_db_server.dat\r
-@@ -286,7 +294,7 @@ ln -fs ../resource %{buildroot}%{_includedir}/iotivity/\r
-\r
-```\r
-\r
-### 3. policyengine.c\r
-```sh\r
---- a/resource/csdk/security/src/policyengine.c\r
-+++ b/resource/csdk/security/src/policyengine.c\r
-@@ -192,7 +192,7 @@ static bool IsRequestFromSubOwner(PEContext_t *context)\r
-  */\r
- static bool IsValidRequestFromSubOwner(PEContext_t *context)\r
- {\r
--    bool isValidRequest = false;\r
-+    bool isValidRequest = true;\r
\r
-     if(NULL == context)\r
-     {\r
-@@ -294,7 +294,7 @@ bool IsRequestFromResourceOwner(PEContext_t *context)\r
-     {\r
-         if(OC_STACK_OK == GetSvrRownerId[(int)context->resourceType](&resourceOwner))\r
-         {\r
--            retVal = UuidCmp(&context->subject, &resourceOwner);\r
-+            retVal = true;//UuidCmp(&context->subject, &resourceOwner);\r
-         }\r
-     }\r
\r
-```\r
-\r
-### 4. provisioningdatabasemanager.c\r
-\r
-```sh\r
---- a/resource/csdk/security/provisioning/src/provisioningdatabasemanager.c\r
-+++ b/resource/csdk/security/provisioning/src/provisioningdatabasemanager.c\r
-@@ -44,7 +44,7 @@\r
- #define PDM_BIND_INDEX_THIRD 3\r
\r
- #define PDM_CREATE_T_DEVICE_LIST "create table T_DEVICE_LIST(ID INTEGER PRIMARY KEY AUTOINCREMENT,\\r
--                                  UUID BLOB NOT NULL UNIQUE, STATE INT NOT NULL);"\r
-+                                  UUID BLOB NOT NULL, STATE INT NOT NULL);"\r
\r
- #define PDM_CREATE_T_DEVICE_LINK  "create table T_DEVICE_LINK_STATE(ID INT NOT NULL, ID2 INT NOT \\r
-                                    NULL,STATE INT NOT NULL, PRIMARY KEY (ID, ID2));"\r
-\r
-```\r
-\r
-### 5. octypes.h\r
-```sh\r
---- a/resource/csdk/stack/include/octypes.h\r
-+++ b/resource/csdk/stack/include/octypes.h\r
-@@ -1052,7 +1052,9 @@ typedef enum\r
-     OC_STACK_SERVICE_UNAVAILABLE,    /** 503*/\r
-     OC_STACK_GATEWAY_TIMEOUT,        /** 504*/\r
-     OC_STACK_PROXY_NOT_SUPPORTED,    /** 505*/\r
--\r
-+#ifdef MULTIPLE_OWNER\r
-+       OC_STACK_LINK_ALREADY_EXIST,\r
-+#endif\r
-     /** ERROR in stack.*/\r
-     OC_STACK_ERROR = 255\r
-     /** Error status code - END HERE.*/\r
-```\r
-\r
-### 6. multipleownershiptransfermanager.c\r
-```sh\r
---- a/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c\r
-+++ b/resource/csdk/security/provisioning/src/multipleownershiptransfermanager.c\r
-@@ -652,14 +652,14 @@ OCStackResult MOTAddPreconfigPIN(const OCProvisionDev_t *targetDeviceInfo,\r
-     VERIFY_NON_NULL(TAG, preconfPIN, ERROR);\r
-     VERIFY_SUCCESS(TAG, (0 != preconfPINLen), ERROR);\r
-     VERIFY_SUCCESS(TAG, (0 != preconfPINLen && OXM_PRECONFIG_PIN_MAX_SIZE >= preconfPINLen), ERROR);\r
--\r
-+#if 0\r
-     OicSecCred_t* prevCred = GetCredResourceData(&targetDeviceInfo->doxm->deviceID);\r
-     if(NULL != prevCred)\r
-     {\r
-         OIC_LOG(INFO, TAG, "PIN/PW Credential already exist!");\r
-         return OC_STACK_OK;\r
-     }\r
--\r
-+#endif\r
-     addCredRes = OC_STACK_NO_MEMORY;\r
-     //Generate PIN based credential\r
-     pinCred = (OicSecCred_t*)OICCalloc(1, sizeof(OicSecCred_t));\r
-```\r
-\r
-After iotivity build succeeds, copy the following package to GBS-ROOT.\r
-\r
-* iotivity-1.2.1-9.armv7l.rpm\r
-* iotivity-devel-1.2.1-9.armv7l.rpm\r
-\r
-**Example**\r
-```sh\r
-~/GBS-ROOT/unified-standard/local/repos/unified_standard/armv7l/RPMS/\r
-```\r
-# build script\r
-If you want to build and install the d2d manager easily, use the following guide.\r
-### 1. modify git path variable in {git_path}/material/script/d2d_build.sh & d2d_install.sh script\r
-       ex) git_path="/data/workspace/d2d-manager"\r
-### 2. copy install script in /usr/bin\r
-       ex) sudo cp d2d_install.sh /usr/bin\r
-### 3. execute d2d_install.sh\r
-       ex) $ d2d_install.sh\r
-\r
-# How to test d2d-subowner\r
-**Assumption)** \r
-We have 2~3 physical devices such as TM1 or U3. Our devices are in same IP subnet.\r
-\r
-**Pre-conditions)** \r
-Execute 2 sampleserver_justworks which has Preconfigured PIN security option (key. 12341234)\r
-\r
-**Example)**\r
-At physical device#1, run sampleserver_justworks (ex. its uuid: 5c7ad9ac-836b-4ac0-92a8-ca516f9e8dd4)\r
-At physical device#2, run sampleserver_justworks (ex. 2nd server's uuid: e4854ed5-65d1-4cc7-8766-3fb7a35e283a)\r
-\r
-## Test Method)\r
-At physical device#2, we execute mdbus2 like below\r
-### 1. Enable d2d-subowner\r
-```sh\r
-sh-3.2# mdbus2 -s -i\r
-MDBUS2> net.d2ds.enabler /net/d2ds/enabler net.d2ds.enabler.enable\r
-(0,)\r
-```\r
-```sh\r
-saerome.kim@lx:~/github_sec/d2d-manager (tizen)$ sdb dlog -v time D2D_SUBOWNER\r
-01-01 10:23:35.029+0900 D/D2D_SUBOWNER(14781): d2ds.c: main(40) > Enter\r
-01-01 10:23:35.030+0900 I/D2D_SUBOWNER(14781): d2ds.c: main(53) > service mainloop start\r
-01-01 10:23:35.030+0900 D/D2D_SUBOWNER(14781): d2ds-service-interface.c: d2ds_service_interface_init(455) > Enter\r
-01-01 10:23:35.032+0900 D/D2D_SUBOWNER(14781): d2ds-service-interface.c: d2ds_service_interface_init(464) > Quit\r
-01-01 10:23:35.045+0900 D/D2D_SUBOWNER(14781): d2ds-service-interface.c: _d2ds_dbus_on_activator_bus_acquired(370) > Enter\r
-01-01 10:23:35.046+0900 D/D2D_SUBOWNER(14781): d2ds-service-interface.c: _d2ds_dbus_on_activator_bus_acquired(391) > Quit\r
-01-01 10:23:35.056+0900 D/D2D_SUBOWNER(14781): d2ds-service-interface.c: _d2ds_dbus_on_name_acquired(305) > Acquired the name net.d2ds\r
-01-01 10:23:35.063+0900 D/D2D_SUBOWNER(14781): d2ds-service-interface.c: _d2ds_dbus_handle_enable(315) > Enter\r
-01-01 10:23:35.526+0900 D/D2D_SUBOWNER(14781): d2ds-service-interface.c: _d2ds_dbus_handle_enable(331) > Quit\r
-```\r
-\r
-### 2. Get d2d-subowner's device ID\r
-\r
-```sh\r
-MDBUS2> net.d2ds /net/d2ds net.d2ds.get_ownerid\r
-('e5d11e8c-7e04-0e9f-fe9f-4bc362f94318', 0)\r
-```\r
-\r
-```sh\r
-saerome.kim@lx:~/github_sec/d2d-manager (tizen)$ sdb dlog -v time D2D_SUBOWNER\r
-01-01 10:23:42.626+0900 D/D2D_SUBOWNER(14781): d2ds-subowner.c: d2ds_request_get_ownerid(1525) > [IPC] Get Device ID\r
-```\r
-\r
-### 3. Find MOT enabled devices in a network\r
-\r
-```sh\r
-MDBUS2> net.d2ds /net/d2ds net.d2ds.disc_mot_enb_devs\r
-(0,)\r
-```\r
-\r
-```sh\r
-saerome.kim@lx:~/github_sec/d2d-manager (tizen)$ sdb dlog -v time D2D_SUBOWNER\r
-01-01 09:07:40.351+0900 D/D2D_SUBOWNER( 4721): d2ds-subowner.c: d2ds_request_disc_mot_enb_devs(1400) > [IPC] Discovery MOT enabled devices\r
-01-01 09:07:40.351+0900 I/D2D_SUBOWNER( 4721): d2ds-subowner.c: _disc_mot_env_devs_func(672) > Discovering Multiple Ownership Transfer enabled Devices on Network..\r
-01-01 09:07:44.358+0900 I/D2D_SUBOWNER( 4721): d2ds-subowner.c: _print_no_uuid(219) > [1] 5c7ad9ac-836b-4ac0-92a8-ca516f9e8dd4\r
-01-01 09:07:44.358+0900 I/D2D_SUBOWNER( 4721): d2ds-subowner.c: _print_no_uuid(219) > [2] e4854ed5-65d1-4cc7-8766-3fb7a35e283a\r
-01-01 09:07:44.358+0900 D/D2D_SUBOWNER( 4721): d2ds-subowner.c: __notify_found_devs(590) > Found 2 MOT enabled devices\r
-01-01 09:07:44.359+0900 I/D2D_SUBOWNER( 4721): d2ds-subowner.c: __notify_found_devs(633) > ?doxms?\r
-```\r
-\r
-```sh\r
-saerome.kim@lx:~/github_sec/d2d-manager (tizen)$ sdb shell dbus-monitor --system "sender='net.d2ds'"\r
-method return time=1515149361.403747 sender=:1.50 -> destination=:1.49 serial=29 reply_serial=29\r
-   int32 0\r
-signal time=1515149365.404783 sender=:1.50 -> destination=(null destination) serial=30 path=/net/d2ds; interface=net.d2ds; member=disc_mowned_devs_done\r
-   array [\r
-      array [\r
-         dict entry(\r
-            string "deviceId"\r
-            variant                string "e5d11e8c-7e04-0e9f-fe9f-4bc362f94318"\r
-         )\r
-         dict entry(\r
-            string "adapter"\r
-            variant                uint32 1\r
-         )\r
-         dict entry(\r
-            string "flags"\r
-            variant                int32 32\r
-         )\r
-         dict entry(\r
-            string "port"\r
-            variant                uint16 59190\r
-         )\r
-         dict entry(\r
-            string "addr"\r
-            variant                string "fe80::7edd:90ff:feb1:1c53%wlan0"\r
-         )\r
-         dict entry(\r
-            string "ifindex"\r
-            variant                int32 0\r
-         )\r
-         dict entry(\r
-            string "routeData"\r
-            variant                string ""\r
-         )\r
-         dict entry(\r
-            string "connType"\r
-            variant                uint32 65568\r
-         )\r
-         dict entry(\r
-            string "securePort"\r
-            variant                uint16 35114\r
-         )\r
-         dict entry(\r
-            string "tcpPort"\r
-            variant                uint16 49193\r
-         )\r
-         dict entry(\r
-            string "secVer"\r
-            variant                string "0.0.0"\r
-         )\r
-         dict entry(\r
-            string "devStatus"\r
-            variant                uint32 1\r
-         )\r
-      ]\r
-   ]\r
-```\r
-\r
-### 4. MOT sampleserver_justworks in device#1\r
-\r
-```sh\r
-MDBUS2> net.d2ds /net/d2ds net.d2ds.mot 5c7ad9ac-836b-4ac0-92a8-ca516f9e8dd4 12341234\r
-(0,)\r
-```\r
-\r
-### 5. MOT sampleserver_justworks in device#2\r
-\r
-```sh\r
-MDBUS2> net.d2ds /net/d2ds net.d2ds.mot e4854ed5-65d1-4cc7-8766-3fb7a35e283a 12341234\r
-(0,)\r
-```\r
-\r
-### 6. Find owned devices in a network\r
-\r
-```sh\r
-MDBUS2> net.d2ds /net/d2ds net.d2ds.disc_mowned_devs\r
-(0,)\r
-```\r
-\r
-```sh\r
-saerome.kim@lx:~/github_sec/d2d-manager (tizen)$ sdb dlog -v time D2D_SUBOWNER\r
-01-01 09:08:21.418+0900 D/D2D_SUBOWNER( 4721): d2ds-subowner.c: d2ds_request_disc_owned_devs(1420) > [IPC] Discovery Owned devices using MOT\r
-01-01 09:08:21.418+0900 D/D2D_SUBOWNER( 4721): d2ds-subowner.c: _disc_owned_devs_func(721) > Discovering Multiple Owned Devices on Network.\r
-01-01 09:08:25.419+0900 I/D2D_SUBOWNER( 4721): d2ds-subowner.c: _print_dev_list(295) > Device List is Empty..\r
-01-01 09:08:25.419+0900 I/D2D_SUBOWNER( 4721):\r
-01-01 09:08:30.358+0900 I/D2D_SUBOWNER( 4721): d2ds-subowner.c: _print_no_uuid(219) > [1] 5c7ad9ac-836b-4ac0-92a8-ca516f9e8dd4\r
-01-01 09:08:30.358+0900 I/D2D_SUBOWNER( 4721): d2ds-subowner.c: _print_no_uuid(219) > [2] e4854ed5-65d1-4cc7-8766-3fb7a35e283a\r
-01-01 09:08:30.358+0900 D/D2D_SUBOWNER( 4721): d2ds-subowner.c: __notify_found_devs(590) > Found 2 MOT enabled devices\r
-```\r
-\r
-### 7. ACL Provisioning sampleserver_justworks in device#1\r
-\r
-```sh\r
-MDBUS2> net.d2ds /net/d2ds net.d2ds.prov_acl e4854ed5-65d1-4cc7-8766-3fb7a35e283a 5c7ad9ac-836b-4ac0-92a8-ca516f9e8dd4 /a/led core.led oic.if.baseline 31\r
-(0,)\r
-```\r
-\r
-### 8. ACL Provisioning sampleserver_justworks in device#2\r
-\r
-```sh\r
-MDBUS2> net.d2ds /net/d2ds net.d2ds.prov_acl 7ad10436-525b-4f4c-890b-84a0f3ad66aa e4854ed5-65d1-4cc7-8766-3fb7a35e283a /a/led core.led oic.if.baseline 31\r
-(0,)\r
-```\r
-\r
-### 9. Make both sampleserver_justworks pairwise\r
-\r
-```sh\r
-MDBUS2> net.d2ds /net/d2ds net.d2ds.prov_cred f9dfa1a0-f989-4c31-a08c-32b0d0178058 c520f48f-ed51-4986-8c45-47bfb7e8d8bc\r
-(0,)\r
-```\r
-\r
-```sh\r
-saerome.kim@lx:~/github_sec/d2d-manager (tizen)$ sdb dlog -v time D2D_SUBOWNER\r
-01-01 10:09:12.288+0900 D/D2D_SUBOWNER(13505): d2ds-subowner.c: d2ds_request_prov_cred(1304) > [IPC] Provisioning Credential\r
-01-01 10:09:12.288+0900 I/D2D_SUBOWNER(13505): d2ds-subowner.c: _print_uuid(187) > 7b6a3d68-d9cb-4197-bb1f-631fb908f140\r
-01-01 10:09:12.288+0900 I/D2D_SUBOWNER(13505): d2ds-subowner.c: _print_uuid(187) > 4dc9c08c-c20f-4cd7-9861-0a90a6d773e0\r
-01-01 10:09:12.288+0900 I/D2D_SUBOWNER(13505): d2ds-subowner.c: _print_uuid(187) > 7b6a3d68-d9cb-4197-bb1f-631fb908f140\r
-01-01 10:09:12.288+0900 I/D2D_SUBOWNER(13505): d2ds-subowner.c: _cred_provisioning_func(1099) >    Provisioning Selected Pairwise Devices..\r
-01-01 10:09:12.829+0900 I/D2D_SUBOWNER(13505): d2ds-subowner.c: _cred_provisioning_func(1115) >    > Provisioned Selected Pairwise Devices\r
-```\r
-\r
-\r
-\r
diff --git a/capi/CMakeLists.txt b/capi/CMakeLists.txt
deleted file mode 100644 (file)
index efa254c..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-SET(CAPI_MDG "capi-network-mdg")
-
-FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
-                " \\
-                --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/mdg_gdbus \\
-                --interface-prefix org.tizen.mdg. \\
-                ${CMAKE_CURRENT_SOURCE_DIR}/src/mdg_gdbus.xml \\
-                ")
-
-SET(INC_DIR include)
-INCLUDE_DIRECTORIES(${INC_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
-
-SET(SOURCES src/mdg.c
-            src/mdg_gdbus.c
-            src/mdg_util.c
-            src/mdg_dbus.c)
-
-ADD_LIBRARY(${CAPI_MDG} SHARED ${SOURCES})
-
-TARGET_LINK_LIBRARIES(${CAPI_MDG} ${daemon_pkgs_LDFLAGS} pthread)
-
-INSTALL(TARGETS ${CAPI_MDG} DESTINATION lib)
-INSTALL(
-        DIRECTORY include/ DESTINATION include
-        FILES_MATCHING
-        PATTERN "include/*.h"
-        )
-
-SET(PC_NAME ${CAPI_MDG})
-SET(PC_REQUIRED capi-base-common)
-SET(PC_LDFLAGS -l${CAPI_MDG})
-
-CONFIGURE_FILE(
-    ${CAPI_MDG}.pc.in
-    ${CMAKE_CURRENT_SOURCE_DIR}/${CAPI_MDG}.pc
-    @ONLY
-)
-
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${CAPI_MDG}.pc DESTINATION lib/pkgconfig)
-
-ADD_SUBDIRECTORY(test)
-ADD_SUBDIRECTORY(unittest)
diff --git a/capi/src/gen.sh b/capi/src/gen.sh
deleted file mode 100755 (executable)
index 8db7387..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-gdbus-codegen --interface-prefix org.tizen.mdg \
-        --generate-c-code mdg_gdbus \
-        --c-generate-object-manager \
-        mdg_gdbus.xml \
diff --git a/capi/src/mdg_gdbus.xml b/capi/src/mdg_gdbus.xml
deleted file mode 100644 (file)
index 5aa4c1e..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!DOCTYPE node PUBLIC
-       "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
-       "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
-
-<node>
-       <interface name="org.tizen.mdg.enabler">
-               <method name="AddRef">
-                       <arg type="s" name="name" direction="in"/>
-                       <arg type="i" name="result" direction="out"/>
-               </method>
-       </interface>
-       <interface name="org.tizen.mdg.group">
-               <!-- Method definitions -->
-               <method name="Create">
-                       <arg type="s" name="group_name" direction="in"/>
-                       <arg type="i" name="result" direction="out"/>
-               </method>
-               <method name="Find">
-                       <arg type="i" name="timeout" direction="in" />
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="GetFoundGroups">
-                       <arg type="i" name="result" direction="out" />
-                       <arg type="aa{sv}" name="groups" direction="out" />
-               </method>
-               <method name="Join">
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="Leave">
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="Delete">
-                       <arg type="i" name="group_count" direction="out" />
-                       <arg type="aa{sv}" name="groups" direction="out" />
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="DeviceFind">
-                       <arg type="i" name="timeout" direction="in" />
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="Invite">
-                       <arg type="s" name="group_name" direction="in"/>
-                       <arg type="s" name="uuid" direction="in"/>
-                       <arg type="s" name="pin" direction="in" />
-                       <arg type="i" name="result" direction="out"/>
-               </method>
-               <method name="Eject">
-                       <arg type="s" name="group_name" direction="in"/>
-                       <arg type="s" name="uuid" direction="in"/>
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="DeviceInvite">
-                       <arg type="s" name="uuid_dev1" direction="in"/>
-                       <arg type="s" name="uuid_dev2" direction="in"/>
-                       <arg type="s" name="pin" direction="in" />
-                       <arg type="s" name="uri_1" direction="in"/>
-                       <arg type="s" name="rt_1" direction="in"/>
-                       <arg type="s" name="interface_1" direction="in"/>
-                       <arg type="i" name="permission_1" direction="in"/>
-                       <arg type="s" name="uri_2" direction="in"/>
-                       <arg type="s" name="rt_2" direction="in"/>
-                       <arg type="s" name="interface_2" direction="in"/>
-                       <arg type="i" name="permission_2" direction="in"/>
-                       <arg type="i" name="result" direction="out"/>
-               </method>
-               <method name="DeviceEject">
-                       <arg type="s" name="uuid_dev1" direction="in"/>
-                       <arg type="s" name="uuid_dev2" direction="in"/>
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="GetRemoteDevice">
-                       <arg type="i" name="device_count" direction="out" />
-                       <arg type="aa{sv}" name="device_info" direction="out" />
-               </method>
-               <method name="PairResource">
-                       <arg type="s" name="target_1" direction="in"/>
-                       <arg type="s" name="subject_1" direction="in"/>
-                       <arg type="s" name="uri_1" direction="in"/>
-                       <arg type="s" name="rt_1" direction="in"/>
-                       <arg type="s" name="interface_1" direction="in"/>
-                       <arg type="i" name="permission_1" direction="in"/>
-                       <arg type="s" name="target_2" direction="in"/>
-                       <arg type="s" name="subject_2" direction="in"/>
-                       <arg type="s" name="uri_2" direction="in"/>
-                       <arg type="s" name="rt_2" direction="in"/>
-                       <arg type="s" name="interface_2" direction="in"/>
-                       <arg type="i" name="permission_2" direction="in"/>
-                       <arg type="i" name="result" direction="out"/>
-               </method>
-               <method name="UnpairResource">
-                       <arg type="s" name="uuid_dev1" direction="in"/>
-                       <arg type="s" name="uuid_dev2" direction="in"/>
-                       <arg type="i" name="result" direction="out"/>
-               </method>
-               <method name="SendData">
-                       <arg type="s" name="uuid" direction="in" />
-                       <arg type="s" name="addr" direction="in"/>
-                       <arg type="i" name="port" direction="in"/>
-                       <arg type="(iay)" name="data" direction="in"/>
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="FindMownedDevices">
-                       <arg type="i" name="timeout" direction="in" />
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="GetMownedDevice">
-                       <arg type="i" name="device_count" direction="out" />
-                       <arg type="aa{sv}" name="device_info" direction="out" />
-               </method>
-               <method name="GetMyMownedDevice">
-                       <arg type="a{sv}" name="device_info" direction="out" />
-               </method>
-               <method name="GetMyUuid">
-                       <arg type="s" name="uuid" direction="out" />
-               </method>
-               <method name="RequestCreateGroup">
-                       <arg type="s" name="uuid" direction="in" />
-                       <arg type="s" name="group_name" direction="in" />
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="RequestInvite">
-                       <arg type="s" name="uuid" direction="in" />
-                       <arg type="s" name="group_name" direction="in" />
-                       <arg type="s" name="target_uuid" direction="in" />
-                       <arg type="s" name="pin" direction="in" />
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="RequestEject">
-                       <arg type="s" name="uuid" direction="in" />
-                       <arg type="s" name="group_name" direction="in" />
-                       <arg type="s" name="target_uuid" direction="in" />
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="RequestDeleteGroup">
-                       <arg type="s" name="uuid" direction="in" />
-                       <arg type="s" name="group_name" direction="in" />
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <method name="StartInvitedDeviceMonitor">
-                       <arg type="i" name="start" direction="in" />
-                       <arg type="i" name="result" direction="out" />
-               </method>
-               <!-- Signal (D-Bus) definitions -->
-               <signal name="GroupFound">
-                       <arg type="a{sv}" name="group_info" direction="out" />
-               </signal>
-               <signal name="GroupFindFinish">
-                       <arg type="i" name="result" direction="out" />
-               </signal>
-               <signal name="DeviceFound">
-                       <arg type="i" name="device_count" direction="out" />
-                       <arg type="aa{sv}" name="device_info" direction="out" />
-               </signal>
-               <signal name="DeviceFindFinish">
-                       <arg type="i" name="result" direction="out" />
-               </signal>
-               <signal name="DeviceInviteResult">
-                       <arg type="i" name="result" direction="out" />
-               </signal>
-               <signal name="DeviceEjectResult">
-                       <arg type="i" name="result" direction="out" />
-               </signal>
-               <signal name="MownedDeviceFound">
-                       <arg type="i" name="device_count" direction="out" />
-                       <arg type="aa{sv}" name="device_info" direction="out" />
-               </signal>
-               <signal name="MownedDeviceFindFinish">
-                       <arg type="i" name="result" direction="out" />
-               </signal>
-               <signal name="JoinResult">
-                       <arg type="i" name="result" direction="out" />
-               </signal>
-               <signal name="SendDataFinish">
-                       <arg type="s" name="resp_data" direction="out" />
-                       <arg type="i" name="result" direction="out" />
-               </signal>
-               <signal name="RequestResult">
-                       <arg type="s" name="command" direction="out" />
-                       <arg type="s" name="device_id" direction="out" />
-                       <arg type="(iay)" name="arg" direction="out" />
-                       <arg type="i" name="result" direction="out" />
-               </signal>
-               <signal name="DeviceMonitorResult">
-                       <arg type="s" name="uuid" direct="out" />
-                       <arg type="s" name="group_name" direct="out" />
-                       <arg type="s" name="status" direct="out" />
-               </signal>
-       </interface>
-</node>
diff --git a/capi/unittest/CMakeLists.txt b/capi/unittest/CMakeLists.txt
deleted file mode 100644 (file)
index 8f24177..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-SET(MDG_UNIT_TEST "mdg_unit_test")
-
-SET(MDG_UNIT_TEST_SOURCES
-       mdg_unit_test.cpp
-)
-
-ADD_EXECUTABLE(${MDG_UNIT_TEST} ${MDG_UNIT_TEST_SOURCES})
-
-TARGET_LINK_LIBRARIES(${MDG_UNIT_TEST}
-       ${daemon_pkgs_LIBRARIES} capi-network-mdg)
-
-INSTALL(TARGETS ${MDG_UNIT_TEST} DESTINATION bin/)
diff --git a/capi/unittest/mdg_unit_test.cpp b/capi/unittest/mdg_unit_test.cpp
deleted file mode 100644 (file)
index a9786b2..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2018 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 <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <unistd.h>
-#include <glib.h>
-#include <dlog.h>
-#include <mdg.h>
-#include <iostream>
-
-using namespace std;
-
-using ::testing::EmptyTestEventListener;
-using ::testing::InitGoogleTest;
-using ::testing::Test;
-using ::testing::TestCase;
-using ::testing::TestEventListeners;
-using ::testing::TestInfo;
-using ::testing::TestPartResult;
-using ::testing::UnitTest;
-
-mdg_h handle = NULL;
-
-TEST(mdg, mdg_initialize_p) {
-
-}
-
-TEST(mdg, mdg_initialize_n) {
-
-}
-
-TEST(mdg, mdg_deinitialize_p) {
-
-}
-
-TEST(mdg, mdg_deinitialize_n) {
-
-}
-
-TEST(mdg, mdg_group_create_p) {
-       cout << "TEST START" << endl;
-
-       int ret;
-
-       mdg_initialize(&handle);
-       ret = mdg_group_create(handle, (char *)"group1");
-
-       cout << "TEST END :" <<  ret << endl;
-}
-
-GMainLoop *main_loop = NULL;
-
-bool _mdg_group_found_cb(mdg_group_type_e type, mdg_group_h group_handle, void *user_data)
-{
-       char *uri_path;
-       mdg_group_info_get_uri_path(group_handle, &uri_path);
-
-       cout << "group type : " << type << ", uri : " << uri_path << endl;
-
-       return true;
-}
-
-void _mdg_finish_cb(int result, void *user_data)
-{
-       cout << "find finish : " << result << endl;
-       g_main_loop_quit(main_loop);
-
-       mdg_group_h *groups;
-       int count;
-
-       mdg_group_get_found_groups(handle, &groups, &count);
-       cout << "Found groups device count : " << count << endl;
-
-       for (int i = 0; i < count; i++) {
-               mdg_group_type_e type;
-               char *uri_path;
-               mdg_group_info_get_type(groups[i], &type);
-               mdg_group_info_get_uri_path(groups[i], &uri_path);
-               cout << i+1 << ". device group type : " << type << ", uri_path : " << uri_path << endl;
-       }
-}
-
-TEST(mdg, mdg_group_find_p) {
-       cout << "TEST START" << endl;
-       mdg_initialize(&handle);
-       main_loop = g_main_loop_new(NULL, FALSE);
-       mdg_group_find(handle, 5, _mdg_group_found_cb, _mdg_finish_cb, main_loop);
-       g_main_loop_run(main_loop);
-       cout << "TEST END" << endl;
-}
-
-int main(int argc, char **argv) {
-       InitGoogleTest(&argc, argv);
-       return RUN_ALL_TESTS();
-}
similarity index 100%
rename from capi/doc/mdg_doc.h
rename to doc/mdg_doc.h
similarity index 100%
rename from capi/include/mdg.h
rename to include/mdg.h
diff --git a/install.sh b/install.sh
deleted file mode 100755 (executable)
index 0ac2fbe..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-device_name=$1
-GBS_ROOT=$2
-if [ -z $device_name ]
-then
-       echo "Install.."
-       sdb root on
-       sdb shell mount -o remount,rw /
-       sdb push ~/GBS-ROOT/50std/local/repos/tizen50std/armv7l/RPMS/d2d-manager-* /tmp/
-       sdb shell rpm -e d2d-manager-capi-devel
-       sdb shell rpm -e d2d-manager-capi
-       sdb shell rpm -e d2d-manager-devel
-       sdb shell rpm -e d2d-manager
-       sdb shell rpm -Uvh --force --nodeps /tmp/*.rpm
-       sdb shell sync
-else
-       echo "Install to $device_name"
-       sdb -s $device_name root on
-       sdb -s $device_name shell mount -o remount,rw /
-       if [ -z $GBS_ROOT ]
-       then
-               sdb -s $device_name push ~/GBS-ROOT/50std/local/repos/tizen50std/armv7l/RPMS/d2d-manager-* /tmp/
-       else
-               sdb -s $device_name push  $GBS_ROOT/d2d-manager* /tmp/
-       fi
-       sdb -s $device_name shell rpm -e d2d-manager-capi-devel
-       sdb -s $device_name shell rpm -e d2d-manager-capi
-       sdb -s $device_name shell rpm -e d2d-manager-devel
-       sdb -s $device_name shell rpm -e d2d-manager
-       sdb -s $device_name shell rpm -Uvh --force --nodeps /tmp/*.rpm
-       sdb -s $device_name shell sync
-fi
-
-#sdb dlog -c
-#sdb dlog -v time D2D_SUBOWNER OIC_PM_UTILITY OIC_RI_STACK OIC_CA_CONN_MGR OIC_CA_PRTCL_MSG OIC_RI_CLIENTCB OIC_RM_UTIL OIC_RM_RAP
diff --git a/material/gbs-configure/gbs.4.0.tm1.conf b/material/gbs-configure/gbs.4.0.tm1.conf
deleted file mode 100755 (executable)
index b9d5200..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-[general]
-#Current profile name which should match a profile section name
-profile = profile.TM1
-
-########################### PROFILES ############################
-[profile.TM1]
-repos = repo.4.0-base, repo.4.0-unified
-buildroot = ~/GBS-ROOT-D2D/
-
-# * 4.0 BASE
-[repo.4.0-base]
-url=http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/arm/packages/
-
-# * 4.0
-[repo.4.0-unified]
-url=http://download.tizen.org/snapshots/tizen/4.0-unified/latest/repos/standard/packages/
diff --git a/material/iotcon/iotcon-0.3.20-0.armv7l.rpm b/material/iotcon/iotcon-0.3.20-0.armv7l.rpm
deleted file mode 100644 (file)
index 1881b81..0000000
Binary files a/material/iotcon/iotcon-0.3.20-0.armv7l.rpm and /dev/null differ
diff --git a/material/iotcon/iotcon-debuginfo-0.3.20-0.armv7l.rpm b/material/iotcon/iotcon-debuginfo-0.3.20-0.armv7l.rpm
deleted file mode 100644 (file)
index 7be8432..0000000
Binary files a/material/iotcon/iotcon-debuginfo-0.3.20-0.armv7l.rpm and /dev/null differ
diff --git a/material/iotcon/iotcon-debugsource-0.3.20-0.armv7l.rpm b/material/iotcon/iotcon-debugsource-0.3.20-0.armv7l.rpm
deleted file mode 100644 (file)
index cacf685..0000000
Binary files a/material/iotcon/iotcon-debugsource-0.3.20-0.armv7l.rpm and /dev/null differ
diff --git a/material/iotcon/iotcon-devel-0.3.20-0.armv7l.rpm b/material/iotcon/iotcon-devel-0.3.20-0.armv7l.rpm
deleted file mode 100644 (file)
index 25d2a3b..0000000
Binary files a/material/iotcon/iotcon-devel-0.3.20-0.armv7l.rpm and /dev/null differ
diff --git a/material/iotcon/iotcon-test-0.3.20-0.armv7l.rpm b/material/iotcon/iotcon-test-0.3.20-0.armv7l.rpm
deleted file mode 100644 (file)
index 75fb125..0000000
Binary files a/material/iotcon/iotcon-test-0.3.20-0.armv7l.rpm and /dev/null differ
diff --git a/material/iotcon/iotcon-test-debuginfo-0.3.20-0.armv7l.rpm b/material/iotcon/iotcon-test-debuginfo-0.3.20-0.armv7l.rpm
deleted file mode 100644 (file)
index 0736d85..0000000
Binary files a/material/iotcon/iotcon-test-debuginfo-0.3.20-0.armv7l.rpm and /dev/null differ
diff --git a/material/iotivity-mot-enabled/iotivity-1.2.1-9.armv7l.rpm b/material/iotivity-mot-enabled/iotivity-1.2.1-9.armv7l.rpm
deleted file mode 100644 (file)
index f1dce97..0000000
Binary files a/material/iotivity-mot-enabled/iotivity-1.2.1-9.armv7l.rpm and /dev/null differ
diff --git a/material/iotivity-mot-enabled/iotivity-debuginfo-1.2.1-9.armv7l.rpm b/material/iotivity-mot-enabled/iotivity-debuginfo-1.2.1-9.armv7l.rpm
deleted file mode 100644 (file)
index f61cb70..0000000
Binary files a/material/iotivity-mot-enabled/iotivity-debuginfo-1.2.1-9.armv7l.rpm and /dev/null differ
diff --git a/material/iotivity-mot-enabled/iotivity-debugsource-1.2.1-9.armv7l.rpm b/material/iotivity-mot-enabled/iotivity-debugsource-1.2.1-9.armv7l.rpm
deleted file mode 100644 (file)
index 40ff4ba..0000000
Binary files a/material/iotivity-mot-enabled/iotivity-debugsource-1.2.1-9.armv7l.rpm and /dev/null differ
diff --git a/material/iotivity-mot-enabled/iotivity-devel-1.2.1-9.armv7l.rpm b/material/iotivity-mot-enabled/iotivity-devel-1.2.1-9.armv7l.rpm
deleted file mode 100644 (file)
index 991da7e..0000000
Binary files a/material/iotivity-mot-enabled/iotivity-devel-1.2.1-9.armv7l.rpm and /dev/null differ
diff --git a/material/iotivity-mot-enabled/iotivity-devel-debuginfo-1.2.1-9.armv7l.rpm b/material/iotivity-mot-enabled/iotivity-devel-debuginfo-1.2.1-9.armv7l.rpm
deleted file mode 100644 (file)
index ec03452..0000000
Binary files a/material/iotivity-mot-enabled/iotivity-devel-debuginfo-1.2.1-9.armv7l.rpm and /dev/null differ
diff --git a/material/iotivity-mot-enabled/iotivity-service-1.2.1-9.armv7l.rpm b/material/iotivity-mot-enabled/iotivity-service-1.2.1-9.armv7l.rpm
deleted file mode 100644 (file)
index f7338d3..0000000
Binary files a/material/iotivity-mot-enabled/iotivity-service-1.2.1-9.armv7l.rpm and /dev/null differ
diff --git a/material/iotivity-mot-enabled/iotivity-service-debuginfo-1.2.1-9.armv7l.rpm b/material/iotivity-mot-enabled/iotivity-service-debuginfo-1.2.1-9.armv7l.rpm
deleted file mode 100644 (file)
index 3303bf4..0000000
Binary files a/material/iotivity-mot-enabled/iotivity-service-debuginfo-1.2.1-9.armv7l.rpm and /dev/null differ
diff --git a/material/iotivity-mot-enabled/iotivity-test-1.2.1-9.armv7l.rpm b/material/iotivity-mot-enabled/iotivity-test-1.2.1-9.armv7l.rpm
deleted file mode 100644 (file)
index 360e3dd..0000000
Binary files a/material/iotivity-mot-enabled/iotivity-test-1.2.1-9.armv7l.rpm and /dev/null differ
diff --git a/material/iotivity-mot-enabled/iotivity-test-debuginfo-1.2.1-9.armv7l.rpm b/material/iotivity-mot-enabled/iotivity-test-debuginfo-1.2.1-9.armv7l.rpm
deleted file mode 100644 (file)
index 3fbfd2a..0000000
Binary files a/material/iotivity-mot-enabled/iotivity-test-debuginfo-1.2.1-9.armv7l.rpm and /dev/null differ
diff --git a/material/mdbus2 b/material/mdbus2
deleted file mode 100755 (executable)
index e36f4c7..0000000
Binary files a/material/mdbus2 and /dev/null differ
diff --git a/material/script/d2d_build.sh b/material/script/d2d_build.sh
deleted file mode 100755 (executable)
index 86cfc21..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-git_path="/data/workspace/d2d-manager"
-
-mkdir -p ~/GBS-ROOT-D2D/local/repos/TM1/armv7l/RPMS
-cp $git_path/material/iotivity-mot-enabled/*.rpm ~/GBS-ROOT-D2D/local/repos/TM1/armv7l/RPMS
-
-#build TM1
-gbs -c $git_path/material/gbs-configure/gbs.4.0.tm1.conf build -A armv7l --include-all
diff --git a/material/script/d2d_install.sh b/material/script/d2d_install.sh
deleted file mode 100755 (executable)
index 596389b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-git_path="/data/workspace/d2d-manager"
-
-# build
-sh $git_path/material/script/d2d_build.sh
-
-# initialize device
-sdb root on
-sdb shell mount -o remount, rw /
-
-# Push & install rpm package TM1
-sdb push ~/GBS-ROOT-D2D/local/repos/TM1/armv7l/RPMS/*.rpm /tmp/
-sdb shell rpm -Uvh --force --nodeps /tmp/*.rpm
-
-sdb shell 
diff --git a/packaging/capi-network-mdg.spec b/packaging/capi-network-mdg.spec
new file mode 100644 (file)
index 0000000..6f6fa7d
--- /dev/null
@@ -0,0 +1,79 @@
+Name:       capi-network-mdg
+Summary:    Multi Device Group CAPI
+Version:    0.0.1
+Release:    0
+Group:      Network & Connectivity/Other
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1:    %{name}.manifest
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(gio-unix-2.0)
+BuildRequires: pkgconfig(capi-system-info)
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+Multi Device Group API library
+Group:    Network & Connectivity/Other
+Requires: %{name} = %{version}-%{release}
+
+%package devel
+Summary:  Multi Device Group API library (development library)
+Group:    Network & Connectivity/Other
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+This package contains the development files for %{name} API library.
+
+%prep
+%setup -q
+chmod 644 %{SOURCE0}
+chmod 644 %{SOURCE1}
+
+cp %{SOURCE1} .
+
+%build
+CFLAGS=$(echo $CFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
+CXXFLAGS=$(echo $CXXFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
+
+%if 0%{?gcov:1}
+export LDFLAGS+=" -lgcov"
+%endif
+
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+
+%define NETWORK_FW_DATADIR %{TZ_SYS_GLOBALUSER_DATA}/network
+%define DBDIR %{TZ_SYS_GLOBALUSER_DATA}/
+
+%cmake . \
+    -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
+       -DLIB_DIR=%{_libdir} -DBIN_DIR=%{_bindir} -DSBIN_DIR=%{_sbindir} \
+       -DNETWORK_FW_DATADIR=%{NETWORK_FW_DATADIR} \
+       -DDBDIR=%{DBDIR} -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
+
+make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}/BUILD/%{name}*
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest capi-network-mdg.manifest
+%defattr(-,root,root,-)
+%{_libdir}/libcapi-network-mdg.so*
+
+%files devel
+%{_includedir}/*.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-network-mdg.so
+%attr(777,network_fw,network_fw) %{_bindir}/mdg-test
diff --git a/packaging/d2d-manager-devel.manifest b/packaging/d2d-manager-devel.manifest
deleted file mode 100644 (file)
index a76fdba..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<manifest>
-       <request>
-               <domain name="_" />
-       </request>
-</manifest>
diff --git a/packaging/d2d-manager.spec b/packaging/d2d-manager.spec
deleted file mode 100644 (file)
index f9cf423..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-Name:       d2d-manager
-Summary:    D2D Manager
-Version:    0.0.1
-Release:    0
-Group:      Network & Connectivity/Other
-License:    Apache-2.0
-Source0:    %{name}-%{version}.tar.gz
-Source3:    %{name}.manifest
-Source4:    %{name}-devel.manifest
-Source6:    mdgd.service
-Source7:    net.mdgd.service
-Source8:    ma.service
-Source9:    net.ma.service
-Source10:    capi-network-mdg.manifest
-
-BuildRequires: cmake
-BuildRequires: pkgconfig(iotivity)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(gio-2.0)
-BuildRequires: pkgconfig(gio-unix-2.0)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(dbus-1)
-BuildRequires: pkgconfig(json-glib-1.0)
-BuildRequires: pkgconfig(uuid)
-BuildRequires: pkgconfig(capi-base-common)
-BuildRequires: pkgconfig(capi-system-info)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(boost)
-BuildRequires: pkgconfig(capi-network-wifi-manager)
-BuildRequires: pkgconfig(libtzplatform-config)
-BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(gmock)
-BuildRequires: pkgconfig(sqlite3)
-BuildRequires: pkgconfig(capi-system-system-settings)
-%description
-D2D Manager
-
-%package devel
-Summary:  D2D Manager (Development)
-Group:    Network & Connectivity/Other
-Requires: %{name} = %{version}-%{release}
-
-%description devel
-This package contains the development files for %{name}.
-
-%package capi
-Summary:  D2D Manager CAPI
-Group:    Network & Connectivity/Other
-Requires: %{name} = %{version}-%{release}
-
-%description capi
-D2D Manager CAPI.
-
-%package capi-devel
-Summary:  D2D Manager CAPI (Development)
-Group:    Network & Connectivity/Other
-Requires: %{name} = %{version}-%{release}
-
-%description capi-devel
-This package contains the development files for %{name} CAPI.
-
-%prep
-%setup -q
-chmod 644 %{SOURCE0}
-chmod 644 %{SOURCE3}
-chmod 644 %{SOURCE4}
-chmod 644 %{SOURCE6}
-chmod 644 %{SOURCE7}
-chmod 644 %{SOURCE8}
-chmod 644 %{SOURCE9}
-chmod 644 %{SOURCE10}
-
-cp %{SOURCE3} .
-cp %{SOURCE4} .
-cp %{SOURCE6} .
-cp %{SOURCE7} .
-cp %{SOURCE8} .
-cp %{SOURCE9} .
-cp %{SOURCE10} .
-
-%build
-CFLAGS=$(echo $CFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
-CXXFLAGS=$(echo $CXXFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//')
-
-MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-
-%define NETWORK_FW_DATADIR %{TZ_SYS_GLOBALUSER_DATA}/network
-%define DBDIR %{TZ_SYS_GLOBALUSER_DATA}/
-
-%cmake . \
-    -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \
-       -DLIB_DIR=%{_libdir} -DBIN_DIR=%{_bindir} -DSBIN_DIR=%{_sbindir} \
-       -DNETWORK_FW_DATADIR=%{NETWORK_FW_DATADIR} \
-       -DDBDIR=%{DBDIR}
-make %{?_smp_mflags}
-
-%install
-rm -rf %{buildroot}/BUILD/%{name}*
-%make_install
-
-mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/
-
-cp %{SOURCE7} %{buildroot}%{_datadir}/dbus-1/system-services/net.mdgd.service
-mkdir -p %{buildroot}%{_unitdir}
-cp %{SOURCE6} %{buildroot}%{_unitdir}/mdgd.service
-
-cp %{SOURCE9} %{buildroot}%{_datadir}/dbus-1/system-services/net.ma.service
-mkdir -p %{buildroot}%{_unitdir}
-cp %{SOURCE8} %{buildroot}%{_unitdir}/ma.service
-
-%postun
-rm -rf %{NETWORK_FW_DATADIR}/*.db
-rm -rf %{NETWORK_FW_DATADIR}/*.db-journal
-rm -rf /opt/usr/dbspace/.mdgd.db
-rm -rf /opt/usr/dbspace/.mdgd.db-journal
-
-%files
-%manifest %{name}.manifest
-%license LICENSE
-%defattr(-,root,root,-)
-%{_bindir}/mot-agent
-%{_bindir}/mdgd
-%attr(644,root,root) %{_datadir}/dbus-1/system-services/*
-%attr(644,root,root) %{_unitdir}/mdgd.service
-%attr(644,root,root) %{_unitdir}/ma.service
-%attr(644,network_fw,network_fw) %{NETWORK_FW_DATADIR}/oic_svr_db_ma.dat
-%attr(644,network_fw,network_fw) %{NETWORK_FW_DATADIR}/oic_svr_db_mdgd_manager.dat
-
-%files devel
-%manifest %{name}-devel.manifest
-
-%files capi
-%manifest capi-network-mdg.manifest
-%defattr(-,root,root,-)
-%{_libdir}/libcapi-network-mdg.so*
-
-%files capi-devel
-%{_includedir}/*.h
-%{_libdir}/pkgconfig/*.pc
-%{_libdir}/libcapi-network-mdg.so
-%attr(777,root,root) %{_bindir}/mdg_unit_test
-%attr(777,root,root) %{_bindir}/mdg-test
diff --git a/packaging/ma.service b/packaging/ma.service
deleted file mode 100644 (file)
index ec192c1..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=OCF MOT Agent
-Requires=dbus.socket
-After=dbus.socket
-
-[Service]
-Type=dbus
-User=network_fw
-Group=network_fw
-BusName=net.ma.enabler
-SmackProcessLabel=System
-ExecStart=/usr/bin/mot-agent
diff --git a/packaging/mdgd.service b/packaging/mdgd.service
deleted file mode 100644 (file)
index 09a5120..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Unit]
-Description=Multi Device Group Manager
-After=feedbckd.service
-
-[Service]
-Type=dbus
-User=network_fw
-Group=network_fw
-BusName=org.tizen.mdg
-SmackProcessLabel=System
-ExecStart=/usr/bin/mdgd
-
-[Install]
-WantedBy=multi-user.target
diff --git a/packaging/net.ma.service b/packaging/net.ma.service
deleted file mode 100644 (file)
index 5a45583..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-[D-BUS Service]
-Name=net.ma.enabler
-
-Exec=/bin/false
-User=network_fw
-Group=network_fw
-SystemdService=ma.service
diff --git a/packaging/net.mdgd.service b/packaging/net.mdgd.service
deleted file mode 100644 (file)
index 59fa3ab..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-[D-BUS Service]
-Name=org.tizen.mdg
-
-Exec=/bin/false
-User=network_fw
-Group=network_fw
-SystemdService=mdgd.service
similarity index 100%
rename from src/mdg-manager/src/gen.sh
rename to src/gen.sh
diff --git a/src/mdg-manager/CMakeLists.txt b/src/mdg-manager/CMakeLists.txt
deleted file mode 100644 (file)
index a641216..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-MESSAGE("===================================================================")
-MESSAGE("Building...mdgd")
-MESSAGE("===================================================================")
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
-                " \\
-                --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/mdg_gdbus \\
-                --interface-prefix org.tizen.mdg. \\
-                ${CMAKE_CURRENT_SOURCE_DIR}/src/mdg_gdbus.xml \\
-                ")
-
-MESSAGE(" - Set source folder")
-FILE(GLOB MDGD_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
-
-SET(MDGD "mdgd")
-ADD_EXECUTABLE(${MDGD} ${MDGD_SRCS})
-TARGET_LINK_LIBRARIES(${MDGD} ${daemon_pkgs_LIBRARIES} pthread)
-INSTALL(TARGETS ${MDGD} DESTINATION bin)
-INSTALL(FILES oic_svr_db_mdgd_manager.dat DESTINATION ${NETWORK_FW_DATADIR})
diff --git a/src/mdg-manager/include/mdgd_context.h b/src/mdg-manager/include/mdgd_context.h
deleted file mode 100644 (file)
index 6a699b3..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_CONTEXT_H__
-#define __MDGD_CONTEXT_H__
-
-#include <glib.h>
-#include <mdgd_log.h>
-#include <unistd.h>
-#include <gio/gio.h>
-#include <mdg_gdbus.h>
-#include <sys/types.h>
-#include <sqlite3.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef struct {
-       GMainLoop *main_loop;
-       //GDBusConnection *connection;
-       int ref_count;
-
-       // resource list
-       GList *resource_list[MDGD_RESOURCE_TYPE_MAX];
-
-       char *device_uuid;
-       bool mot_me; /**< Indicator whether mot local comp-manager */
-       GList *grp_list;
-       GList *pairwise_list;
-
-       bool monitor_started;
-       bool first_search;
-
-       //sqlite3 db
-       sqlite3 *db;
-} mdgd_context_t;
-
-typedef struct {
-       char *conn_name;
-       int conn_id;
-       GDBusConnection *connection;
-} mdgd_conn_destroy_data;
-
-int mdgd_context_create();
-int mdgd_context_destroy();
-void mdgd_context_mutex_lock();
-void mdgd_context_mutex_unlock();
-
-mdgd_context_t *mdgd_context_get_context();
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __MDGD_CONTEXT_H__ */
diff --git a/src/mdg-manager/include/mdgd_db.h b/src/mdg-manager/include/mdgd_db.h
deleted file mode 100644 (file)
index b9d7e74..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2016 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 __MDGD_DB_H__
-#define __MDGD_DB_H__
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <stdbool.h>
-
-#define MDGD_DB_FILE "/opt/usr/dbspace/.mdgd.db"
-#define MDGD_DB_GROUP_TABLE "mdgd_group"
-#define MDGD_DB_DEVICE_TABLE "mdgd_device"
-
-int mdgd_db_init();
-int mdgd_db_deinit();
-int mdgd_db_group_insert(const char *group_name);
-int mdgd_db_device_insert(const char *device_id, const char *group_name);
-int mdgd_db_group_delete(char *group_name);
-int mdgd_db_device_delete(char *device_id, char *group_name);
-bool mdgd_check_device_exist(char *device_id);
-bool mdgd_check_group_exist(const char *group_name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/mdg-manager/include/mdgd_enum.h b/src/mdg-manager/include/mdgd_enum.h
deleted file mode 100644 (file)
index e733d59..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_ENUM_H__
-#define __MDGD_ENUM_H__
-
-#include <tizen.h>
-
-#define NOTUSED(var) (var = var) /**< It is used to avoid generating build warning */
-
-#ifndef TIZEN_ERROR_MDG
-#define TIZEN_ERROR_MDG -0x02F50000 /**< Base error code */
-#endif
-
-/**
- * @brief Error codes for mdg-manager.
- *
- * @since_tizen 5.0
- */
-typedef enum {
-       MDGD_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
-       MDGD_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
-       MDGD_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
-       MDGD_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
-       MDGD_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
-       MDGD_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
-       MDGD_ERROR_NO_DATA = TIZEN_ERROR_MDG | 0x01, /**< Data not exists */
-       MDGD_ERROR_OPERATION_FAILED = TIZEN_ERROR_MDG | 0x02, /**< operation failed */
-       MDGD_ERROR_ALREADY_REGISTERED = TIZEN_ERROR_MDG | 0x03, /**< Request already registered */
-       MDGD_ERROR_IN_PROGRESS = TIZEN_ERROR_MDG | 0x04,/**< operation is in progress */
-       MDGD_ERROR_COMM_ERROR = TIZEN_ERROR_MDG | 0x05, /**< communication error */
-       MDGD_ERROR_RX = TIZEN_ERROR_MDG | 0x06, /**< RX error */
-       MDGD_ERROR_TX = TIZEN_ERROR_MDG | 0x07, /**< TX error */
-       MDGD_ERROR_PLUGIN_FAIL = TIZEN_ERROR_MDG | 0x08, /**< Plugin failed */
-       MDGD_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_MDG | 0x09, /**< Already in progress */
-       MDGD_ERROR_NOT_STARTED = TIZEN_ERROR_MDG | 0x0A, /**< Not Started */
-       MDGD_ERROR_ALREADY_INITIALIZED = TIZEN_ERROR_MDG | 0x0B, /**< Already initilized */
-       MDGD_ERROR_UNKNOWN = -999
-} mdgd_error_e;
-
-/**
- * @brief Resource type.
- *
- * @since_tizen 5.0
- */
-typedef enum {
-       MDGD_RESOURCE_TYPE_GROUP = 0, /**< Group resource type  */
-       MDGD_RESOURCE_TYPE_DEVICE, /**< Device resource type  */
-       MDGD_RESOURCE_TYPE_OPERATION, /**< Operation resource type */
-       MDGD_RESOURCE_TYPE_DATA, /**< Data resource type */
-       MDGD_RESOURCE_TYPE_MAX
-} mdgd_resource_type_e;
-
-/**
- * @brief Group type.
- *
- * @since_tizen 5.0
- */
-typedef enum {
-       MDGD_GROUP_GROUP_ERROR = 0, /**< Group type error */
-       MDGD_GROUP_GROUP_LOCAL = 1, /**< Local group type */
-       MDGD_GROUP_GROUP_REMOTE = 2, /**< Remote group type */
-} mdgd_group_type_e;
-
-typedef enum {
-       MDGD_GROUP_DEVICE_ERROR = 0, /**< Group type error */
-       MDGD_GROUP_DEVICE_LOCAL = 1, /**< Local group type */
-       MDGD_GROUP_DEVICE_REMOTE = 2, /**< Remote group type */
-} mdgd_device_type_e;
-
-/**
- * @brief The command type for request.
- *
- * @since_tizen 5.0
- */
-typedef enum {
-       MDGD_REQ_UNKNOWN_COMMAND = -1, /**< Unknown Command */
-       MDGD_REQ_SEND_DATA = 0, /**< Send data */
-       MDGD_REQ_CREATE_GROUP, /**< Create Group */
-       MDGD_REQ_INVITE_DEVICE, /**< Invite Device */
-       MDGD_REQ_EJECT_DEVICE, /**< Exile Device */
-       MDGD_REQ_DELETE_GROUP, /**< Delete Group */
-       MDGD_REQ_KEEP_ALIVE, /**< Keep Alive Message */
-       MDGD_REQ_SEND_DATA_ALL, /**< Send data in subnet */
-} mdgd_request_type_e;
-
-#endif /* __MDGD_ENUM_H__ */
diff --git a/src/mdg-manager/include/mdgd_gdbus.h b/src/mdg-manager/include/mdgd_gdbus.h
deleted file mode 100644 (file)
index bc22f0d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_GDBUS_H__
-#define __MDGD_GDBUS_H__
-
-#include <mdgd_gdbus_group.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define MDGD_DBUS_SERVICE "org.tizen.mdg" /**< For mdg dbus */
-#define MDGD_DBUS_GROUP_PATH "/org/tizen/mdg/group" /**< For group commands */
-#define MDGD_DBUS_ENABLER_PATH "/org/tizen/mdg/enabler" /**< For d-bus activation */
-
-int mdgd_gdbus_init();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MDGD_GDBUS_H__ */
diff --git a/src/mdg-manager/include/mdgd_gdbus_group.h b/src/mdg-manager/include/mdgd_gdbus_group.h
deleted file mode 100644 (file)
index 8574815..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_GDBUS_GROUP_H__
-#define __MDGD_GDBUS_GROUP_H__
-
-#include <mdgd_group.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-Group *group_dbus_get_object();
-
-gboolean group_create(Group *group, GDBusMethodInvocation *invocation, gchar *group_name,
-       gpointer user_data);
-
-gboolean group_find(Group *group, GDBusMethodInvocation *invocation, gint timeout,
-       gpointer user_data);
-
-gboolean group_get_found_groups(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data);
-
-gboolean group_join(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data);
-
-gboolean group_leave(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data);
-
-gboolean group_delete(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data);
-
-gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation,
-       gint timeout, gpointer user_data);
-
-gboolean group_device_invite(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid_dev1, gchar *uuid_dev2, gchar *pin, gchar *uri_1, gchar *rt_1,
-       gchar *interface_1, int permission_1, gchar *uri_2, gchar *rt_2,
-       gchar *interface_2, int permission_2, gpointer user_data);
-
-gboolean group_device_eject(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid_dev1, gchar *uuid_dev2, gpointer user_data);
-
-gboolean group_invite(Group *group, GDBusMethodInvocation *invocation, gchar *group_name,
-       gchar *uuid, gchar *pin, gpointer user_data);
-
-gboolean group_eject(Group *group, GDBusMethodInvocation *invocation, gchar *group_name,
-       gchar *uuid, gpointer user_data);
-
-gboolean group_get_remote_device(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data);
-
-gboolean group_pair_resource(Group *group, GDBusMethodInvocation *invocation,
-       gchar *target_1, gchar *subject_1, gchar *uri_1, gchar *rt_1,
-       gchar *interface_1, int permission_1, gchar *target_2, gchar *subject_2,
-       gchar *uri_2, gchar *rt_2, gchar *interface_2, int permission_2,
-       gpointer user_data);
-
-gboolean group_unpair_resource(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid_dev1, gchar *uuid_dev2, gpointer user_data);
-
-gboolean group_send_data(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid_dev, gchar *addr, int port, GVariant *params,
-       gpointer user_data);
-
-gboolean group_find_mowned_devices(Group *group,
-       GDBusMethodInvocation *invocation, int timeout, gpointer user_data);
-
-gboolean group_get_mowned_device(Group *group,
-       GDBusMethodInvocation *invocation, gpointer user_data);
-
-gboolean group_get_my_mowned_device(Group *group,
-       GDBusMethodInvocation *invocation, gpointer user_data);
-
-gboolean group_get_my_uuid(Group *group,
-       GDBusMethodInvocation *invocation, gpointer user_data);
-
-gboolean group_request_create_group(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid, gchar *group_name, gpointer user_data);
-
-gboolean group_request_invite(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid, gchar *group_name, gchar *target_uuid, gchar *PIN, gpointer user_data);
-
-gboolean group_request_eject(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid, gchar *group_name, gchar *target_uuid, gpointer user_data);
-
-gboolean group_request_delete_group(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid, gchar *group_name, gpointer user_data);
-
-gboolean group_start_invited_device_monitor(Group *group,
-                                       GDBusMethodInvocation *invocation, int start,
-                                       gpointer user_data);
-
-void notify_group_found(GVariant *group_data);
-void notify_group_find_finish(int ret);
-void notify_device_found(int device_count, GVariant *device_data);
-void notify_device_find_finish(int ret);
-void notify_group_device_invite_result(int ret);
-void notify_group_device_eject_result(int ret);
-void notify_mowned_device_found(int device_count, GVariant *device_data);
-void notify_mowned_device_find_finish(int ret);
-void notify_group_join(int result);
-void notify_send_data_finish(const char *resp_data, int ret);
-void notify_request_result(const char *cmd, const char *requester_id,
-                                                  unsigned char *arg, int len, int ret);
-void notify_device_monitor_result(const char *uuid, const char *group_name,
-                                                                 const char *status);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __MDGD_GDBUS_GROUP_H__ */
diff --git a/src/mdg-manager/include/mdgd_group.h b/src/mdg-manager/include/mdgd_group.h
deleted file mode 100644 (file)
index 6adffe0..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_GROUP_H__
-#define __MDGD_GROUP_H__
-
-#include <mdgd_iot.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef struct {
-       char *uri_path; /**< URI path */
-       char *device_id; /**< Device ID */
-       char *host_addr; /**< Host address */
-       char *group_name; /**< Group name */
-       char *resource_type; /**< Resource type */
-       mdgd_group_type_e type; /**< Group yype */
-} mdgd_group_t;
-
-typedef struct {
-       char *device_id; /**< Device Id */
-       int adapter; /**< Adapter type */
-       int flags; /**< Flags */
-       int port; /**< Remtoe device is listening this port */
-       char *addr; /**< IP Address of remote device */
-       int ifindex; /**< Network interfce index of Remote device */
-       char *route_data; /**< Route data */
-       char *remote_id; /**< Remote Id */
-       int conn_type; /**< Connection type */
-       int secure_port; /**< Secured port once TLS handhaking complete */
-       int tcp_port; /**< TCP port when using CoAP over TCP */
-       char *sec_ver; /**< OCF Security specification version */
-       int dev_status; /**< Device status */
-       char *model_name; /**< Device ID */
-       char *device_name; /**< Host address */
-       char *platform_ver; /**< Group name */
-       char *vendor_id; /**< Resource type */
-       char *profile; /**< Group yype */
-       bool mowned;
-       mdgd_device_type_e type;
-} mdgd_mot_device_t;
-
-typedef struct {
-       char *group_name;
-       char *uuid_dev1; /**< Source device Id */
-       char *uuid_dev2; /**< Target device Id */
-       char *pin; /**< Random or pre-configured PIN */
-       char *uri_1; /**< URI at source resource */
-       char *rt_1; /**< Resource type at source resource */
-       char *interface_1; /**< Interface at source resource */
-       int permission_1; /**< CRUDN for target device */
-       char *uri_2; /**< URI at target resource */
-       char *rt_2; /**< Resource type at target resource */
-       char *interface_2; /**< Interface at target resource */
-       int permission_2; /**< CRUDN for source device */
-} mdgd_group_invite_info_t;
-
-typedef struct {
-       char *group_name; /**< Group Name */
-       char *uuid; /**< Device ID */
-       char *host; /**< Device Host Address */
-       int count; /**< Count of successful post method */
-} mdgd_invited_device_t;
-
-typedef struct {
-       char *name; /**< Group name */
-       GList *device_list; /**< Remote device UUIDs. (char* type) */
-} mdgd_grp_t;
-
-/* Called when daemon is start. */
-int mdgd_group_initialize();
-
-/* create group and destroy */
-int mdgd_group_create(const char* name);
-int mdgd_group_destroy(mdgd_group_t *handle);
-
-/* Find Remote groups */
-int mdgd_group_find(int timeout);
-GVariant *mdgd_group_get_found_groups();
-int mdgd_group_add_new(char *uri_path, char *device_id, char *device_name,
-                                char *host_addr, char *resource_type, mdgd_group_type_e type);
-
-/* Join the remote devices in my daemon */
-int mdgd_group_get_groups(mdgd_group_t ***handles, int *count); //Get all of group in my daemon
-int mdgd_group_get_remote_devices(/* callback */); //Get all of device in network (Async)
-
-int mdgd_group_add_new_mot_device(mdgd_mot_device_t *device);
-void mdgd_group_notify_mot_enable_device_done();
-int mdgd_group_find_mot_enabled_devices(int timeout);
-
-char *mdgd_group_invite_get_uuid();
-char *mdgd_group_invite_get_pin();
-
-/* Join to device in group (async) */
-int mdgd_group_invite(const char *group_name, const char *uuid,
-                                         const char *pin);
-mdgd_group_invite_info_t *mdgd_group_get_invite_info();
-void mdgd_group_free_invite_info();
-void mdgd_group_notify_group_invite(int result);
-
-/* eject from group (async) */
-int mdgd_group_eject(const gchar *group_name, gchar *uuid_dev1, const char *uuid_dev2);
-void mdgd_group_notify_group_dismiss(int result);
-
-int mdgd_group_pair_resource(char* target1, char *subject1, char *uri1,
-       char *rt1, char *interface1, int permission1, char* target2, char *subject2,
-       char *uri2, char *rt2, char *interface2, int permission2);
-
-int mdgd_group_unpair_resource(gchar *uuid_dev1, gchar *uuid_dev2);
-int mdgd_group_send_data(gchar *uuid_dev, gchar *addr, int port,
-                                                unsigned char *data, int len);
-void mdgd_group_notify_keepalive_response(mdgd_command_t *cmd);
-
-GVariant *mdgd_group_get_remote_mot_enabled_devices();
-int mdgd_group_get_mot_device_count();
-
-int mdgd_group_add_new_mowned_device(mdgd_mot_device_t *device);
-void mdgd_group_notify_mowned_device_find_done();
-int mdgd_group_find_mowned_devices();
-GVariant *mdgd_group_get_mowned_devices();
-int mdgd_group_get_mowned_device_count();
-GVariant *mdgd_group_get_my_mowned_devices();
-void mdgd_group_change_mowned_device(mdgd_mot_device_t *device);
-
-/* Join to remote device group */
-int mdgd_group_join();
-int mdgd_group_leave_from(/* callback */); //leave from certain remote group (Async)
-
-/* Called when daemon is end. */
-int mdgd_group_deinitialize();
-
-/* Getter for a group */
-int mdgd_group_get_group_name(mdgd_group_t *handle, char **name);
-int mdgd_group_get_group_type(mdgd_group_t *handle, int *type);
-int mdgd_group_get_group_device_type(mdgd_group_t *handle);
-int mdgd_group_get_group_device_id(mdgd_group_t *handle);
-
-/* notify */
-int mdgd_group_event_handler(/*callback*/); // event hadnler
-int mdgd_group_add_device_in_group(const char *group_name, const char *uuid);
-int mdgd_group_remove_device_in_group(char *group_name, char *uuid);
-
-/* Group management */
-int mdgd_group_request_create_group(char *uuid, char *group_name);
-int mdgd_group_request_invite(char *uuid, char *group_name, char *target_uuid, char *PIN);
-int mdgd_group_request_eject(char *uuid, char *group_name, char *target_uuid);
-int mdgd_group_request_delete_group(char *uuid, char *group_name);
-
-int mdgd_group_start_invited_device_monitor(int start);
-mdgd_mot_device_t *mdgd_group_check_device_in_mot_enb_dev_list(char *uuid);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __MDGD_GROUP_H__ */
diff --git a/src/mdg-manager/include/mdgd_iot.h b/src/mdg-manager/include/mdgd_iot.h
deleted file mode 100644 (file)
index b8b333f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_IOT_H__
-#define __MDGD_IOT_H__
-
-#include <mdgd_resource.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define SVR_PATH "/tmp/.svr.dat" /**< For Temp */
-
-typedef struct _iot_discovery_t {
-       gchar *uuid; /**< Device Id */
-       gchar *data; /**< Data to send */
-       gchar *host; /**< Target host IP address + Port */
-} iot_discovery_t;
-
-typedef struct _mdgd_command_t {
-       int tid; /**< Timer ID */
-       int resource_type; /**< OCF resource type */
-       mdgd_request_type_e command; /**< Comments set for group management */
-       gchar *uuid; /**< Device UUID */
-       gchar *host; /**< Host address + Port */
-       gchar *arg1; /**< Arguement #1 */
-       gchar *arg2; /**< Arguement #2 */
-       gchar *arg3; /**< Arguement #3 */
-       gchar *arg4; /**< Arguement #4 */
-#ifdef SUPPORT_BASE64_ENCODING
-       unsigned char *data;
-       int data_len;
-#endif
-       void *user_data;
-} mdgd_command_t;
-
-int mdgd_iot_initialize();
-int mdgd_iot_add_resource(mdgd_resource_type_e resource_type, const char *uri);
-int mdgd_iot_delete_resource(mdgd_resource_type_e resource_type);
-int mdgd_iot_discovery_resource(mdgd_resource_type_e resource_type, int timeout, void *user_data);
-int mdgd_iot_send_data(mdgd_resource_type_e resource_type, int timeout,
-                                          mdgd_command_t *cmd);
-int mdgd_iot_deinitialize();
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __MDGD_IOT_H__ */
diff --git a/src/mdg-manager/include/mdgd_log.h b/src/mdg-manager/include/mdgd_log.h
deleted file mode 100644 (file)
index db0c3d7..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_LOG_H__
-#define __MDGD_LOG_H__
-
-#include <dlog.h>
-#include <mdgd_enum.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define COLOR_RED               "\033[0;31m"
-#define COLOR_GREEN             "\033[0;32m"
-#define COLOR_BROWN             "\033[0;33m"
-#define COLOR_BLUE              "\033[0;34m"
-#define COLOR_PURPLE            "\033[0;35m"
-#define COLOR_CYAN              "\033[0;36m"
-#define COLOR_LIGHTBLUE         "\033[0;37m"
-#define COLOR_END               "\033[0;m"
-
-#define LOG_TAG "MDGD"
-
-#define LOG_DEBUG(fmt, ...) \
-       do { \
-               LOGD(COLOR_BROWN" " fmt COLOR_END, ##__VA_ARGS__); \
-       } while (0)
-#define LOG_ERR(fmt, ...) \
-       do { \
-               LOGE(COLOR_RED" " fmt COLOR_END, ##__VA_ARGS__); \
-       } while (0)
-#define LOG_BEGIN() \
-       do { \
-               LOGD(COLOR_BLUE "BEGIN" COLOR_END); \
-       } while (0)
-#define LOG_END() \
-       do { \
-               LOGD(COLOR_BLUE "END" COLOR_END); \
-       } while (0)
-
-#define NOTUSED(var) (var = var)
-
-#define mdgd_check_null_ret_error(name, value, error) do { \
-       /* LCOV_EXCL_START */ \
-       if (G_UNLIKELY(NULL == (value))) { \
-                               LOGE("%s is NULL", name); \
-                               return error; \
-                       } \
-       /* LCOV_EXCL_STOP */ \
-} while (FALSE)
-
-#define mdgd_check_null_ret(name, value) do { \
-       /* LCOV_EXCL_START */ \
-       if (G_UNLIKELY(NULL == (value))) { \
-                               LOGE("%s is NULL", name); \
-                               return; \
-                       } \
-       /* LCOV_EXCL_STOP */ \
-} while (FALSE)
-
-const char *mdgd_log_get_error_string(int result);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MDGD_LOG_H__ */
diff --git a/src/mdg-manager/include/mdgd_manager.h b/src/mdg-manager/include/mdgd_manager.h
deleted file mode 100644 (file)
index 3f2aaf5..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_MANAGER_H__
-#define __MDGD_MANAGER_H__
-
-#include <mdgd_log.h>
-#include <mdgd_group.h>
-#include <mdgd_resource.h>
-#include <mdgd_gdbus.h>
-#include <mdgd_db.h>
-
-#endif /* __MDGD_MANAGER_H__ */
diff --git a/src/mdg-manager/include/mdgd_mot_agent.h b/src/mdg-manager/include/mdgd_mot_agent.h
deleted file mode 100644 (file)
index 395525e..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_MOT_AGENT_H__
- #define __MDGD_MOT_AGENT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int agent_dbus_start();
-int agent_dbus_stop();
-
-int agent_enable();
-int agent_disable();
-int agent_get_ownerid(char* deviceid);
-int agent_find_mot_enable_devices(int timeout);
-int agent_find_mowned_devices();
-int agent_mot(char* uuid_str, char *pin);
-int agent_resources_pairwise(char* target1, char *subject1, char *uri1,
-       char *rt1, char *interface1, int permission1, char* target2, char *subject2,
-       char *uri2, char *rt2, char *interface2, int permission2);
-int agent_unlink_resources(char* uuid_str1, char *uuid_str2);
-int agent_remove_subowner(char* uuid_str);
-int agent_remove_subowned(char* uuid_str);
-int agent_pair(const char *pin, char* target1, const char *subject1, char *uri1,
-       char *rt1, char *interface1, int permission1, const char* target2,
-       char *subject2, char *uri2, char *rt2, char *interface2, int permission2);
-int agent_unpair(char* uuid_str1, const char *uuid_str2);
-
-#ifdef __cplusplus
-}
-#endif
-
- #endif /* __MDGD_MOT_AGENT_H__ */
diff --git a/src/mdg-manager/include/mdgd_resource.h b/src/mdg-manager/include/mdgd_resource.h
deleted file mode 100644 (file)
index 31658dc..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_RESOURCE_H__
-#define __MDGD_RESOURCE_H__
-
-#include <mdgd_context.h>
-#include <octypes.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef struct {
-       mdgd_resource_type_e resource_type;
-       char *type;
-       char *uri_prefix;
-       unsigned char policies;
-} mdgd_rd_t;
-
-typedef struct {
-       char *uri;
-} mdgd_re_t;
-
-int mdgd_resource_append(mdgd_resource_type_e resource_type, const char *uri);
-char *mdgd_resource_get_type(mdgd_resource_type_e resource_type);
-char *mdgd_resource_get_uri_prefix(mdgd_resource_type_e resource_type);
-unsigned char mdgd_resource_get_policies(mdgd_resource_type_e resource_type);
-void mdgd_resource_print_list();
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* __MDGD_RESOURCE_H__ */
diff --git a/src/mdg-manager/include/mdgd_util.h b/src/mdg-manager/include/mdgd_util.h
deleted file mode 100644 (file)
index 6e1ce35..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MDGD_UTIL_H__
-#define __MDGD_UTIL_H__
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define LOCAL_IP 1 /**< Local IP */
-#define REMOTE_IP 2 /**< Remote IP */
-
-void mdgd_remove_ip_info(void);
-int mdgd_make_ip_info(void);
-int mdgd_is_local_ip(char *ipdata);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MDGD_UTIL_H__ */
diff --git a/src/mdg-manager/oic_svr_db_mdgd_manager.dat b/src/mdg-manager/oic_svr_db_mdgd_manager.dat
deleted file mode 100644 (file)
index bdc3480..0000000
Binary files a/src/mdg-manager/oic_svr_db_mdgd_manager.dat and /dev/null differ
diff --git a/src/mdg-manager/oic_svr_db_mdgd_manager.json b/src/mdg-manager/oic_svr_db_mdgd_manager.json
deleted file mode 100644 (file)
index 943566f..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-{\r
-    "cred":{\r
-        "creds": [\r
-            {\r
-                "credid": 1,\r
-                "subjectuuid": "*",\r
-                "credtype": 16,\r
-                "privatedata": {\r
-                    "encoding": "oic.sec.encoding.raw",\r
-                    "data": "12341234"\r
-                }\r
-            }\r
-        ],\r
-        "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
-    },\r
-    "acl": {\r
-        "aclist": {\r
-            "aces": [\r
-                {\r
-                    "subjectuuid": "*",\r
-                    "resources": [\r
-                        {\r
-                            "href": "/oic/res",\r
-                            "rel": "",\r
-                            "rt": ["oic.wk.res"],\r
-                            "if": ["oic.if.ll"]\r
-                        },{\r
-                            "href": "/oic/d",\r
-                            "rel": "",\r
-                            "rt": ["oic.wk.d"],\r
-                            "if": ["oic.if.baseline", "oic.if.r"]\r
-                        },{\r
-                            "href": "/oic/p",\r
-                            "rel": "",\r
-                            "rt": ["oic.wk.p"],\r
-                            "if": ["oic.if.baseline", "oic.if.r"]\r
-                        }\r
-                    ],\r
-                    "permission": 2\r
-                },\r
-                {\r
-                    "subjectuuid": "*",\r
-                    "resources": [\r
-                        {\r
-                            "href": "/oic/sec/doxm",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.doxm"],\r
-                            "if": ["oic.if.baseline"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/sec/pstat",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.pstat"],\r
-                            "if": ["oic.if.baseline"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/sec/cred",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.cred"],\r
-                            "if": ["oic.if.baseline"]\r
-                        }\r
-                    ],\r
-                    "permission": 6\r
-                },\r
-                {\r
-                    "subjectuuid": "*",\r
-                    "resources": [\r
-                        {\r
-                            "href": "/comp/group",\r
-                            "rel": "",\r
-                            "rt": ["core.comp.group"],\r
-                            "if": ["oic.if.ll"]\r
-                        },{\r
-                            "href": "/comp/device",\r
-                            "rel": "",\r
-                            "rt": ["core.comp.device"],\r
-                            "if": ["oic.if.baseline"]\r
-                        }, {\r
-                            "href": "/comp/operation",\r
-                            "rel": "",\r
-                            "rt": ["core.comp.operation"],\r
-                            "if": ["oic.if.baseline"]\r
-                        }\r
-                    ],\r
-                    "permission": 31\r
-                },\r
-                {\r
-                    "subjectuuid": "*",\r
-                    "resources": [\r
-                        {\r
-                            "href": "/oic/sec/pconf",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.pconf"],\r
-                            "if": ["oic.if.baseline"]\r
-                        },\r
-                        {\r
-                            "href": "/oic/sec/dpairing",\r
-                            "rel": "",\r
-                            "rt": ["oic.r.dpairing"],\r
-                            "if": ["oic.if.baseline"]\r
-                        }\r
-                    ],\r
-                    "permission": 2\r
-                }\r
-            ]\r
-        },\r
-        "rowneruuid" : "00000000-0000-0000-0000-000000000000"\r
-    },\r
-    "pstat": {\r
-        "isop": false,\r
-        "cm": 2,\r
-        "tm": 0,\r
-        "om": 4,\r
-        "sm": 4,\r
-        "deviceuuid": "00000000-0000-0000-0000-000000000000",\r
-        "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
-    },\r
-    "doxm": {\r
-        "oxms": [0, 65280],\r
-        "oxmsel": 65280,\r
-        "sct": 17,\r
-        "owned": false,\r
-        "x.org.iotivity.mom": 1,\r
-        "deviceuuid": "00000000-0000-0000-0000-000000000000",\r
-        "devowneruuid": "00000000-0000-0000-0000-000000000000",\r
-        "rowneruuid": "00000000-0000-0000-0000-000000000000"\r
-    }\r
-}\r
diff --git a/src/mdg-manager/src/mdgd_context.c b/src/mdg-manager/src/mdgd_context.c
deleted file mode 100644 (file)
index 2aa0376..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2018 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 <mdgd_context.h>
-
-static pthread_mutex_t context_lock = PTHREAD_MUTEX_INITIALIZER;
-static mdgd_context_t *mdgd_ctx;
-
-int mdgd_context_create()
-{
-       mdgd_ctx = g_new0(mdgd_context_t, 1);
-       if (!mdgd_ctx) {
-               LOG_DEBUG("create mdgd_context is failed");
-               return MDGD_ERROR_OUT_OF_MEMORY;
-       }
-       mdgd_ctx->mot_me = FALSE;
-       mdgd_ctx->first_search = TRUE;
-
-       return MDGD_ERROR_NONE;
-}
-
-void mdgd_context_mutex_lock()
-{
-       LOG_DEBUG("context mutex lock");
-       pthread_mutex_lock(&context_lock);
-}
-
-void mdgd_context_mutex_unlock()
-{
-       LOG_DEBUG("context mutex unlock");
-       pthread_mutex_unlock(&context_lock);
-}
-
-int mdgd_context_destroy()
-{
-       return MDGD_ERROR_NONE;
-}
-
-mdgd_context_t *mdgd_context_get_context()
-{
-       return mdgd_ctx;
-}
-
diff --git a/src/mdg-manager/src/mdgd_db.c b/src/mdg-manager/src/mdgd_db.c
deleted file mode 100644 (file)
index 33226c0..0000000
+++ /dev/null
@@ -1,511 +0,0 @@
-/*
- * Copyright (c) 2016 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 <mdgd_db.h>
-#include <mdgd_context.h>
-#include <mdgd_group.h>
-
-static bool __is_table_existing(const char *table)
-{
-       bool result;
-       char *sql;
-       int ret;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       sql = sqlite3_mprintf("SELECT count(*) FROM sqlite_master WHERE type='table' AND name ='%s';", table);
-       if (sql != NULL) {
-               sqlite3_stmt *stmt = NULL;
-
-               ret = sqlite3_prepare_v2(mdgd_ctx->db, sql, strlen(sql), &stmt, NULL);
-               if (ret == SQLITE_OK) {
-                       ret = sqlite3_step(stmt);
-                       if (ret == SQLITE_ROW) {
-                               int count;
-
-                               count = sqlite3_column_int(stmt, 0);
-                               if (count > 0)
-                                       result = true;
-                               else
-                                       result = false;
-                       } else {
-                               LOG_ERR("sqlite3_step failed, [%d:%s]", ret, sqlite3_errmsg(mdgd_ctx->db));
-
-                               result = false;
-                       }
-
-                       sqlite3_finalize(stmt);
-               } else {
-                       LOG_ERR("sqlite3_prepare_v2 failed, [%d:%s]", ret, sqlite3_errmsg(mdgd_ctx->db));
-
-                       result = false;
-               }
-
-               sqlite3_free(sql);
-       } else {
-               LOG_ERR("sqlite3_mprintf failed");
-
-               result = false;
-       }
-
-       return result;
-}
-
-static int __create_group_table()
-{
-       int ret = 0;
-       int sql_ret;
-       char *sql = NULL;
-       char *error = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (mdgd_ctx->db == NULL) {
-               LOG_ERR("mdgd_ctx->db is NULL");
-               return -1;
-       }
-
-       sql = sqlite3_mprintf("CREATE TABLE %s(id INTEGER PRIMARY KEY, group_name TEXT);",
-               MDGD_DB_GROUP_TABLE);
-
-       if (sql != NULL) {
-               sql_ret = sqlite3_exec(mdgd_ctx->db, sql, NULL, NULL, &error);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("sqlite3_exec failed, %d, %s", sql_ret, error);
-                       ret = -1;
-                       sqlite3_free(error);
-               }
-               sqlite3_free(sql);
-       } else {
-               LOG_ERR("sql is NULL");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-static int __create_device_table()
-{
-       int ret = 0;
-       int sql_ret;
-       char *sql = NULL;
-       char *error = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (mdgd_ctx->db == NULL) {
-               LOG_ERR("mdgd_ctx->db is NULL");
-               return -1;
-       }
-
-       sql = sqlite3_mprintf("CREATE TABLE %s(id INTEGER PRIMARY KEY, device_id TEXT, group_name TEXT);",
-               MDGD_DB_DEVICE_TABLE);
-
-       if (sql != NULL) {
-               sql_ret = sqlite3_exec(mdgd_ctx->db, sql, NULL, NULL, &error);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("sqlite3_exec failed, %d, %s", sql_ret, error);
-                       ret = -1;
-                       sqlite3_free(error);
-               }
-               sqlite3_free(sql);
-       } else {
-               LOG_ERR("sql is NULL");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-static void __prepare_table()
-{
-       if (__is_table_existing(MDGD_DB_GROUP_TABLE) == false)
-               __create_group_table();
-
-       if (__is_table_existing(MDGD_DB_DEVICE_TABLE) == false)
-               __create_device_table();
-}
-
-static int __check_integrity()
-{
-       sqlite3_stmt *stmt = NULL;
-       int result = 0;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (mdgd_ctx->db == 0) {
-               LOG_ERR("failed to check handle");
-               return -1;
-       }
-
-       int ret = sqlite3_prepare_v2(mdgd_ctx->db, "PRAGMA integrity_check", -1, &stmt, NULL);
-       if (ret != SQLITE_OK && ret != SQLITE_BUSY) {
-               LOG_ERR("failed to check integrity: %s", sqlite3_errmsg(mdgd_ctx->db));
-               return -1;
-       } else {
-               ret = sqlite3_step(stmt);
-               if (ret == SQLITE_ROW) {
-                       const char *ret_val = (const char *)sqlite3_column_text(stmt, 0);
-                       if (ret_val && !strncmp(ret_val, "ok", strlen("ok"))) {
-                               result = 0;
-                       } else {
-                               LOG_ERR("failed to check integrity");
-                               result = -1;
-                       }
-               } else {
-                       result = 0;
-               }
-       }
-
-       sqlite3_finalize(stmt);
-
-       return result;
-}
-
-int mdgd_db_init()
-{
-       int ret = 0;
-       int sql_ret;
-       char *error = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (mdgd_ctx->db == NULL) {
-               sql_ret = sqlite3_open_v2(MDGD_DB_FILE, &(mdgd_ctx->db),
-                       SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("sqlite3_open_v2 failed, (%d)", sql_ret);
-                       goto ERR;
-               }
-
-               if (__check_integrity() < 0) {
-                       LOG_ERR("Failed to check integrity");
-                       unlink(MDGD_DB_FILE);
-                       mdgd_ctx->db = NULL;
-                       sql_ret = sqlite3_open_v2(MDGD_DB_FILE, &mdgd_ctx->db, SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
-                       if (sql_ret != SQLITE_OK) {
-                               LOG_ERR("sqlite3_open_v2 failed, (%d)", sql_ret);
-                               goto ERR;
-                       }
-               }
-
-               /* Enable persist journal mode */
-               sql_ret = sqlite3_exec(mdgd_ctx->db, "PRAGMA journal_mode = PERSIST", NULL, NULL, &error);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("Fail to change journal mode: (%d) %s", sql_ret, error);
-                       sqlite3_free(error);
-
-                       goto ERR;
-               }
-
-               __prepare_table();
-       }
-
-       if (mdgd_ctx->db == NULL) {
-               LOG_ERR("DB is NULL");
-               goto ERR;
-       }
-
-       return ret;
-
-ERR:
-       if (mdgd_ctx->db != NULL) {
-               sql_ret = sqlite3_close(mdgd_ctx->db);
-               if (sql_ret == SQLITE_OK)
-                       mdgd_ctx->db = NULL;
-               else
-                       LOG_ERR("sqlite3_close failed, [%d]", sql_ret);
-       }
-
-       return ret;
-}
-int mdgd_db_deinit()
-{
-       int ret = 0;
-       int sql_ret;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (mdgd_ctx->db != NULL) {
-               sql_ret = sqlite3_close(mdgd_ctx->db);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("sqlite3_close failed, %d", sql_ret);
-                       return -1;
-               }
-               mdgd_ctx->db = NULL;
-       }
-
-       return ret;
-}
-
-int mdgd_db_group_insert(const char *group_name)
-{
-       int ret = 0;
-       int sql_ret;
-       char *sql = NULL;
-       char *error = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (mdgd_ctx->db == NULL) {
-               LOG_ERR("mtp_ctx->db is NULL");
-               return -1;
-       }
-
-       sql = sqlite3_mprintf("INSERT INTO %s (group_name) values(%Q);",
-               MDGD_DB_GROUP_TABLE,
-               group_name);
-
-       if (sql != NULL) {
-               sql_ret = sqlite3_exec(mdgd_ctx->db, sql, NULL, NULL, &error);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("sqlite3_exec failed, %d, %s", sql_ret, error);
-                       ret = -1;
-                       sqlite3_free(error);
-               }
-               sqlite3_free(sql);
-       } else {
-               LOG_ERR("sql is NULL");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-int mdgd_db_device_insert(const char *device_id, const char *group_name)
-{
-       int ret = 0;
-       int sql_ret;
-       char *sql = NULL;
-       char *error = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (mdgd_ctx->db == NULL) {
-               LOG_ERR("mtp_ctx->db is NULL");
-               return -1;
-       }
-
-       sql = sqlite3_mprintf("INSERT INTO %s (device_id, group_name) values(%Q, %Q);",
-               MDGD_DB_DEVICE_TABLE,
-               device_id,
-               group_name);
-
-       if (sql != NULL) {
-               sql_ret = sqlite3_exec(mdgd_ctx->db, sql, NULL, NULL, &error);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("sqlite3_exec failed, %d, %s", sql_ret, error);
-                       ret = -1;
-                       sqlite3_free(error);
-               }
-               sqlite3_free(sql);
-       } else {
-               LOG_ERR("sql is NULL");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-int mdgd_db_group_delete(char *group_name)
-{
-       int ret = 0;
-       int sql_ret;
-       char *sql = NULL;
-       char *error = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (mdgd_ctx->db == NULL) {
-               LOG_ERR("mdgd_ctx->db is NULL");
-               return -1;
-       }
-
-       if (group_name == NULL) {
-               LOG_ERR("group_name is NULL");
-               return -1;
-       }
-
-       sql = sqlite3_mprintf("DELETE FROM %s WHERE group_name=%Q",
-               MDGD_DB_GROUP_TABLE,
-               group_name);
-
-       if (sql != NULL) {
-               sql_ret = sqlite3_exec(mdgd_ctx->db, sql, NULL, NULL, &error);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("sqlite3_exec failed, %d, %s", sql_ret, error);
-                       ret = -1;
-                       sqlite3_free(error);
-               }
-               sqlite3_free(sql);
-       } else {
-               LOG_ERR("sql is NULL");
-               ret = -1;
-       }
-
-       return ret;
-}
-
-int mdgd_db_device_delete(char *device_id, char *group_name)
-{
-       int ret = 0;
-       int sql_ret;
-       char *sql = NULL;
-       char *error = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (mdgd_ctx->db == NULL) {
-               LOG_ERR("mdgd_ctx->db is NULL");
-               return -1;
-       }
-
-       if (group_name == NULL) {
-               LOG_ERR("group_name is NULL");
-               return -1;
-       }
-
-       if (device_id == NULL) {
-               LOG_ERR("device_id is NULL");
-               return -1;
-       }
-
-       sql = sqlite3_mprintf("DELETE FROM %s WHERE group_name=%Q and device_id=%Q",
-               MDGD_DB_DEVICE_TABLE,
-               group_name,
-               device_id);
-
-       if (sql != NULL) {
-               sql_ret = sqlite3_exec(mdgd_ctx->db, sql, NULL, NULL, &error);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("sqlite3_exec failed, %d, %s", sql_ret, error);
-                       ret = -1;
-                       sqlite3_free(error);
-               }
-               sqlite3_free(sql);
-       } else {
-               LOG_ERR("sql is NULL");
-               ret = -1;
-       }
-
-       return ret;
-
-}
-
-bool mdgd_check_device_exist(char *device_id)
-{
-       int ret = 0;
-       bool result = false;
-       int sql_ret;
-       char *sql = NULL;
-       char *error = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE device_id=%Q;",
-               MDGD_DB_DEVICE_TABLE, device_id);
-       if (sql != NULL) {
-               sqlite3_stmt *stmt = NULL;
-
-               ret = sqlite3_prepare_v2(mdgd_ctx->db, sql, strlen(sql), &stmt, NULL);
-               if (ret == SQLITE_OK) {
-                       ret = sqlite3_step(stmt);
-                       if (ret == SQLITE_ROW) {
-                               int count;
-
-                               count = sqlite3_column_int(stmt, 0);
-                               if (count > 0)
-                                       result = true;
-                               else
-                                       result = false;
-                       } else {
-                               LOG_ERR("sqlite3_step failed, [%d:%s]", ret, sqlite3_errmsg(mdgd_ctx->db));
-
-                               result = false;
-                       }
-
-                       sqlite3_finalize(stmt);
-               } else {
-                       LOG_ERR("sqlite3_prepare_v2 failed, [%d:%s]", ret, sqlite3_errmsg(mdgd_ctx->db));
-
-                       result = false;
-               }
-
-               sqlite3_free(sql);
-       } else {
-               LOG_ERR("sqlite3_mprintf failed");
-
-               result = false;
-       }
-
-       return result;
-}
-
-bool mdgd_check_group_exist(const char *group_name)
-{
-       int ret = 0;
-       bool result = false;
-       int sql_ret;
-       char *sql = NULL;
-       char *error = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       sql = sqlite3_mprintf("SELECT count(*) FROM %s WHERE group_name=%Q;",
-               MDGD_DB_DEVICE_TABLE, group_name);
-       if (sql != NULL) {
-               sqlite3_stmt *stmt = NULL;
-
-               ret = sqlite3_prepare_v2(mdgd_ctx->db, sql, strlen(sql), &stmt, NULL);
-               if (ret == SQLITE_OK) {
-                       ret = sqlite3_step(stmt);
-                       if (ret == SQLITE_ROW) {
-                               int count;
-
-                               count = sqlite3_column_int(stmt, 0);
-                               if (count > 0)
-                                       result = true;
-                               else
-                                       result = false;
-                       } else {
-                               LOG_ERR("sqlite3_step failed, [%d:%s]", ret, sqlite3_errmsg(mdgd_ctx->db));
-
-                               result = false;
-                       }
-
-                       sqlite3_finalize(stmt);
-               } else {
-                       LOG_ERR("sqlite3_prepare_v2 failed, [%d:%s]", ret, sqlite3_errmsg(mdgd_ctx->db));
-
-                       result = false;
-               }
-
-               sqlite3_free(sql);
-       } else {
-               LOG_ERR("sqlite3_mprintf failed");
-
-               result = false;
-       }
-
-       return result;
-}
-
-int mdgd_db_print()
-{
-       return 0;
-}
-
diff --git a/src/mdg-manager/src/mdgd_gdbus.c b/src/mdg-manager/src/mdgd_gdbus.c
deleted file mode 100644 (file)
index bedf36f..0000000
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright (c) 2018 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 <mdgd_gdbus.h>
-#include <sys/types.h>
-
-#define DBUS_SERVICE_DBUS              "org.freedesktop.DBus"
-#define DBUS_INTERFACE_DBUS            "org.freedesktop.DBus"
-
-static Group *group_skeleton;
-static Enabler *enabler_skeleton;
-
-Group *group_dbus_get_object()
-{
-       return group_skeleton;
-}
-
-static bool __group_init(GDBusConnection *connection)
-{
-       gboolean ret = FALSE;
-       GError *error = NULL;
-
-       GDBusObjectManagerServer *group;
-
-       // Add interface to default object path
-       group_skeleton = group_skeleton_new();
-
-       // Register for method callbacks as signal callbacks
-       g_signal_connect(group_skeleton,
-               "handle-create",
-               G_CALLBACK(group_create),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-find",
-               G_CALLBACK(group_find),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-get-found-groups",
-               G_CALLBACK(group_get_found_groups),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-join",
-               G_CALLBACK(group_join),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-leave",
-               G_CALLBACK(group_leave),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-delete",
-               G_CALLBACK(group_delete),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-device-find",
-               G_CALLBACK(group_device_find),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-invite",
-               G_CALLBACK(group_invite),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-eject",
-               G_CALLBACK(group_eject),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-device-invite",
-               G_CALLBACK(group_device_invite),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-device-eject",
-               G_CALLBACK(group_device_eject),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-get-remote-device",
-               G_CALLBACK(group_get_remote_device),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-pair-resource",
-               G_CALLBACK(group_pair_resource),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-unpair-resource",
-               G_CALLBACK(group_unpair_resource),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-send-data",
-               G_CALLBACK(group_send_data),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-find-mowned-devices",
-               G_CALLBACK(group_find_mowned_devices),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-get-mowned-device",
-               G_CALLBACK(group_get_mowned_device),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-get-my-mowned-device",
-               G_CALLBACK(group_get_my_mowned_device),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-get-my-uuid",
-               G_CALLBACK(group_get_my_uuid),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-request-create-group",
-               G_CALLBACK(group_request_create_group),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-request-invite",
-               G_CALLBACK(group_request_invite),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-request-eject",
-               G_CALLBACK(group_request_eject),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-request-delete-group",
-               G_CALLBACK(group_request_delete_group),
-               NULL);
-
-       g_signal_connect(group_skeleton,
-               "handle-start-invited-device-monitor",
-               G_CALLBACK(group_start_invited_device_monitor),
-               NULL);
-
-       group = g_dbus_object_manager_server_new(MDGD_DBUS_GROUP_PATH);
-
-       // Set connection to 'manager'
-       g_dbus_object_manager_server_set_connection(group, connection);
-
-       // Export 'group' interface on mdg-manager DBUS
-       ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(group_skeleton),
-                               connection, MDGD_DBUS_GROUP_PATH, &error);
-
-       if (ret == FALSE) {
-               LOG_DEBUG("Can not skeleton_export %s", error->message);
-               g_error_free(error);
-       }
-
-       return ret;
-}
-
-static void _app_conn_destroyed_cb(GDBusConnection *conn, const gchar *Name,
-                          const gchar *path, const gchar *interface, const gchar *sig,
-                          GVariant *param, gpointer user_data)
-{
-       gchar *name = NULL;
-       gchar *old = NULL;
-       gchar *new = NULL;
-       mdgd_conn_destroy_data *data = user_data;
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       if (param == NULL)
-               return;
-
-       g_variant_get(param, "(sss)", &name, &old, &new);
-
-       if (g_strcmp0(name, data->conn_name) == 0 && *new == '\0') {
-               LOG_DEBUG("App %s Destroyed: name %s id %d", data->conn_name, name,
-                       data->conn_id);
-
-               mdgd_ctx->ref_count -= 1;
-
-               g_dbus_connection_signal_unsubscribe(data->connection, data->conn_id);
-       }
-
-       g_free(name);
-       g_free(old);
-       g_free(new);
-       g_free(data->conn_name);
-       g_free(data);
-
-       if (mdgd_ctx->ref_count == 0) {
-               LOG_DEBUG("No app remaining quit mdgd");
-               g_main_loop_quit(mdgd_ctx->main_loop);
-       }
-
-       return;
-}
-
-static gboolean _register_mdgd_conn_destroy_signal(Enabler *enabler,
-                                                                  gchar *name)
-{
-       mdgd_conn_destroy_data *data;
-       GDBusConnection *connection = NULL;
-
-       connection = g_dbus_interface_skeleton_get_connection(
-                                         (GDBusInterfaceSkeleton *)enabler_skeleton);
-       if (NULL == connection) {
-               LOG_ERR("Failed to get GDbus connection");
-               return FALSE;
-       }
-
-       data = g_try_malloc0(sizeof(mdgd_conn_destroy_data));
-       if (NULL == data) {
-               LOG_ERR("Failed to Allocate memory");
-               return FALSE;
-       }
-
-       data->conn_name = g_strdup(name);
-       data->connection = connection;
-
-       data->conn_id = g_dbus_connection_signal_subscribe(connection,
-                                                       DBUS_SERVICE_DBUS, DBUS_INTERFACE_DBUS,
-                                                       "NameOwnerChanged", NULL, name,
-                                                       G_DBUS_SIGNAL_FLAGS_NONE, _app_conn_destroyed_cb,
-                                                       data, NULL);
-
-       return TRUE;
-}
-
-gboolean enabler_add_ref(Enabler *enabler, GDBusMethodInvocation *invocation,
-       gchar *name, gpointer user_data)
-{
-       LOG_DEBUG("Add Reference for %s", name);
-
-       if (TRUE == _register_mdgd_conn_destroy_signal(enabler, name)) {
-               mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-               mdgd_ctx->ref_count += 1;
-
-               enabler_complete_add_ref(enabler, invocation, 0);
-       } else {
-               LOG_ERR("Failed to register connection destroy signal");
-               enabler_complete_add_ref(enabler, invocation,
-                                        MDGD_ERROR_OPERATION_FAILED);
-       }
-
-       return TRUE;
-}
-
-static bool __enabler_init(GDBusConnection *connection)
-{
-       gboolean ret = FALSE;
-       GError *error = NULL;
-
-       GDBusObjectManagerServer *enabler;
-
-       // Add interface to default object path
-       enabler_skeleton = enabler_skeleton_new();
-
-       // Register for method callbacks as signal callbacks
-       g_signal_connect(enabler_skeleton,
-               "handle-add-ref",
-               G_CALLBACK(enabler_add_ref),
-               NULL);
-
-       enabler = g_dbus_object_manager_server_new(MDGD_DBUS_ENABLER_PATH);
-
-       // Set connection to 'enabler'
-       g_dbus_object_manager_server_set_connection(enabler, connection);
-
-       // Export 'enabler' interface on mdg DBUS
-       ret = g_dbus_interface_skeleton_export(
-                               G_DBUS_INTERFACE_SKELETON(enabler_skeleton), connection,
-                               MDGD_DBUS_ENABLER_PATH, &error);
-
-       if (ret == FALSE) {
-               LOG_DEBUG("Can not skeleton_export %s", error->message);
-               g_error_free(error);
-       }
-
-       return ret;
-}
-
-
-static void on_bus_acquired(GDBusConnection *connection, const gchar *path,
-       gpointer user_data)
-{
-       if (__group_init(connection) == false)
-               LOG_DEBUG("Can not signal connect");
-
-       if (__enabler_init(connection) == false)
-               LOG_ERR("Can't signal connect");
-}
-
-static void on_name_acquired(GDBusConnection *connection, const gchar *name,
-       gpointer user_data)
-{
-       LOG_DEBUG("on_name_acquired : %s", name);
-}
-
-static void on_name_lost(GDBusConnection *connnection, const gchar *name,
-       gpointer user_data)
-{
-       LOG_DEBUG("on_name_lost : %s", name);
-}
-
-int mdgd_gdbus_init()
-{
-       g_bus_own_name(G_BUS_TYPE_SYSTEM, MDGD_DBUS_SERVICE, G_BUS_NAME_OWNER_FLAGS_NONE,
-               on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
-
-       return 0;
-}
diff --git a/src/mdg-manager/src/mdgd_gdbus_group.c b/src/mdg-manager/src/mdgd_gdbus_group.c
deleted file mode 100644 (file)
index 9cc3bc0..0000000
+++ /dev/null
@@ -1,479 +0,0 @@
-/*
- * Copyright (c) 2018 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 <mdgd_db.h>
-#include <mdgd_gdbus_group.h>
-
-/* GDBUS Group Layer */
-/* In this gdbus group layer, Please call the "fn_group" service layer function.*/
-
-gboolean group_create(Group *group, GDBusMethodInvocation *invocation,
-       gchar *group_name, gpointer user_data)
-{
-       gint result = MDGD_ERROR_NONE;
-
-       LOG_DEBUG("group create called using dbus successful");
-
-       if (mdgd_check_group_exist(group_name))
-               LOG_DEBUG("Group already created");
-       else {
-               result = mdgd_group_create(group_name);
-               if (MDGD_ERROR_NONE == result)
-                       mdgd_db_group_insert(group_name);
-       }
-
-       group_complete_create(group, invocation, result);
-
-       return TRUE;
-}
-
-gboolean group_find(Group *group, GDBusMethodInvocation *invocation, gint timeout,
-       gpointer user_data)
-{
-       gint result = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("group find called using dbus successful");
-
-       result = mdgd_group_find(timeout);
-
-       group_complete_find(group, invocation, result);
-       return TRUE;
-}
-
-gboolean group_get_found_groups(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data)
-{
-       gint result = MDGD_ERROR_UNKNOWN;
-       GVariant *group_data;
-
-       LOG_DEBUG("get found groups called using dbus successful");
-
-       group_data = mdgd_group_get_found_groups();
-
-       group_complete_get_found_groups(group, invocation, result, group_data);
-       return TRUE;
-}
-
-gboolean group_join(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data)
-{
-       gint result = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("join called using dbus successful");
-
-       result = mdgd_group_join();
-
-       group_complete_join(group, invocation, result);
-
-       return TRUE;
-}
-
-gboolean group_leave(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data)
-{
-       //group_complete_leave(group, invocation, result);
-
-       return TRUE;
-}
-
-gboolean group_delete(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data)
-{
-       //group_complete_delete(group, invocation, result);
-
-       return TRUE;
-}
-
-gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation,
-       gint timeout, gpointer user_data)
-{
-       int result = MDGD_ERROR_UNKNOWN;
-
-       result = mdgd_group_find_mot_enabled_devices(timeout);
-
-       group_complete_device_find(group, invocation, result);
-
-       return TRUE;
-}
-
-gboolean group_device_invite(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid_dev1, gchar *uuid_dev2, gchar *pin, gchar *uri_1, gchar *rt_1,
-       gchar *interface_1, int permission_1, gchar *uri_2, gchar *rt_2,
-       gchar *interface_2, int permission_2, gpointer user_data)
-{
-       gint result = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("group device invite called using dbus successful");
-/*
-       result = mdgd_group_invite(uuid_dev1, uuid_dev2, pin, uri_1, rt_1,
-                                       interface_1, permission_1, uri_2, rt_2, interface_2,
-                                       permission_2);
-*/
-       group_complete_device_invite(group, invocation, result);
-
-       return TRUE;
-}
-
-gboolean group_device_eject(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid_dev1, gchar *uuid_dev2, gpointer user_data)
-{
-       gint result = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("group device eject called using dbus successful");
-
-       result = mdgd_group_eject(NULL, uuid_dev1, uuid_dev2);
-
-       group_complete_device_eject(group, invocation, result);
-
-       return TRUE;
-}
-
-gboolean group_invite(Group *group, GDBusMethodInvocation *invocation, gchar *group_name,
-       gchar *uuid, gchar *pin, gpointer user_data)
-{
-       gint result = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("group invite called using dbus successful");
-
-       if (mdgd_check_device_exist(uuid)) {
-               result = MDGD_ERROR_ALREADY_REGISTERED;
-       } else {
-               result = mdgd_group_invite(group_name, uuid, pin);
-               if (MDGD_ERROR_NONE == result)
-                       mdgd_db_device_insert(uuid, group_name);
-       }
-
-       /* Now, for the sake of convenience, we change 'group_complete_invite' to 'group_complete_device_invite'. */
-#if 0
-       group_complete_invite(group, invocation, result);
-#else
-       group_complete_device_invite(group, invocation, result);
-#endif
-
-       return TRUE;
-}
-
-gboolean group_eject(Group *group, GDBusMethodInvocation *invocation, gchar *group_name,
-       gchar *uuid, gpointer user_data)
-{
-       gint result = MDGD_ERROR_UNKNOWN;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, FALSE);
-
-       if (!mdgd_check_device_exist(uuid)) {
-               result = MDGD_ERROR_ALREADY_REGISTERED;
-       } else {
-               result = mdgd_group_eject(group_name, mdgd_ctx->device_uuid, uuid);
-       }
-
-       /* Now, for the sake of convenience, we change 'group_complete_eject' to 'group_complete_device_eject'. */
-#if 0
-       group_complete_invite(group, invocation, result);
-#else
-       group_complete_device_eject(group, invocation, result);
-#endif
-
-       return TRUE;
-}
-
-gboolean group_get_remote_device(Group *group, GDBusMethodInvocation *invocation,
-       gpointer user_data)
-{
-       int dev_count = 0;
-       GVariant *device_data;
-
-       LOG_DEBUG("get remote device called using dbus successful");
-
-       dev_count = mdgd_group_get_mot_device_count();
-       device_data = mdgd_group_get_remote_mot_enabled_devices();
-
-       group_complete_get_remote_device(group, invocation, dev_count, device_data);
-
-       return TRUE;
-}
-
-gboolean group_pair_resource(Group *group, GDBusMethodInvocation *invocation,
-       gchar *target_1, gchar *subject_1, gchar *uri_1, gchar *rt_1,
-       gchar *interface_1, int permission_1, gchar *target_2, gchar *subject_2,
-       gchar *uri_2, gchar *rt_2, gchar *interface_2, int permission_2,
-       gpointer user_data)
-{
-       int ret = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("pair resource called using dbus successful");
-
-       ret = mdgd_group_pair_resource(target_1, subject_1, uri_1, rt_1,
-                                          interface_1, permission_1, target_2, subject_2, uri_2,
-                                          rt_2, interface_2, permission_2);
-
-       group_complete_pair_resource(group, invocation, ret);
-
-       return TRUE;
-}
-
-gboolean group_unpair_resource(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid_dev1, gchar *uuid_dev2, gpointer user_data)
-{
-       int ret = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("unpair resource called using dbus successful");
-
-       ret = mdgd_group_unpair_resource(uuid_dev1, uuid_dev2);
-
-       group_complete_unpair_resource(group, invocation, ret);
-
-       return TRUE;
-}
-
-gboolean group_send_data(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid_dev, gchar *addr, int port, GVariant *params,
-       gpointer user_data)
-{
-       int ret = MDGD_ERROR_UNKNOWN;
-       int length = 0;
-       int len;
-       unsigned char *data;
-       GVariantIter *iter;
-
-       LOG_DEBUG("send data called using dbus successful");
-
-       g_variant_get(params, "(iay)", &len, &iter);
-
-       data = g_try_malloc0(len + 1);
-       if (NULL == data) {
-               group_complete_send_data(group, invocation, -1);
-               LOG_ERR("Failed to allocate memory");
-               return TRUE;
-       }
-
-       while (g_variant_iter_loop(iter, "y", &data[length]))
-               length += 1;
-
-       g_variant_iter_free(iter);
-
-       ret = mdgd_group_send_data(uuid_dev, addr, port, data, len);
-
-       group_complete_send_data(group, invocation, 0);
-
-       g_free(data);
-
-       return ret;
-}
-
-gboolean group_find_mowned_devices(Group *group,
-       GDBusMethodInvocation *invocation, gint timeout, gpointer user_data)
-{
-       int ret = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("find mot owned devices called using dbus successful");
-
-       ret = mdgd_group_find_mowned_devices(timeout);
-
-       group_complete_find_mowned_devices(group, invocation, ret);
-
-       return TRUE;
-}
-
-gboolean group_get_mowned_device(Group *group,
-       GDBusMethodInvocation *invocation, gpointer user_data)
-{
-       int dev_count = 0;
-       GVariant *device_data;
-
-       LOG_DEBUG("get mowned device called using dbus successful");
-
-       dev_count = mdgd_group_get_mowned_device_count();
-       device_data = mdgd_group_get_mowned_devices();
-
-       group_complete_get_mowned_device(group, invocation, dev_count, device_data);
-
-       return TRUE;
-}
-
-gboolean group_get_my_mowned_device(Group *group,
-       GDBusMethodInvocation *invocation, gpointer user_data)
-{
-       GVariant *device_data;
-
-       LOG_DEBUG("get mowned device called using dbus successful");
-
-       device_data = mdgd_group_get_my_mowned_devices();
-       LOG_DEBUG("get mowned device called end ");
-
-       group_complete_get_my_mowned_device(group, invocation, device_data);
-
-       return TRUE;
-}
-
-gboolean group_get_my_uuid(Group *group,
-       GDBusMethodInvocation *invocation, gpointer user_data)
-{
-       LOG_DEBUG("get my uuid called using dbus successful");
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       group_complete_get_my_uuid(group, invocation, mdgd_ctx->device_uuid);
-
-       return TRUE;
-}
-
-gboolean group_request_create_group(Group *group, GDBusMethodInvocation
-       *invocation, gchar *uuid, gchar *group_name, gpointer user_data)
-{
-       int ret = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("Request Create Group called using dbus successful");
-
-       ret = mdgd_group_request_create_group(uuid, group_name);
-
-       group_complete_request_create_group(group, invocation, ret);
-
-       return TRUE;
-}
-
-gboolean group_request_invite(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid, gchar *group_name, gchar *target_uuid, gchar *PIN, gpointer user_data)
-{
-       int ret = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("Request Invite called using dbus successful");
-
-       ret = mdgd_group_request_invite(uuid, group_name, target_uuid, PIN);
-
-       group_complete_request_invite(group, invocation, ret);
-
-       return TRUE;
-}
-
-gboolean group_request_eject(Group *group, GDBusMethodInvocation *invocation,
-       gchar *uuid, gchar *group_name, gchar *target_uuid, gpointer user_data)
-{
-       int ret = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("Request Eject called using dbus successful");
-
-       ret = mdgd_group_request_eject(uuid, group_name, target_uuid);
-
-       group_complete_request_eject(group, invocation, ret);
-
-       return TRUE;
-}
-
-gboolean group_request_delete_group(Group *group,
-       GDBusMethodInvocation *invocation, gchar *uuid, gchar *group_name, gpointer user_data)
-{
-       int ret = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("Request Delete Group called using dbus successful");
-
-       ret = mdgd_group_request_delete_group(uuid, group_name);
-
-       group_complete_request_delete_group(group, invocation, ret);
-
-       return TRUE;
-}
-
-gboolean group_start_invited_device_monitor(Group *group,
-                                       GDBusMethodInvocation *invocation, int start,
-                                       gpointer user_data)
-{
-       int ret = MDGD_ERROR_UNKNOWN;
-
-       LOG_DEBUG("Start Myowned device monitor");
-
-       ret = mdgd_group_start_invited_device_monitor(start);
-
-       group_complete_start_invited_device_monitor(group, invocation, ret);
-
-       return TRUE;
-}
-
-void notify_group_found(GVariant *group_data)
-{
-       group_emit_group_found(group_dbus_get_object(), group_data);
-}
-
-void notify_group_find_finish(int ret)
-{
-       group_emit_group_find_finish(group_dbus_get_object(), ret);
-}
-
-void notify_device_found(int device_count, GVariant *device_data)
-{
-       group_emit_device_found(group_dbus_get_object(), device_count, device_data);
-}
-
-void notify_device_find_finish(int ret)
-{
-       group_emit_device_find_finish(group_dbus_get_object(), ret);
-}
-
-void notify_group_device_invite_result(int ret)
-{
-       group_emit_device_invite_result(group_dbus_get_object(), ret);
-}
-
-void notify_group_device_eject_result(int ret)
-{
-       group_emit_device_eject_result(group_dbus_get_object(), ret);
-}
-
-void notify_mowned_device_found(int device_count, GVariant *device_data)
-{
-       group_emit_mowned_device_found(group_dbus_get_object(), device_count, device_data);
-}
-
-void notify_mowned_device_find_finish(int ret)
-{
-       group_emit_mowned_device_find_finish(group_dbus_get_object(), ret);
-}
-void notify_group_join(int result)
-{
-       group_emit_join_result(group_dbus_get_object(), result);
-}
-
-void notify_send_data_finish(const char *resp_data, int ret)
-{
-       group_emit_send_data_finish(group_dbus_get_object(), resp_data, ret);
-}
-
-void notify_request_result(const char *cmd, const char *requester_id,
-                                                  unsigned char *arg, int len, int ret)
-{
-       GVariantBuilder *bytearray_builder = NULL;
-       GVariant *params = NULL;
-       int i;
-
-       bytearray_builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
-
-       for (i = 0; i < len; i++)
-               g_variant_builder_add(bytearray_builder, "y", arg[i]);
-
-       params = g_variant_new("(iay)", len, bytearray_builder);
-       g_variant_builder_unref(bytearray_builder);
-
-       group_emit_request_result(group_dbus_get_object(), cmd, requester_id,
-                                                         params, ret);
-}
-
-void notify_device_monitor_result(const char *uuid, const char *group_name,
-                                                                 const char *status)
-{
-       group_emit_device_monitor_result(group_dbus_get_object(), uuid, group_name,
-                                                                         status);
-}
-
diff --git a/src/mdg-manager/src/mdgd_group.c b/src/mdg-manager/src/mdgd_group.c
deleted file mode 100644 (file)
index 4a500fc..0000000
+++ /dev/null
@@ -1,1385 +0,0 @@
-/*
- * Copyright (c) 2018 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 <mdgd_enum.h>
-#include <mdgd_group.h>
-#include <mdgd_mot_agent.h>
-#include <mdgd_gdbus_group.h>
-#include <mdgd_db.h>
-#include <mdgd_util.h>
-
-GList *found_group_list;
-GList *mot_enb_dev_list = NULL;
-GList *mowned_dev_list = NULL;
-GList *invited_dev_list = NULL;
-mdgd_group_invite_info_t *group_invite_info = NULL;
-mdgd_mot_device_t *my_device = NULL;
-
-#define KEEPALIVE_MESSAGE_TIMEOUT 900
-#define CHECK_DEVICE_STATUS_TIMEOUT 3000
-
-/* Called when daemon is start. */
-int mdgd_group_initialize()
-{
-       int sql_ret = SQLITE_OK;
-       char *sql = NULL;
-       sqlite3_stmt *stmt = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       //1. group creation
-       sql = sqlite3_mprintf("SELECT group_name FROM %s;", MDGD_DB_GROUP_TABLE);
-       if (sql != NULL) {
-               sql_ret = sqlite3_prepare_v2(mdgd_ctx->db, sql, strlen(sql), &stmt, NULL);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("Error: %s", sqlite3_errmsg(mdgd_ctx->db));
-                       sqlite3_free(sql);
-                       return MDGD_ERROR_UNKNOWN;
-               }
-
-               do {
-                       sql_ret = sqlite3_step(stmt);
-                       if (sql_ret != SQLITE_ROW) {
-                               break;
-                       }
-
-                       char *group_name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
-
-                       mdgd_group_create(group_name);
-               } while (sql_ret != SQLITE_DONE);
-
-               sqlite3_finalize(stmt);
-               sqlite3_free(sql);
-       }
-
-       //2. device creation
-       mdgd_group_find_mot_enabled_devices(2);
-
-       return MDGD_ERROR_NONE;
-}
-
-void __print_foreach_device(gpointer data, gpointer user_data)
-{
-       char *uuid = (char *)data;
-       LOG_DEBUG("        - %s", uuid);
-}
-
-void __print_foreach_grp(gpointer data, gpointer user_data)
-{
-       mdgd_grp_t *grp = (mdgd_grp_t *)data;
-       LOG_DEBUG("Group name : %s", grp->name);
-       LOG_DEBUG("    <Device>");
-       g_list_foreach(grp->device_list, __print_foreach_device, NULL);
-       LOG_DEBUG("");
-}
-
-void __print_groups_information()
-{
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret("mdgd_ctx", mdgd_ctx);
-
-       LOG_DEBUG("-------------------------------------------");
-       g_list_foreach(mdgd_ctx->grp_list, __print_foreach_grp, NULL);
-       LOG_DEBUG("-------------------------------------------");
-}
-
-/* create group and destroy */
-int mdgd_group_create(const char* name)
-{
-       int ret;
-
-       LOG_BEGIN();
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, MDGD_ERROR_INVALID_PARAMETER);
-       GList *list = mdgd_ctx->grp_list;
-
-       GList *l;
-       for (l = list; l != NULL; l = l->next) {
-               mdgd_grp_t *grp = (mdgd_grp_t *)l->data;
-
-               if (!strncmp(grp->name, name, strlen(grp->name))) {
-                       LOG_ERR("already exists name in structure");
-                       return MDGD_ERROR_UNKNOWN;
-               }
-       }
-
-       ret = mdgd_iot_add_resource(MDGD_RESOURCE_TYPE_GROUP, name);
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("Add resource is failed : %s", mdgd_log_get_error_string(ret));
-       }
-
-       mdgd_grp_t *grp = g_new0(mdgd_grp_t, 1);
-       grp->name = strdup(name);
-
-       mdgd_ctx->grp_list = g_list_append(mdgd_ctx->grp_list, grp);
-
-       mdgd_resource_print_list();
-       __print_groups_information();
-
-       LOG_END();
-
-       return MDGD_ERROR_NONE;
-}
-
-int mdgd_group_destroy(mdgd_group_t *handle)
-{
-       int ret = MDGD_ERROR_NONE;
-       NOTUSED(handle);
-       return ret;
-}
-
-static void _free_device_func(gpointer data)
-{
-       mdgd_check_null_ret("data", data);
-       g_free(data);
-       data = NULL;
-}
-
-static void _free_group_func(gpointer data)
-{
-       mdgd_group_t *group = (mdgd_group_t *)data;
-       mdgd_check_null_ret("group", group);
-
-       if (group->uri_path != NULL) {
-               g_free(group->uri_path);
-               group->uri_path = NULL;
-       }
-       if (group->device_id != NULL) {
-               g_free(group->device_id);
-               group->device_id = NULL;
-       }
-       if (group->group_name != NULL) {
-               g_free(group->group_name);
-               group->group_name = NULL;
-       }
-       if (group->host_addr != NULL) {
-               g_free(group->host_addr);
-               group->host_addr = NULL;
-       }
-       if (group->resource_type != NULL) {
-               g_free(group->resource_type);
-               group->resource_type = NULL;
-       }
-       g_free(group);
-       group = NULL;
-}
-
-static void _mot_enb_dev_list_free_func(gpointer data)
-{
-       mdgd_mot_device_t *device = (mdgd_mot_device_t *)data;
-       mdgd_check_null_ret("device", device);
-
-       if (device->device_id != NULL) {
-               g_free(device->device_id);
-               device->device_id = NULL;
-       }
-       if (device->addr != NULL) {
-               g_free(device->addr);
-               device->addr = NULL;
-       }
-       if (device->route_data != NULL) {
-               g_free(device->route_data);
-               device->route_data = NULL;
-       }
-       if (device->remote_id != NULL) {
-               g_free(device->remote_id);
-               device->remote_id = NULL;
-       }
-       if (device->sec_ver != NULL) {
-               g_free(device->sec_ver);
-               device->sec_ver = NULL;
-       }
-       g_free(device);
-       device = NULL;
-}
-
-int mdgd_group_find(int timeout)
-{
-       int ret;
-
-       LOG_BEGIN();
-
-       /* list freeing */
-       g_list_free_full(found_group_list, _free_group_func);
-       found_group_list = NULL;
-
-       mdgd_command_t *cmd = g_new0(mdgd_command_t, 1);
-       mdgd_check_null_ret_error("cmd", cmd, MDGD_ERROR_INVALID_PARAMETER);
-       ret = mdgd_iot_discovery_resource(MDGD_RESOURCE_TYPE_GROUP, timeout, cmd);
-       if (ret != MDGD_ERROR_NONE)
-               LOG_ERR("Failed to discover resource : %s", mdgd_log_get_error_string(ret));
-
-       LOG_END();
-
-       return ret;
-}
-
-GVariant *mdgd_group_get_found_groups()
-{
-       GVariantBuilder *builder;
-       GVariant *group_data;
-       GList *iter = NULL;
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
-
-       iter = found_group_list;
-       while (iter != NULL) {
-               mdgd_group_t *group = (mdgd_group_t *)iter->data;
-
-               g_variant_builder_open(builder, G_VARIANT_TYPE_VARDICT);
-               g_variant_builder_add(builder, "{sv}", "URI",
-                                                         g_variant_new_string(group->uri_path));
-               g_variant_builder_add(builder, "{sv}", "DeviceID",
-                                                         g_variant_new_string(group->device_id));
-               g_variant_builder_add(builder, "{sv}", "GroupName",
-                                                         g_variant_new_string(group->group_name));
-               g_variant_builder_add(builder, "{sv}", "HostAddress",
-                                                         g_variant_new_string(group->host_addr));
-               g_variant_builder_add(builder, "{sv}", "GroupDeviceType",
-                                                         g_variant_new_string(group->resource_type));
-               /*When we get found groups, we can get my groups also. */
-               g_variant_builder_add(builder, "{sv}", "GroupType",
-                                                         g_variant_new_int32(group->type));
-               g_variant_builder_close(builder);
-
-               iter = g_list_next(iter);
-       }
-
-       group_data = g_variant_builder_end(builder);
-       g_variant_builder_unref(builder);
-
-       return group_data;
-}
-
-int mdgd_group_add_new(char *uri_path, char *device_id, char *device_name,
-                                        char *host_addr, char *resource_type, mdgd_group_type_e type)
-{
-       mdgd_group_t *group;
-       GVariantBuilder *builder;
-       GVariant *group_data;
-
-       LOG_BEGIN();
-
-       group = g_try_malloc0(sizeof(mdgd_group_t));
-       group->uri_path = g_strdup(uri_path);
-       group->device_id = g_strdup(device_id);
-       group->group_name = g_strdup(device_name);
-       group->host_addr = g_strdup(host_addr);
-       group->resource_type =  g_strdup(resource_type);
-       group->type = type;
-
-       found_group_list = g_list_append(found_group_list, group);
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       g_variant_builder_add(builder, "{sv}", "URI",
-                                                 g_variant_new_string(group->uri_path));
-       g_variant_builder_add(builder, "{sv}", "DeviceID",
-                                                 g_variant_new_string(group->device_id));
-       g_variant_builder_add(builder, "{sv}", "GroupName",
-                                                 g_variant_new_string(group->group_name));
-       g_variant_builder_add(builder, "{sv}", "HostAddress",
-                                                 g_variant_new_string(group->host_addr));
-       g_variant_builder_add(builder, "{sv}", "GroupDeviceType",
-                                                 g_variant_new_string(group->resource_type));
-       g_variant_builder_add(builder, "{sv}", "GroupType",
-                                                 g_variant_new_int32(group->type));
-
-       group_data = g_variant_builder_end(builder);
-
-       notify_group_found(group_data);
-
-       g_variant_builder_unref(builder);
-
-       LOG_END();
-
-       return MDGD_ERROR_NONE;
-}
-
-/* Join the remote devices in my daemon */
-
-// Find MOT enabled devices
-int mdgd_group_add_new_mot_device(mdgd_mot_device_t *device)
-{
-       GList *iter = NULL;
-       gboolean is_exist = FALSE;
-
-       LOG_BEGIN();
-
-       iter = mot_enb_dev_list;
-       while (iter != NULL) {
-               mdgd_mot_device_t *temp = (mdgd_mot_device_t *)iter->data;
-
-               if (g_strcmp0(temp->device_id, device->device_id) == 0) {
-                       LOG_DEBUG("Device %s already exists in mot enable device list",
-                                         device->device_id);
-                       is_exist = TRUE;
-                       break;
-               }
-
-               iter = g_list_next(iter);
-       }
-
-       if (is_exist == FALSE) {
-               LOG_DEBUG("Add device with uuid %s to mot enabled device list",
-                                 device->device_id);
-               mot_enb_dev_list = g_list_append(mot_enb_dev_list, device);
-       }
-
-       LOG_END();
-
-       return is_exist;
-}
-
-
-GVariant *mdgd_group_get_remote_mot_enabled_devices()
-{
-       GVariantBuilder *builder;
-       GVariant *group_data;
-       GList *iter = NULL;
-
-       mdgd_remove_ip_info();
-       mdgd_make_ip_info();
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
-
-       iter = mot_enb_dev_list;
-       while (iter != NULL) {
-               mdgd_mot_device_t *device = (mdgd_mot_device_t *)iter->data;
-
-               g_variant_builder_open(builder, G_VARIANT_TYPE_VARDICT);
-               g_variant_builder_add(builder, "{sv}", "DeviceID",
-                                                         g_variant_new_string(device->device_id));
-               g_variant_builder_add(builder, "{sv}", "Adapter",
-                                                         g_variant_new_int32(device->adapter));
-               g_variant_builder_add(builder, "{sv}", "Flags",
-                                                         g_variant_new_int32(device->flags));
-               g_variant_builder_add(builder, "{sv}", "Port",
-                                                         g_variant_new_uint16(device->port));
-               g_variant_builder_add(builder, "{sv}", "Address",
-                                                         g_variant_new_string(device->addr));
-               g_variant_builder_add(builder, "{sv}", "DeviceType",
-                                                         g_variant_new_uint16(mdgd_is_local_ip(device->addr)));
-               g_variant_builder_add(builder, "{sv}", "Ifindex",
-                                                         g_variant_new_int32(device->ifindex));
-               g_variant_builder_add(builder, "{sv}", "RouteData",
-                                                         g_variant_new_string(device->route_data));
-               g_variant_builder_add(builder, "{sv}", "ConnType",
-                                                         g_variant_new_int32(device->conn_type));
-               g_variant_builder_add(builder, "{sv}", "SecurePort",
-                                                         g_variant_new_uint16(device->secure_port));
-               g_variant_builder_add(builder, "{sv}", "TcpPort",
-                                                         g_variant_new_uint16(device->tcp_port));
-               g_variant_builder_add(builder, "{sv}", "SecVer",
-                                                         g_variant_new_string(device->sec_ver));
-               g_variant_builder_add(builder, "{sv}", "DeviceStatus",
-                                                         g_variant_new_int32(device->dev_status));
-               LOG_DEBUG("%s", device->model_name);
-               g_variant_builder_add(builder, "{sv}", "ModelName",
-                                                         g_variant_new_string(device->model_name));
-               g_variant_builder_add(builder, "{sv}", "DeviceName",
-                                                         g_variant_new_string(device->device_name));
-               g_variant_builder_add(builder, "{sv}", "PlatformVer",
-                                                         g_variant_new_string(device->platform_ver));
-               g_variant_builder_add(builder, "{sv}", "VendorID",
-                                                         g_variant_new_string(device->vendor_id));
-               g_variant_builder_add(builder, "{sv}", "Profile",
-                                                         g_variant_new_string(device->profile));
-
-               g_variant_builder_close(builder);
-
-               iter = g_list_next(iter);
-       }
-
-       group_data = g_variant_builder_end(builder);
-       g_variant_builder_unref(builder);
-
-       return group_data;
-}
-
-int mdgd_group_get_mot_device_count()
-{
-       if (mot_enb_dev_list)
-               return g_list_length(mot_enb_dev_list);
-
-       return 0;
-}
-
-void mdgd_group_notify_mot_enable_device_done()
-{
-       GVariant *device_data;
-       int count = mdgd_group_get_mot_device_count();
-
-       LOG_BEGIN();
-
-       device_data = mdgd_group_get_remote_mot_enabled_devices();
-
-       notify_device_found(count, device_data);
-
-       LOG_END();
-}
-
-int mdgd_group_find_mot_enabled_devices(int timeout)
-{
-       int ret;
-
-       LOG_BEGIN();
-
-       /* list freeing */
-       g_list_free_full(mot_enb_dev_list, _mot_enb_dev_list_free_func);
-       mot_enb_dev_list = NULL;
-
-       ret = agent_find_mot_enable_devices(timeout);
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("Failed to find mot enable devices : %s",
-                                mdgd_log_get_error_string(ret));
-       }
-
-       LOG_END();
-
-       return ret;
-}
-
-void mdgd_group_notify_keepalive_response(mdgd_command_t *cmd)
-{
-       GList *iter = NULL;
-       gboolean is_exist = FALSE;
-       mdgd_invited_device_t *temp;
-
-       LOG_DEBUG("Response received from uuid %s", cmd->uuid);
-
-       iter = invited_dev_list;
-       while (iter != NULL) {
-               temp = (mdgd_invited_device_t *)iter->data;
-
-               if ((g_strcmp0(temp->group_name, cmd->arg1) == 0) &&
-                       (g_strcmp0(temp->uuid, cmd->uuid) == 0)) {
-                       LOG_DEBUG("Device %s count %d found in invited device list",
-                                         cmd->uuid, temp->count);
-                       is_exist = TRUE;
-                       break;
-               }
-
-               iter = g_list_next(iter);
-       }
-
-       if (is_exist == TRUE)
-               temp->count += 1;
-}
-
-int mdgd_group_request_keepalive(char *uuid, char *group_name, char *host)
-{
-       int ret = MDGD_ERROR_NONE;
-
-       LOG_DEBUG("[Request KeepAlive] to %s", uuid);
-       mdgd_command_t *cmd = g_new0(mdgd_command_t, 1);
-       cmd->command = MDGD_REQ_KEEP_ALIVE;
-       cmd->uuid = g_strdup(uuid);
-       cmd->arg1 = g_strdup(group_name);
-       cmd->host = g_strdup(host);
-
-       ret = mdgd_iot_send_data(MDGD_RESOURCE_TYPE_DATA, 2, cmd);
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("Failed to send data : %s",
-                               mdgd_log_get_error_string(ret));
-               return ret;
-       }
-
-       return 0;
-}
-
-mdgd_group_invite_info_t *mdgd_group_get_invite_info()
-{
-       return group_invite_info;
-}
-
-void mdgd_group_free_invite_info()
-{
-       LOG_DEBUG("Remove Group Invite Information %p", group_invite_info);
-
-       if (group_invite_info) {
-               g_free(group_invite_info->group_name);
-               g_free(group_invite_info->uuid_dev1);
-               g_free(group_invite_info->uuid_dev2);
-               g_free(group_invite_info->pin);
-               g_free(group_invite_info->uri_1);
-               g_free(group_invite_info->rt_1);
-               g_free(group_invite_info->interface_1);
-               g_free(group_invite_info->uri_2);
-               g_free(group_invite_info->rt_2);
-               g_free(group_invite_info->interface_2);
-               g_free(group_invite_info);
-
-               group_invite_info = NULL;
-       }
-}
-
-mdgd_mot_device_t *mdgd_group_check_device_in_mot_enb_dev_list(char *uuid)
-{
-       mdgd_mot_device_t *device;
-       GList *iter;
-
-       iter = mot_enb_dev_list;
-
-       while (iter != NULL) {
-               device = (mdgd_mot_device_t *)iter->data;
-
-               if (g_strcmp0(device->device_id, uuid) == 0) {
-                       LOG_DEBUG("Device %s is available in mot enable device list", uuid);
-                       return device;
-               }
-       }
-
-       return NULL;
-}
-
-static char *_addr2host(char *addr, int port)
-{
-       char ip[50];
-       char *percent;
-
-       g_strlcpy(ip, addr, strlen(addr) + 1);
-
-       /* Remove % from address */
-       percent = strchr(ip, '%');
-       if (percent)
-               percent[0] = '\0';
-
-       /* IPv6 Address should be encoded for RFC6874  */
-       if (strchr(ip, ':')) /* IPv6 Adress */
-               return g_strdup_printf("coaps://[%s%s%s]:%d", ip, "%25",
-                                                                       percent + 1, port);
-       else /* IPv4 Address */
-               return g_strdup_printf("coaps://%s:%d", ip, port);
-}
-
-void mdgd_group_notify_group_invite(int ret)
-{
-       /*
-        * ret = 0 OC_STACK_OK
-        * ret = 49 OC_STACK_DUPLICATE_UUID
-        */
-       if (OC_STACK_OK == ret && group_invite_info) {
-               mdgd_invited_device_t *device;
-               GList *iter = NULL;
-               gboolean is_exist = FALSE;
-
-               device = g_try_malloc0(sizeof(mdgd_invited_device_t));
-               device->group_name = g_strdup(group_invite_info->group_name);
-               device->uuid = g_strdup(group_invite_info->uuid_dev2);
-
-               iter = invited_dev_list;
-               while (iter != NULL) {
-                       mdgd_invited_device_t *temp = (mdgd_invited_device_t *)iter->data;
-
-                       if ((g_strcmp0(temp->group_name, device->group_name) == 0) &&
-                               (g_strcmp0(temp->uuid, device->uuid) == 0)) {
-                               LOG_DEBUG("Device %s already exists in invited device list",
-                                                 temp->uuid);
-                               is_exist = TRUE;
-                               break;
-                       }
-
-                       iter = g_list_next(iter);
-               }
-
-               if (is_exist == FALSE) {
-                       mdgd_mot_device_t *temp;
-                       temp = mdgd_group_check_device_in_mot_enb_dev_list(device->uuid);
-                       if (temp)
-                               device->host = _addr2host(temp->addr, temp->secure_port);
-
-                       device->count = 0;
-                       LOG_DEBUG("Add device %s group %s host %s to invited device list",
-                                         device->uuid, device->group_name, device->host);
-                       invited_dev_list = g_list_prepend(invited_dev_list, device);
-
-                       mdgd_group_request_keepalive(device->uuid, device->group_name,
-                                                                                device->host);
-
-                       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-                       mdgd_check_null_ret("mdgd_ctx", mdgd_ctx);
-
-                       if (mdgd_ctx->monitor_started == true) {
-                               notify_device_monitor_result(device->uuid, device->group_name,
-                                                                                        "Added");
-
-                               mdgd_group_start_invited_device_monitor(1);
-                       }
-
-               } else {
-                       g_free(device->uuid);
-                       g_free(device->group_name);
-                       g_free(device);
-               }
-       } else if (OC_STACK_DUPLICATE_UUID == ret) {
-               /* Replace error code for CAPI */
-               ret = MDGD_ERROR_ALREADY_REGISTERED;
-       } else if (OC_STACK_INVALID_PARAM == ret) {
-               /* Replace error code for CAPI */
-               ret = MDGD_ERROR_OPERATION_FAILED;
-       }
-
-       mdgd_group_free_invite_info();
-
-       notify_group_device_invite_result(ret);
-}
-
-
-#define FULL_PERMISSION 31
-
-int _is_pairwise_uuid(char *uuid)
-{
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, -1);
-
-       GList *iter = NULL;
-
-       iter = mdgd_ctx->pairwise_list;
-       while (iter != NULL) {
-               char *pairwise_uuid = (char *)iter->data;
-
-               if (!strncmp(pairwise_uuid, uuid, strlen(uuid)))
-                       return 0;
-
-               iter = g_list_next(iter);
-       }
-
-       return -1;
-}
-
-int mdgd_group_add_device_in_group(const char *group_name, const char *uuid)
-{
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, -1);
-
-       GList *iter = NULL;
-
-       iter = mdgd_ctx->grp_list;
-       while (iter != NULL) {
-               mdgd_grp_t *group = (mdgd_grp_t *)iter->data;
-
-               if (!strncmp(group_name, group->name, strlen(group->name))) {
-                       GList *device_iter = group->device_list;
-                       while (device_iter != NULL) {
-                               char *device_uuid = (char *)device_iter->data;
-                               if (!strncmp(device_uuid, uuid, strlen(device_uuid)))
-                                       return -1;
-
-                               device_iter = g_list_next(device_iter);
-                       }
-
-                       group->device_list = g_list_append(group->device_list, strdup(uuid));
-
-                       __print_groups_information();
-                       return 0;
-               }
-
-               iter = g_list_next(iter);
-       }
-
-       return -1;
-}
-
-//Join to device in group (async)
-int mdgd_group_invite(const char *group_name, const char *uuid, const char *pin)
-{
-       int ret = MDGD_ERROR_NONE;
-
-       LOG_BEGIN();
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, MDGD_ERROR_INVALID_PARAMETER);
-
-#ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
-       /*
-        * 1. Perform MOT
-        * 2. Discover Mowned devices
-        * 3. Pairwise
-        */
-       LOG_DEBUG("group name : %s, uuid : %s", group_name, uuid);
-
-       if (_is_pairwise_uuid(uuid) < 0) {
-
-               ret = agent_mot(uuid, pin);
-               if (ret == MDGD_ERROR_NONE) {
-                       group_invite_info = g_try_malloc0(sizeof(mdgd_group_invite_info_t));
-                       group_invite_info->uuid_dev1 = g_strdup(mdgd_ctx->device_uuid);
-                       group_invite_info->uuid_dev2 = g_strdup(uuid);
-                       group_invite_info->pin = g_strdup(pin);
-                       group_invite_info->uri_1 = g_strdup("/comp/data/1");
-                       group_invite_info->rt_1 = g_strdup("core.comp.data");
-                       group_invite_info->interface_1 = g_strdup("oic.if.baseline");
-                       group_invite_info->permission_1 = FULL_PERMISSION;
-                       group_invite_info->uri_2 = g_strdup("/comp/data/1");
-                       group_invite_info->rt_2 = g_strdup("core.comp.data");
-                       group_invite_info->interface_2 = g_strdup("oic.if.baseline");
-                       group_invite_info->permission_2 = FULL_PERMISSION;
-               }
-       }
-
-#else
-       group_invite_info = g_try_malloc0(sizeof(mdgd_group_invite_info_t));
-       group_invite_info->uuid_dev2 = g_strdup(uuid);
-       group_invite_info->group_name = g_strdup(group_name);
-
-       ret = agent_pair(pin, mdgd_ctx->device_uuid, uuid, "/comp/data/1",
-                                        "core.comp.data", "oic.if.baseline", FULL_PERMISSION, uuid,
-                                        mdgd_ctx->device_uuid, "/comp/data/1", "core.comp.data",
-                                        "oic.if.baseline", FULL_PERMISSION);
-#endif
-
-       if (mdgd_group_add_device_in_group(group_name, uuid) < 0)
-               return MDGD_ERROR_NONE;
-
-       LOG_END();
-
-       return ret;
-}
-
-void mdgd_group_notify_group_dismiss(int result)
-{
-       LOG_DEBUG("Notify group eject %d", result);
-
-       /* Replace error code for CAPI */
-       if (OC_STACK_INVALID_PARAM == result)
-               result = MDGD_ERROR_ALREADY_REGISTERED;
-
-       notify_group_device_eject_result(result);
-}
-
-int mdgd_group_remove_device_in_group(char *group_name, char *uuid)
-{
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, -1);
-
-       GList *iter = NULL;
-
-       /* Find the device at every group in list */
-       iter = mdgd_ctx->grp_list;
-       while (iter != NULL) {
-               mdgd_grp_t *group = (mdgd_grp_t *)iter->data;
-               if (!strncmp(group_name, group->name, strlen(group_name))) {
-                       GList *device_iter = group->device_list;
-
-                       device_iter = g_list_remove_all(device_iter, uuid);
-               }
-
-               iter = g_list_next(iter);
-       }
-       mdgd_db_device_delete(uuid, group_name);
-       __print_groups_information();
-
-       return 0;
-}
-
-//dismiss from group (async)
-int mdgd_group_eject(const gchar *group_name, gchar *uuid_dev1, const gchar *uuid_dev2)
-{
-       int ret;
-
-       LOG_BEGIN();
- #ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
-       ret = agent_remove_mo_at_device(uuid);
-       /*
-        * 1. Unpair device
-        * 2. Remove MOT at device #2
-        * 3. Remove cred at local (device #1)
-        * */
-#else
-       ret = agent_unpair(uuid_dev1, uuid_dev2);
-#endif
-       mdgd_group_remove_device_in_group(group_name, uuid_dev2);
-
-       LOG_END();
-
-       return ret;
-}
-
-int mdgd_group_pair_resource(char* target1, char *subject1, char *uri1,
-       char *rt1, char *interface1, int permission1, char* target2, char *subject2,
-       char *uri2, char *rt2, char *interface2, int permission2)
-{
-       int ret;
-
-       LOG_BEGIN();
-
-       ret = agent_resources_pairwise(target1, subject1, uri1, rt1, interface1, permission1,
-                                                target2, subject2, uri2, rt2, interface2, permission2);
-
-       LOG_END();
-
-       return ret;
-}
-
-int mdgd_group_unpair_resource(gchar *uuid_dev1, gchar *uuid_dev2)
-{
-       int ret;
-
-       LOG_BEGIN();
-
-       ret = agent_unlink_resources(uuid_dev1, uuid_dev2);
-
-       LOG_END();
-
-       return ret;
-}
-
-int mdgd_group_send_data(gchar *uuid_dev, gchar *addr, int port,
-                                                unsigned char *data, int len)
-{
-       int ret;
-
-       LOG_BEGIN();
-
-       mdgd_command_t *cmd = g_try_malloc0(sizeof(mdgd_command_t));
-       if (NULL == cmd) {
-               ret = MDGD_ERROR_OUT_OF_MEMORY;
-               LOG_ERR("Failed to alloc memory");
-               return ret;
-       }
-
-       cmd->command = MDGD_REQ_SEND_DATA;
-       cmd->uuid = g_strdup(uuid_dev);
-
-       cmd->host = _addr2host(addr, port);
-
-#ifdef SUPPORT_BASE64_ENCODING
-       cmd->data = g_try_malloc0(len + 1);
-       if (NULL == cmd->data) {
-               ret = MDGD_ERROR_OUT_OF_MEMORY;
-               LOG_ERR("Send Data Fail to uuid = %s host %s error=%s",
-                       cmd->uuid, cmd->host, mdgd_log_get_error_string(ret));
-               return ret;
-       }
-
-       memcpy(cmd->data, data, len);
-       cmd->data_len = len;
-#else
-       cmd->arg1 = g_try_malloc0(len + 1);
-       if (NULL == cmd->arg1) {
-               ret = MDGD_ERROR_OUT_OF_MEMORY;
-               LOG_ERR("Send Data Fail to uuid = %s host %s error=%s",
-                       cmd->uuid, cmd->host, mdgd_log_get_error_string(ret));
-               return ret;
-       }
-
-       memcpy(cmd->arg1, data, len);
-       cmd->arg1[len] = '\0';
-#endif
-
-       LOG_DEBUG("UUID %s host %s", cmd->uuid, cmd->host);
-
-       ret = mdgd_iot_send_data(MDGD_RESOURCE_TYPE_DATA, 3, cmd);
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("Failed to send data : %s",
-                               mdgd_log_get_error_string(ret));
-       }
-
-       LOG_END();
-
-       return ret;
-}
-
-int  mdgd_group_add_new_mowned_device(mdgd_mot_device_t *device)
-{
-       GList *iter = NULL;
-       gboolean is_exist = FALSE;
-
-       LOG_BEGIN();
-
-       iter = mowned_dev_list;
-       while (iter != NULL) {
-               mdgd_mot_device_t *temp = (mdgd_mot_device_t *)iter->data;
-
-               if (g_strcmp0(temp->device_id, device->device_id) == 0) {
-                       LOG_DEBUG("Device %s already exists in mowned device list",
-                                         device->device_id);
-                       is_exist = TRUE;
-                       break;
-               }
-
-               iter = g_list_next(iter);
-       }
-
-       if (is_exist == FALSE) {
-               LOG_DEBUG("Add device with uuid %s to mowned device list",
-                                 device->device_id);
-               mowned_dev_list = g_list_append(mowned_dev_list, device);
-       }
-
-       LOG_END();
-
-       return is_exist;
-}
-
-GVariant *mdgd_group_get_mowned_devices()
-{
-       GVariantBuilder *builder;
-       GVariant *group_data;
-       GList *iter = NULL;
-
-       mdgd_remove_ip_info();
-       mdgd_make_ip_info();
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
-
-       iter = mowned_dev_list;
-       while (iter != NULL) {
-               mdgd_mot_device_t *device = (mdgd_mot_device_t *)iter->data;
-
-               g_variant_builder_open(builder, G_VARIANT_TYPE_VARDICT);
-               g_variant_builder_add(builder, "{sv}", "DeviceID",
-                                                         g_variant_new_string(device->device_id));
-               g_variant_builder_add(builder, "{sv}", "Adapter",
-                                                         g_variant_new_int32(device->adapter));
-               g_variant_builder_add(builder, "{sv}", "Flags",
-                                                         g_variant_new_int32(device->flags));
-               g_variant_builder_add(builder, "{sv}", "Port",
-                                                         g_variant_new_uint16(device->port));
-               g_variant_builder_add(builder, "{sv}", "Address",
-                                                         g_variant_new_string(device->addr));
-               g_variant_builder_add(builder, "{sv}", "DeviceType",
-                                                         g_variant_new_uint16(mdgd_is_local_ip(device->addr)));
-               g_variant_builder_add(builder, "{sv}", "Ifindex",
-                                                         g_variant_new_int32(device->ifindex));
-               g_variant_builder_add(builder, "{sv}", "RouteData",
-                                                         g_variant_new_string(device->route_data));
-               g_variant_builder_add(builder, "{sv}", "ConnType",
-                                                         g_variant_new_int32(device->conn_type));
-               g_variant_builder_add(builder, "{sv}", "SecurePort",
-                                                         g_variant_new_uint16(device->secure_port));
-               g_variant_builder_add(builder, "{sv}", "TcpPort",
-                                                         g_variant_new_uint16(device->tcp_port));
-               g_variant_builder_add(builder, "{sv}", "SecVer",
-                                                         g_variant_new_string(device->sec_ver));
-               g_variant_builder_add(builder, "{sv}", "DeviceStatus",
-                                                         g_variant_new_int32(device->dev_status));
-               g_variant_builder_add(builder, "{sv}", "ModelName",
-                                                         g_variant_new_string(device->model_name));
-               g_variant_builder_add(builder, "{sv}", "DeviceName",
-                                                         g_variant_new_string(device->device_name));
-               g_variant_builder_add(builder, "{sv}", "PlatformVer",
-                                                         g_variant_new_string(device->platform_ver));
-               g_variant_builder_add(builder, "{sv}", "VendorID",
-                                                         g_variant_new_string(device->vendor_id));
-               g_variant_builder_add(builder, "{sv}", "Profile",
-                                                         g_variant_new_string(device->profile));
-
-               g_variant_builder_close(builder);
-
-               iter = g_list_next(iter);
-       }
-
-       group_data = g_variant_builder_end(builder);
-       g_variant_builder_unref(builder);
-
-       return group_data;
-}
-
-void mdgd_group_change_mowned_device(mdgd_mot_device_t *device)
-{
-       LOG_BEGIN();
-
-       my_device = device;
-
-       LOG_END();
-}
-
-GVariant *mdgd_group_get_my_mowned_devices()
-{
-       GVariantBuilder *builder;
-       GVariant *group_data;
-
-       mdgd_remove_ip_info();
-       mdgd_make_ip_info();
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
-
-       if (my_device != NULL) {
-               g_variant_builder_add(builder, "{sv}", "DeviceID",
-                                                         g_variant_new_string(my_device->device_id));
-               g_variant_builder_add(builder, "{sv}", "Adapter",
-                                                         g_variant_new_int32(my_device->adapter));
-               g_variant_builder_add(builder, "{sv}", "Flags",
-                                                         g_variant_new_int32(my_device->flags));
-               g_variant_builder_add(builder, "{sv}", "Port",
-                                                         g_variant_new_uint16(my_device->port));
-               g_variant_builder_add(builder, "{sv}", "Address",
-                                                         g_variant_new_string(my_device->addr));
-               g_variant_builder_add(builder, "{sv}", "DeviceType",
-                                                         g_variant_new_uint16(mdgd_is_local_ip(my_device->addr)));
-               g_variant_builder_add(builder, "{sv}", "Ifindex",
-                                                         g_variant_new_int32(my_device->ifindex));
-               g_variant_builder_add(builder, "{sv}", "RouteData",
-                                                         g_variant_new_string(my_device->route_data));
-               g_variant_builder_add(builder, "{sv}", "ConnType",
-                                                         g_variant_new_int32(my_device->conn_type));
-               g_variant_builder_add(builder, "{sv}", "SecurePort",
-                                                         g_variant_new_uint16(my_device->secure_port));
-               g_variant_builder_add(builder, "{sv}", "TcpPort",
-                                                         g_variant_new_uint16(my_device->tcp_port));
-               g_variant_builder_add(builder, "{sv}", "SecVer",
-                                                         g_variant_new_string(my_device->sec_ver));
-               g_variant_builder_add(builder, "{sv}", "DeviceStatus",
-                                                         g_variant_new_int32(my_device->dev_status));
-               g_variant_builder_add(builder, "{sv}", "ModelName",
-                                                         g_variant_new_string(my_device->model_name));
-               g_variant_builder_add(builder, "{sv}", "DeviceName",
-                                                         g_variant_new_string(my_device->device_name));
-               g_variant_builder_add(builder, "{sv}", "PlatformVer",
-                                                         g_variant_new_string(my_device->platform_ver));
-               g_variant_builder_add(builder, "{sv}", "VendorID",
-                                                         g_variant_new_string(my_device->vendor_id));
-               g_variant_builder_add(builder, "{sv}", "Profile",
-                                                         g_variant_new_string(my_device->profile));
-       }
-
-       group_data = g_variant_builder_end(builder);
-       g_variant_builder_unref(builder);
-
-       return group_data;
-}
-
-int mdgd_group_get_mowned_device_count()
-{
-       if (mowned_dev_list)
-               return g_list_length(mowned_dev_list);
-
-       return 0;
-}
-
-void mdgd_group_notify_mowned_device_find_done()
-{
-       GVariant *device_data;
-       int count = g_list_length(mowned_dev_list);
-
-       LOG_BEGIN();
-
-       device_data = mdgd_group_get_mowned_devices();
-
-       notify_mowned_device_found(count, device_data);
-
-       LOG_END();
-}
-
-int mdgd_group_find_mowned_devices(int timeout)
-{
-       int ret;
-
-       LOG_BEGIN();
-
-       /* list freeing */
-       g_list_free_full(mowned_dev_list, _mot_enb_dev_list_free_func);
-       mowned_dev_list = NULL;
-
-       ret = agent_find_mowned_devices(timeout);
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("Failed to find mowned devices : %s",
-                                mdgd_log_get_error_string(ret));
-       }
-
-       LOG_END();
-
-       return ret;
-}
-
-/* Join to remote device group */
-
-int mdgd_group_join()
-{
-       int ret = MDGD_ERROR_NONE;
-
-       LOG_BEGIN();
-
-
-       LOG_END();
-
-       return ret;
-}
-
-int mdgd_group_leave_from(/* callback */) //leave from certain remote group (Async)
-{
-       int ret = MDGD_ERROR_NONE;
-       return ret;
-}
-
-/* Called when daemon is end. */
-int mdgd_group_deinitialize()
-{
-       int ret = MDGD_ERROR_NONE;
-       return ret;
-}
-
-int mdgd_group_get_group_name(mdgd_group_t *handle, char **name)
-{
-       int ret = MDGD_ERROR_NONE;
-       NOTUSED(handle);
-       NOTUSED(name);
-       return ret;
-}
-
-int mdgd_group_get_group_type(mdgd_group_t *handle, int *type)
-{
-       int ret = MDGD_ERROR_NONE;
-       NOTUSED(handle);
-       NOTUSED(type);
-       return ret;
-}
-
-int mdgd_group_get_group_device_type(mdgd_group_t *handle)
-{
-       int ret = MDGD_ERROR_NONE;
-       NOTUSED(handle);
-       return ret;
-}
-
-int mdgd_group_get_group_device_id(mdgd_group_t *handle)
-{
-       int ret = MDGD_ERROR_NONE;
-       NOTUSED(handle);
-       return ret;
-}
-
-int mdgd_group_request_create_group(char *uuid, char *group_name)
-{
-       int ret = MDGD_ERROR_NONE;
-       mdgd_mot_device_t *device;
-
-       LOG_ERR("[Request Create Group] %s", group_name);
-       LOG_ERR("[Request Create Group] to %s", uuid);
-
-       mdgd_command_t *cmd = g_new0(mdgd_command_t, 1);
-       cmd->command = MDGD_REQ_CREATE_GROUP;
-       cmd->uuid = g_strdup(uuid);
-       cmd->arg1 = g_strdup(group_name);
-
-       device = mdgd_group_check_device_in_mot_enb_dev_list(uuid);
-       if (device) {
-               cmd->host = _addr2host(device->addr, device->secure_port);
-               ret = mdgd_iot_send_data(MDGD_RESOURCE_TYPE_DATA, 5, cmd);
-               if (ret != MDGD_ERROR_NONE) {
-                       LOG_ERR("Failed to send data : %s",
-                                       mdgd_log_get_error_string(ret));
-               }
-       } else {
-               ret = mdgd_iot_discovery_resource(MDGD_RESOURCE_TYPE_DATA, 5, cmd);
-               if (ret != MDGD_ERROR_NONE) {
-                       LOG_ERR("Failed to discover resource : %s",
-                                       mdgd_log_get_error_string(ret));
-               }
-       }
-
-       return ret;
-}
-
-int mdgd_group_request_invite(char *uuid, char *group_name, char *target_uuid, char *PIN)
-{
-       int ret = MDGD_ERROR_NONE;
-       mdgd_mot_device_t *device;
-
-       LOG_ERR("[Request Invite] %s, %s, %s", group_name, target_uuid, PIN);
-       LOG_ERR("[Request Invite] to %s", uuid);
-
-       mdgd_command_t *cmd = g_new0(mdgd_command_t, 1);
-       cmd->command = MDGD_REQ_INVITE_DEVICE;
-       cmd->uuid = g_strdup(uuid);
-       cmd->arg1 = g_strdup(group_name);
-       cmd->arg2 = g_strdup(target_uuid);
-       cmd->arg3 = g_strdup(PIN);
-
-       device = mdgd_group_check_device_in_mot_enb_dev_list(uuid);
-       if (device) {
-               cmd->host = _addr2host(device->addr, device->secure_port);
-               ret = mdgd_iot_send_data(MDGD_RESOURCE_TYPE_DATA, 5, cmd);
-               if (ret != MDGD_ERROR_NONE) {
-                       LOG_ERR("Failed to send data : %s",
-                                       mdgd_log_get_error_string(ret));
-               }
-       } else {
-               ret = mdgd_iot_discovery_resource(MDGD_RESOURCE_TYPE_DATA, 5, cmd);
-               if (ret != MDGD_ERROR_NONE) {
-                       LOG_ERR("Failed to discover resource : %s",
-                                       mdgd_log_get_error_string(ret));
-               }
-       }
-
-       return ret;
-}
-
-
-int mdgd_group_request_eject(char *uuid, char *group_name, char *target_uuid)
-{
-       int ret = MDGD_ERROR_NONE;
-       mdgd_mot_device_t *device;
-
-       LOG_ERR("[Request Eject] %s, %s", group_name, target_uuid);
-       LOG_ERR("[Request Eject] to %s", uuid);
-
-       mdgd_command_t *cmd = g_new0(mdgd_command_t, 1);
-       cmd->command = MDGD_REQ_EJECT_DEVICE;
-       cmd->uuid = g_strdup(uuid);
-       cmd->arg1 = g_strdup(group_name);
-       cmd->arg2 = g_strdup(target_uuid);
-
-       device = mdgd_group_check_device_in_mot_enb_dev_list(uuid);
-       if (device) {
-               cmd->host = _addr2host(device->addr, device->secure_port);
-               ret = mdgd_iot_send_data(MDGD_RESOURCE_TYPE_DATA, 5, cmd);
-               if (ret != MDGD_ERROR_NONE) {
-                       LOG_ERR("Failed to send data : %s",
-                                       mdgd_log_get_error_string(ret));
-               }
-       } else {
-               ret = mdgd_iot_discovery_resource(MDGD_RESOURCE_TYPE_DATA, 5, cmd);
-               if (ret != MDGD_ERROR_NONE) {
-                       LOG_ERR("Failed to discover resource : %s",
-                                       mdgd_log_get_error_string(ret));
-               }
-       }
-
-       return ret;
-
-}
-
-
-int mdgd_group_request_delete_group(char *uuid, char *group_name)
-{
-       int ret = MDGD_ERROR_NONE;
-       mdgd_mot_device_t *device;
-
-       LOG_ERR("[Request Delete Group] %s", group_name);
-       LOG_ERR("[Request Delete Group] to %s", uuid);
-
-       mdgd_command_t *cmd = g_new0(mdgd_command_t, 1);
-       cmd->command = MDGD_REQ_DELETE_GROUP;
-       cmd->uuid = g_strdup(uuid);
-       cmd->arg1 = g_strdup(group_name);
-
-       device = mdgd_group_check_device_in_mot_enb_dev_list(uuid);
-       if (device) {
-               cmd->host = _addr2host(device->addr, device->secure_port);
-               ret = mdgd_iot_send_data(MDGD_RESOURCE_TYPE_DATA, 5, cmd);
-               if (ret != MDGD_ERROR_NONE) {
-                       LOG_ERR("Failed to send data : %s",
-                                       mdgd_log_get_error_string(ret));
-               }
-       } else {
-               ret = mdgd_iot_discovery_resource(MDGD_RESOURCE_TYPE_DATA, 5, cmd);
-               if (ret != MDGD_ERROR_NONE) {
-                       LOG_ERR("Failed to discover resource : %s",
-                                       mdgd_log_get_error_string(ret));
-               }
-       }
-
-       return ret;
-}
-
-static gboolean __send_keepalive_messages(gpointer user_data)
-{
-       GList *iter = NULL;
-
-       iter = invited_dev_list;
-       while (iter != NULL) {
-               mdgd_invited_device_t *temp = (mdgd_invited_device_t *)iter->data;
-
-               mdgd_group_request_keepalive(temp->uuid, temp->group_name, temp->host);
-
-               iter = g_list_next(iter);
-       }
-
-       return TRUE;
-}
-
-static gboolean __check_invited_device_status(gpointer user_data)
-{
-       int *t_id = (int *)user_data;
-       GList *iter = NULL;
-
-       g_source_remove(*t_id);
-       *t_id = 0;
-
-       iter = invited_dev_list;
-       while (iter != NULL) {
-               mdgd_invited_device_t *temp = (mdgd_invited_device_t *)iter->data;
-
-               iter = g_list_next(iter);
-
-               LOG_DEBUG("uuid %s count %d", temp->uuid, temp->count);
-
-               if (temp->count == 0) {
-                       LOG_DEBUG("Remove device with uuid %s", temp->uuid);
-                       invited_dev_list = g_list_remove(invited_dev_list, temp);
-
-                       notify_device_monitor_result(temp->uuid, temp->group_name,
-                                                                                "Removed");
-
-                       g_free(temp->host);
-                       g_free(temp->uuid);
-                       g_free(temp->group_name);
-                       g_free(temp);
-               } else {
-                       temp->count = 0;
-               }
-       }
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, FALSE);
-
-       if (mdgd_ctx->monitor_started == false) {
-               g_free(t_id);
-               return FALSE;
-       }
-
-       if (g_list_length(invited_dev_list) == 0) {
-               g_free(t_id);
-               return FALSE;
-       }
-
-       *t_id = g_timeout_add(KEEPALIVE_MESSAGE_TIMEOUT, __send_keepalive_messages,
-                                                 NULL);
-
-       return TRUE;
-}
-
-int mdgd_group_start_invited_device_monitor(int start)
-{
-       int *t_id;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx,
-                                                         MDGD_ERROR_INVALID_PARAMETER);
-
-       if (start) { /* Start Monitor */
-               mdgd_ctx->monitor_started = true;
-               LOG_DEBUG("Start invited device monitor");
-       } else { /* Stop Monitor */
-               mdgd_ctx->monitor_started = false;
-               LOG_DEBUG("Stop invited device monitor");
-               return MDGD_ERROR_NONE;
-       }
-
-       t_id = g_try_malloc0(sizeof(int));
-
-       *t_id = g_timeout_add(KEEPALIVE_MESSAGE_TIMEOUT, __send_keepalive_messages,
-                                                 NULL);
-
-       g_timeout_add(CHECK_DEVICE_STATUS_TIMEOUT, __check_invited_device_status,
-                                                 t_id);
-
-       return MDGD_ERROR_NONE;
-}
diff --git a/src/mdg-manager/src/mdgd_iot.cpp b/src/mdg-manager/src/mdgd_iot.cpp
deleted file mode 100755 (executable)
index cf81b49..0000000
+++ /dev/null
@@ -1,1252 +0,0 @@
-/*
- * Copyright (c) 2018 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 <tzplatform_config.h>
-
-#include <utlist.h>
-#include <base64.h>
-#include <sys/utsname.h>
-
-#include <octypes.h>
-#include <pmtypes.h>
-#include <pmutility.h>
-#include <securevirtualresourcetypes.h>
-
-#include <iotivity_config.h>
-#include <platform_features.h>
-#include <ocprovisioningmanager.h>
-#include <doxmresource.h>
-#include <system_info.h>
-#include <vconf.h>
-#include <system_settings.h>
-
-#include <mdgd_iot.h>
-#include <mdgd_group.h>
-#include <mdgd_gdbus_group.h>
-#include <mdgd_mot_agent.h>
-#include <mdgd_db.h>
-
-#include "OCProvisioningManager.hpp"
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-using namespace OC;
-using namespace std;
-
-#define MAX_FILE_PATH_LEN 1024
-#define SVR_DB_FILE_NAME "oic_svr_db_mdgd_manager.dat"
-#define SYSTEM_INFO_PLATFORM_VERSION "http://tizen.org/feature/platform.version"
-#define SYSTEM_INFO_MANUF_NAME "http://tizen.org/system/manufacturer"
-#define SYSTEM_INFO_MODEL_NAME "http://tizen.org/system/model_name"
-#define SYSTEM_INFO_BUILD_STRING "http://tizen.org/system/build.string"
-#define SYSTEM_INFO_TIZEN_ID "http://tizen.org/system/tizenid"
-#define SYSTEM_INFO_PROFILE "http://tizen.org/feature/profile"
-
-int last_get_result;
-OCPersistentStorage ps;
-
-static int ConvertUuidToStr(const OicUuid_t* uuid, char** strUuid)
-{
-       if (NULL == uuid || NULL == strUuid || NULL != *strUuid) {
-               LOG_ERR("ConvertUuidToStr : Invalid param");
-               return OC_STACK_INVALID_PARAM;
-       }
-
-       size_t uuidIdx = 0;
-       size_t urnIdx = 0;
-       const size_t urnBufSize = (UUID_LENGTH * 2) + 4 + 1;
-       char* convertedUrn = (char*)calloc(urnBufSize, sizeof(char));
-       if (NULL == convertedUrn) {
-               LOG_ERR("Memory Allocation Failed");
-               goto exit;
-       }
-
-       for (uuidIdx = 0, urnIdx = 0; uuidIdx < UUID_LENGTH && urnIdx < urnBufSize;
-               uuidIdx++, urnIdx += 2) {
-               // canonical format for UUID has '8-4-4-4-12'
-               if (uuidIdx == 4 || uuidIdx == 6 || uuidIdx == 8 || uuidIdx == 10) {
-                       snprintf(convertedUrn + urnIdx, 2, "%c", '-');
-                       urnIdx++;
-               }
-               snprintf(convertedUrn + urnIdx, 3, "%02x", (uint8_t)(uuid->id[uuidIdx]));
-       }
-       convertedUrn[urnBufSize - 1] = '\0';
-
-       *strUuid = convertedUrn;
-       return OC_STACK_OK;
-
-exit:
-       return OC_STACK_NO_MEMORY;
-}
-
-#define CASE_TO_STR(x) case x: return #x;
-
-static const char *command2string(mdgd_request_type_e command)
-{
-       switch (command) {
-       CASE_TO_STR(MDGD_REQ_SEND_DATA)
-       CASE_TO_STR(MDGD_REQ_CREATE_GROUP)
-       CASE_TO_STR(MDGD_REQ_INVITE_DEVICE)
-       CASE_TO_STR(MDGD_REQ_EJECT_DEVICE)
-       CASE_TO_STR(MDGD_REQ_DELETE_GROUP)
-       default:
-               return "Unknown Command";
-       }
-}
-
-static mdgd_request_type_e string2command(char *command)
-{
-       if (g_strcmp0(command, "5") == 0)
-               return MDGD_REQ_SEND_DATA;
-       else if (g_strcmp0(command, "1") == 0)
-               return MDGD_REQ_CREATE_GROUP;
-       else if (g_strcmp0(command, "2") == 0)
-               return MDGD_REQ_INVITE_DEVICE;
-       else if (g_strcmp0(command, "3") == 0)
-               return MDGD_REQ_EJECT_DEVICE;
-       else if (g_strcmp0(command, "4") == 0)
-               return MDGD_REQ_DELETE_GROUP;
-       else
-               return MDGD_REQ_UNKNOWN_COMMAND;
-}
-
-static FILE* client_open(const char* /*path*/, const char *mode)
-{
-       char data_dir[MAX_FILE_PATH_LEN] = {0,};
-
-       snprintf(data_dir, MAX_FILE_PATH_LEN, "%s/network/%s",
-                       "/opt/usr/data", SVR_DB_FILE_NAME);
-
-       LOG_DEBUG("Open file %s", data_dir);
-
-    return fopen(data_dir, mode);
-}
-
-int __mdgd_iot_get_platform_info(OCPlatformInfo *platform_info)
-{
-       int ret;
-       char *tizen_id = NULL;
-       char *device_name = NULL;
-       char platform_id[1024];
-
-       device_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
-       if (device_name == NULL)
-               LOG_ERR("vconf_get_str() Fail");
-
-       ret = system_info_get_platform_string(SYSTEM_INFO_TIZEN_ID, &tizen_id);
-       if (SYSTEM_INFO_ERROR_NONE != ret)
-               LOG_ERR("system_info_get_platform_string() Fail(%d)", ret);
-
-       snprintf(platform_id, sizeof(platform_id), "%s(%s)",
-                        device_name ? device_name : "", tizen_id ? tizen_id : "");
-
-       free(device_name);
-       free(tizen_id);
-       LOG_DEBUG("platform_id: %s", platform_id);
-
-       /* Mandatory (oic.wk.p) */
-       platform_info->platformID = strdup(platform_id);
-
-       /* Mandatory (oic.wk.p) */
-       ret = system_info_get_platform_string(SYSTEM_INFO_MANUF_NAME,
-                       &platform_info->manufacturerName);
-       if (SYSTEM_INFO_ERROR_NONE != ret) {
-               LOG_ERR("system_info_get_platform_string(manufacturer) Fail(%d)", ret);
-               free(platform_info->platformID);
-               return -1;
-       }
-
-       ret = system_info_get_platform_string(SYSTEM_INFO_MODEL_NAME,
-                       &platform_info->modelNumber);
-       if (SYSTEM_INFO_ERROR_NONE != ret)
-               LOG_ERR("system_info_get_platform_string(model_name) Fail(%d)", ret);
-
-       ret = system_info_get_platform_string(SYSTEM_INFO_PLATFORM_VERSION,
-                       &platform_info->platformVersion);
-       if (SYSTEM_INFO_ERROR_NONE != ret)
-               LOG_ERR("system_info_get_platform_string(platform_version) Fail(%d)", ret);
-
-       ret = system_info_get_platform_string(SYSTEM_INFO_BUILD_STRING,
-                       &platform_info->firmwareVersion);
-       if (SYSTEM_INFO_ERROR_NONE != ret)
-               LOG_ERR("system_info_get_platform_string(build_string) Fail(%d)", ret);
-
-       platform_info->manufacturerUrl = g_strdup("NONE");
-       platform_info->dateOfManufacture = g_strdup("NONE");
-
-       struct utsname uts;
-
-       if (!uname(&uts))
-               platform_info->operatingSystemVersion = g_strdup(uts.sysname);
-       else
-               platform_info->operatingSystemVersion = g_strdup("NONE");
-
-       platform_info->hardwareVersion = g_strdup("0-0");
-       platform_info->supportUrl = g_strdup("NONE");
-       platform_info->systemTime = g_strdup("NONE");
-
-       return 0;
-}
-
-static void _clean_platform_info(OCPlatformInfo *platform_info)
-{
-       mdgd_check_null_ret("platform_info", platform_info);
-
-       if (platform_info->platformID) {
-               free(platform_info->platformID);
-               platform_info->platformID = NULL;
-       }
-       if (platform_info->manufacturerName) {
-               free(platform_info->manufacturerName);
-               platform_info->manufacturerName = NULL;
-       }
-       if (platform_info->modelNumber) {
-               free(platform_info->modelNumber);
-               platform_info->modelNumber = NULL;
-       }
-       if (platform_info->platformVersion) {
-               free(platform_info->platformVersion);
-               platform_info->platformVersion = NULL;
-       }
-       if (platform_info->firmwareVersion) {
-               free(platform_info->firmwareVersion);
-               platform_info->firmwareVersion = NULL;
-       }
-       if (platform_info->manufacturerUrl) {
-               free(platform_info->manufacturerUrl);
-               platform_info->manufacturerUrl = NULL;
-       }
-       if (platform_info->dateOfManufacture) {
-               free(platform_info->dateOfManufacture);
-               platform_info->dateOfManufacture = NULL;
-       }
-       if (platform_info->operatingSystemVersion) {
-               free(platform_info->operatingSystemVersion);
-               platform_info->operatingSystemVersion = NULL;
-       }
-       if (platform_info->hardwareVersion) {
-               free(platform_info->hardwareVersion);
-               platform_info->hardwareVersion = NULL;
-       }
-       if (platform_info->supportUrl) {
-               free(platform_info->supportUrl);
-               platform_info->supportUrl = NULL;
-       }
-       if (platform_info->systemTime) {
-               free(platform_info->systemTime);
-               platform_info->systemTime = NULL;
-       }
-}
-
-int mdgd_iot_initialize()
-{
-       char *device_id = NULL;
-       int ret;
-       OCPlatformInfo platform_info = {0};
-
-       ps.open = client_open;
-       ps.read = fread;
-       ps.write = fwrite;
-       ps.close = fclose;
-       ps.unlink = unlink;
-
-       PlatformConfig cfg {
-               OC::ServiceType::InProc,
-                       OC::ModeType::Both,
-                       (OCTransportAdapter)(OCTransportAdapter::OC_ADAPTER_IP),
-                       OC::QualityOfService::LowQos,
-                       &ps
-       };
-
-       OCPlatform::Configure(cfg);
-
-       ret = __mdgd_iot_get_platform_info(&platform_info);
-       if (ret != 0) {
-               _clean_platform_info(&platform_info);
-               LOG_ERR("Failed to get platform info %d", ret);
-               return MDGD_ERROR_NONE;
-       }
-
-       ret = OCPlatform::registerPlatformInfo(platform_info);
-       if (ret != OC_STACK_OK)
-       {
-               _clean_platform_info(&platform_info);
-               LOG_ERR("Platform Registration failed");
-               return MDGD_ERROR_NONE;
-    }
-       _clean_platform_info(&platform_info);
-
-       OCDeviceInfo device_info = {0};
-       device_info.deviceName = g_strdup("UNKNOWN");
-
-       ret = OCPlatform::registerDeviceInfo(device_info);
-
-       if (ret != OC_STACK_OK)
-       {
-               LOG_ERR("Device Registration failed");
-               return MDGD_ERROR_NONE;
-    }
-
-       g_free(device_info.deviceName);
-
-       OicUuid_t uuid;
-
-       ret = GetDoxmDeviceID(&uuid);
-       if      (OC_STACK_OK != ret)
-               LOG_DEBUG("GetDoxmDevOwnerId failed = [%d][%s]", ret, get_error_message(ret));
-
-       ret = ConvertUuidToStr(&uuid, &device_id);
-       if (OC_STACK_OK != ret)
-               LOG_DEBUG("ConvertUuidToStr failed = [%d][%s]", ret, get_error_message(ret));
-
-       LOG_DEBUG("device_id : %s", device_id);
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, MDGD_ERROR_INVALID_PARAMETER);
-
-       mdgd_ctx->device_uuid = g_strdup(device_id);
-
-       /* Do Self-Ownership Transfer */
-       ret = OCSecure::configSelfOwnership();
-       if (OC_STACK_OK != ret ) {
-               LOG_ERR( "OCConfigSelfOwnership() error = [%d][%s]", ret, get_error_message(ret));
-       }
-
-       /*
-               "Device" resource
-               For get peer description.
-               ex) /comp/device
-       */
-       mdgd_iot_add_resource(MDGD_RESOURCE_TYPE_DEVICE, "");
-
-       /*
-               "operation" resource
-               The operation resource is a control command channel between daemon and daemon.
-               resource type is core.comp.operation
-               Within this function we create a default operation resource. (uri is /comp/operation/1)
-               If we need more control channels, increase the number.
-               ex) /comp/operation/2, /comp/operation/3
-       */
-       mdgd_iot_add_resource(MDGD_RESOURCE_TYPE_OPERATION, "1");
-
-       /*
-               "DATA" resource
-               To show the send data to remote daemon.
-               It can be used when the remote device is mot enable and pairwise.
-               ex) /comp/data/1
-       */
-       mdgd_iot_add_resource(MDGD_RESOURCE_TYPE_DATA, "1");
-
-       return MDGD_ERROR_NONE;
-}
-
-static void _print_oc_representation(OCRepresentation rep)
-{
-       /* attribute.type() is an enum class AttributeType defined in
-        * AttributeValue.h header file of IoTivity */
-       for (auto& attribute : rep) {
-               LOG_DEBUG("%s of type %d with value %s", attribute.attrname().c_str(),
-                                 attribute.type(),
-                                 attribute.getValueToString().c_str());
-       }
-}
-
-OCEntityHandlerResult _request_handler(std::shared_ptr<OCResourceRequest> request)
-{
-       LOG_DEBUG("_request_handler is called");
-
-       if (request) {
-               std::string requestType = request->getRequestType();
-               int requestFlag = request->getRequestHandlerFlag();
-
-               LOG_DEBUG("request type %s flag %x", requestType.c_str(), requestFlag);
-
-               if (requestType == "GET") {
-                       //Send Peer Description
-                       LOG_DEBUG("requestFlag : GET");
-                       auto pResponse = std::make_shared<OC::OCResourceResponse>();
-                       OCRepresentation rep;
-
-                       /* Set Peer Description */
-
-                       char *device_name = NULL;
-                       char *model_name = NULL;
-                       char *platform_ver = NULL;
-                       char *profile = NULL;
-                       char *vendor_id = NULL;
-
-                       system_settings_get_value_string(SYSTEM_SETTINGS_KEY_DEVICE_NAME, &device_name);
-                       system_info_get_platform_string(SYSTEM_INFO_MODEL_NAME, &model_name);
-                       system_info_get_platform_string(SYSTEM_INFO_PLATFORM_VERSION, &platform_ver);
-                       system_info_get_platform_string(SYSTEM_INFO_PROFILE, &profile);
-                       /* How to get the vendor id? */
-
-                       LOG_DEBUG("device name : %s", device_name);
-                       LOG_DEBUG("model name : %s", model_name);
-                       LOG_DEBUG("platform ver name : %s", platform_ver);
-                       LOG_DEBUG("profile : %s", profile);
-
-                       rep.setValue("model_name", std::string(model_name));
-                       rep.setValue("platform_ver", std::string(platform_ver));
-                       rep.setValue("profile", std::string(profile));
-                       rep.setValue("device_name", std::string(device_name));
-                       rep.setValue("vendor_id", std::string("6FFF"));
-
-                       pResponse->setRequestHandle(request->getRequestHandle());
-                       pResponse->setResourceHandle(request->getResourceHandle());
-                       pResponse->setErrorCode(200);
-                       pResponse->setResponseResult(OC_EH_OK);
-                       pResponse->setResourceRepresentation(rep, DEFAULT_INTERFACE);
-                       OCPlatform::sendResponse(pResponse);
-               } else if (requestType == "POST") {
-                       if (requestFlag & RequestHandlerFlag::RequestFlag) {
-                               LOG_DEBUG("requestFlag : Request");
-                               auto pResponse = std::make_shared<OC::OCResourceResponse>();
-                               unsigned char *arg = NULL;
-                               int arg_len = 0;
-                               int result;
-                               int cmd;
-                               std::string requester_id, group_name, uuid, data;
-#ifdef SUPPORT_BASE64_ENCODING
-                               int payload_len;
-                               size_t outSize;
-                               uint8_t *out;
-                               uint32_t len = 0;
-#endif
-                               mdgd_context_t *mdgd_ctx;
-
-                               try {
-                                       OCRepresentation rep = request->getResourceRepresentation();
-
-                                       _print_oc_representation(rep);
-
-                                       ObservationInfo observationInfo = request->getObservationInfo();
-                                       LOG_DEBUG("Received request from %s:%d",
-                                                 observationInfo.address.c_str(), observationInfo.port);
-
-                                       if (!rep.getValue("CMD", cmd))
-                                               LOG_ERR("CMD not found in representation");
-                                       else
-                                               LOG_DEBUG("Command received %d", cmd);
-
-                                       if (!rep.getValue("device_id", requester_id))
-                                               LOG_ERR("device_id not found in representation");
-                                       else
-                                               LOG_DEBUG("device_id received %s", requester_id.c_str());
-
-                                       switch(cmd) {
-                                       case MDGD_REQ_SEND_DATA:
-                                               LOG_DEBUG("Receive Data");
-#ifdef SUPPORT_BASE64_ENCODING
-                                               if (!rep.getValue("data", data))
-                                                       LOG_ERR("data not found");
-
-                                               /*
-                                                * BASE64 encoding/decoding system use '=' as padding byte
-                                                * But, query parameter does not allow use '=' character.Basically,
-                                                * So, in order to use BASE64 as query parameters, we need additioinal length param
-                                                * such as 'len=xx'
-                                                */
-                                               payload_len = strlen(data.c_str()); /* This data may be cliped the last padding 1~2 bytes ('='/'==') */
-
-                                               LOG_DEBUG("data = %s payload_len = %d", data.c_str(),
-                                                                 payload_len);
-
-                                               outSize = B64DECODE_OUT_SAFESIZE(payload_len + 1);
-                                               out = (uint8_t *)g_try_malloc0(outSize);
-                                               if (NULL == out) {
-                                                       LOG_ERR("Can't allocate memory for base64 str");
-                                                       return OC_EH_OK;
-                                               }
-
-                                               if (B64_OK != b64Decode(data.c_str(), payload_len, out,
-                                                                                          outSize, &len)) {
-                                                       LOG_ERR("Base64 decoding failed.");
-                                                       g_free(out);
-                                                       return OC_EH_OK;
-                                               }
-
-                                               arg = (unsigned char *) g_try_malloc0(len);
-                                               memcpy(arg, out, len);
-                                               arg_len = len;
-
-                                               g_free(out);
-
-                                               LOG_DEBUG("Successfully decoded from base64");
-#else
-                                               if (!rep.getValue("data", data))
-                                                       LOG_ERR("data not found");
-
-                                               LOG_DEBUG("Receive Data = %s", data.c_str());
-                                               arg = (unsigned char *) g_strdup(data.c_str());
-                                               arg_len = strlen(data.c_str());
-#endif
-                                               break;
-                                       case MDGD_REQ_CREATE_GROUP:
-                                               LOG_DEBUG("Request create group");
-
-                                               result = MDGD_ERROR_NONE;
-
-                                               if (rep.getValue("name", group_name)) {
-                                                       LOG_DEBUG("group_name : %s", group_name.c_str());
-                                                       if (mdgd_check_group_exist(group_name.c_str()))
-                                                               LOG_DEBUG("Group already created");
-                                                       else {
-                                                               result = mdgd_group_create(group_name.c_str());
-                                                               if (result == 0)
-                                                                       mdgd_db_group_insert(group_name.c_str());
-                                                       }
-                                                       arg = (unsigned char *) g_strdup(group_name.c_str());
-                                                       arg_len = strlen(group_name.c_str());
-                                               }
-                                               break;
-                                       case MDGD_REQ_INVITE_DEVICE:
-                                               LOG_DEBUG("Request invite device");
-
-                                               if (!rep.getValue("name", group_name))
-                                                       LOG_ERR("Group name not found");
-                                               if (!rep.getValue("id", uuid))
-                                                       LOG_ERR("UUID not found");
-
-                                               LOG_DEBUG("group name : %s, UUID : %s", group_name.c_str(),
-                                                                 uuid.c_str());
-
-                                               result = mdgd_group_invite(group_name.c_str(),
-                                                                          uuid.c_str(), "12341234");
-                                               if (result == 0)
-                                                       mdgd_db_device_insert(uuid.c_str(), group_name.c_str());
-                                               arg = (unsigned char *) g_strdup(uuid.c_str());
-                                               arg_len = strlen(uuid.c_str());
-                                               break;
-                                       case MDGD_REQ_EJECT_DEVICE:
-                                               LOG_DEBUG("Request eject device");
-
-                                               mdgd_ctx = mdgd_context_get_context();
-
-                                               if (!rep.getValue("name", group_name))
-                                                       LOG_ERR("Group name not found");
-                                               if (!rep.getValue("id", uuid))
-                                                       LOG_ERR("UUID not found");
-
-                                               LOG_DEBUG("group name : %s Self UUID : %s Target UUID : %s",
-                                                                 group_name.c_str(),mdgd_ctx->device_uuid,
-                                                                 uuid.c_str());
-
-                                               result = mdgd_group_eject(group_name.c_str(), mdgd_ctx->device_uuid,
-                                                                          uuid.c_str());
-                                               arg = (unsigned char *) g_strdup(uuid.c_str());
-                                               arg_len = strlen(uuid.c_str());
-                                               break;
-                                       case MDGD_REQ_DELETE_GROUP:
-                                               LOG_DEBUG("Request delete group");
-                                               arg = (unsigned char *) g_strdup("DELETED");
-                                               arg_len = strlen("DELETED");
-                                               break;
-                                       case MDGD_REQ_KEEP_ALIVE:
-                                               LOG_DEBUG("Keep Alive message");
-
-                                               if (rep.getValue("group_name", group_name)) {
-                                                       LOG_DEBUG("group_name : %s", group_name.c_str());
-                                               }
-                                               break;
-                                       default:
-                                               LOG_ERR("Unknown request command %d", cmd);
-                                               break;
-                                       }
-
-                                       if (cmd != MDGD_REQ_KEEP_ALIVE) {
-                                               const char *cmd_str;
-                                               cmd_str = command2string((mdgd_request_type_e) cmd);
-                                               notify_request_result(cmd_str, requester_id.c_str(), arg,
-                                                                                         arg_len, result);
-                                       }
-
-                                       g_free(arg);
-
-                                       pResponse->setRequestHandle(request->getRequestHandle());
-                                       pResponse->setResourceHandle(request->getResourceHandle());
-                                       pResponse->setErrorCode(200);
-                                       pResponse->setResponseResult(OC_EH_OK);
-                                       OCPlatform::sendResponse(pResponse);
-                               } catch (std::exception& e) {
-                                       LOG_ERR("Exceptioin occured %s", e.what());
-                               }
-                       }
-               } else {
-                       LOG_ERR("Invalid Request Type");
-                       return OC_EH_OK;
-               }
-       }
-
-       return OC_EH_OK;
-}
-
-int mdgd_iot_add_resource(mdgd_resource_type_e resource_type, const char *uri)
-{
-       OCResourceHandle resourceHandle;
-       std::string uri_path;
-
-       uri_path =  std::string(mdgd_resource_get_uri_prefix(resource_type)) +
-                               std::string(uri);
-
-       LOG_DEBUG("[ADD] resource uri is %s", uri_path.c_str());
-
-       OCStackResult result = OCPlatform::registerResource(resourceHandle,
-                                                       uri_path,
-                                                       std::string(mdgd_resource_get_type(resource_type)),
-                                                       std::string(DEFAULT_INTERFACE), &_request_handler,
-                                                       mdgd_resource_get_policies(resource_type));
-       if (result != OC_STACK_OK) {
-               LOG_ERR("Failed to create resource");
-               return MDGD_ERROR_NONE;
-       }
-
-       LOG_DEBUG("Successfully created resource");
-
-       //Append to resource list
-       mdgd_resource_append(resource_type, uri_path.c_str());
-
-       return MDGD_ERROR_NONE;
-}
-
-int found_group_count = 0;
-
-static void _clear_user_data(void *user_data)
-{
-       mdgd_command_t *cmd = (mdgd_command_t *)user_data;
-
-       if (NULL == cmd)
-               return;
-
-       if (cmd->tid) {
-               g_source_remove(cmd->tid);
-       }
-
-       if (cmd->uuid) {
-               g_free(cmd->uuid);
-               cmd->uuid = NULL;
-       }
-       if (cmd->host) {
-               g_free(cmd->host);
-               cmd->host = NULL;
-       }
-       if (cmd->arg1) {
-               g_free(cmd->arg1);
-               cmd->arg1 = NULL;
-       }
-       if (cmd->arg2) {
-               g_free(cmd->arg2);
-               cmd->arg2 = NULL;
-       }
-       if (cmd->arg3) {
-               g_free(cmd->arg3);
-               cmd->arg3 = NULL;
-       }
-       if (cmd->arg4) {
-               g_free(cmd->arg4);
-               cmd->arg4 = NULL;
-       }
-
-#ifdef SUPPORT_BASE64_ENCODING
-       if (cmd->data) {
-               g_free(cmd->data);
-               cmd->data = NULL;
-       }
-#endif
-
-       g_free(cmd);
-       cmd = NULL;
-}
-
-static void _on_post(const HeaderOptions& /*headerOptions*/,
-                                        const OCRepresentation& rep, const int eCode,
-                                        void *user_data)
-{
-       int ret;
-       mdgd_command_t *cmd = (mdgd_command_t *)user_data;
-
-       try {
-               if (eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CREATED ||
-                       eCode == OC_STACK_RESOURCE_CHANGED) {
-                       last_get_result = 0;
-                       LOG_DEBUG("Post request is successful");
-
-                       if (cmd->command == MDGD_REQ_KEEP_ALIVE) {
-                               mdgd_group_notify_keepalive_response(cmd);
-                               return;
-                       }
-               } else {
-                       last_get_result = eCode;
-                       LOG_ERR("_on_post Response error %d", eCode);
-               }
-       } catch(std::exception& e) {
-               LOG_ERR("Exception %s in on post", e.what());
-       }
-
-       notify_send_data_finish("RESP_DATA", last_get_result);
-
-       //_clear_user_data(cmd);
-}
-
-static void _on_get(const HeaderOptions& /*headerOptions*/,
-                               const OCRepresentation& rep, const int eCode,
-                               void *user_data)
-{
-       int ret;
-       LOG_DEBUG("On get function.");
-
-       try {
-               if (eCode == OC_STACK_OK || eCode == OC_STACK_RESOURCE_CREATED ||
-                       eCode == OC_STACK_RESOURCE_CHANGED) {
-                       gchar *key;
-                       GVariant *val;
-                       gsize len = 0;
-                       mdgd_mot_device_t *device = (mdgd_mot_device_t *)user_data;
-                       mdgd_check_null_ret("device", device);
-
-                       std::string modelName;
-                       std::string platformVer;
-                       std::string Profile;
-                       std::string deviceName;
-                       std::string vendorID;
-
-                       rep.getValue("model_name", modelName);
-                       rep.getValue("platform_ver", platformVer);
-                       rep.getValue("profile", Profile);
-                       rep.getValue("device_name", deviceName);
-                       rep.getValue("vendor_id", vendorID);
-
-                       mdgd_check_null_ret("modelName", modelName.c_str());
-                       mdgd_check_null_ret("platformVer", platformVer.c_str());
-                       mdgd_check_null_ret("Profile", Profile.c_str());
-                       mdgd_check_null_ret("deviceName", deviceName.c_str());
-                       mdgd_check_null_ret("vendorID", vendorID.c_str());
-
-                       device->model_name = g_strdup(modelName.c_str());
-                       device->platform_ver= g_strdup(platformVer.c_str());
-                       device->profile = g_strdup(Profile.c_str());
-                       device->device_name = g_strdup(deviceName.c_str());
-                       device->vendor_id = g_strdup(vendorID.c_str());
-
-                       if (device->mowned == false)
-                               mdgd_group_add_new_mot_device(device);
-                       else
-                               mdgd_group_add_new_mowned_device(device);
-               } else {
-                       LOG_ERR("_on_get Response error %d", eCode);
-               }
-       } catch(std::exception& e) {
-               LOG_ERR("Exception %s in on get", e.what());
-       }
-}
-
-static int _perform_mot_me(gpointer data)
-{
-       int ret;
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, FALSE);
-
-       ret = agent_mot(mdgd_ctx->device_uuid, "12341234");
-       if (ret != MDGD_ERROR_NONE)
-               LOG_ERR("agent_mot(%s) Failed", mdgd_ctx->device_uuid);
-
-       return FALSE;
-}
-
-static bool _found_resource(std::shared_ptr<OCResource> resource,
-                                                       void *user_data)
-{
-       int ret;
-       char *resource_uri_path;
-       char *resource_device_id = NULL;
-       char *resource_host;
-       char *resource_type = NULL;
-       mdgd_group_type_e group_type;
-       std::string resourceURI;
-       std::string hostAddress;
-
-       LOG_DEBUG("Found Resource");
-       try {
-               if (resource) {
-                       resource_host = g_strdup(resource->host().c_str());
-
-                       resource_uri_path = g_strdup(resource->uri().c_str());
-                       resource_device_id = g_strdup(resource->sid().c_str());
-
-                       LOG_DEBUG("Resource URI : %s", resource_uri_path);
-                       LOG_DEBUG("Host Address : %s", resource_host);
-
-                       LOG_DEBUG("Resource Device ID : %s", resource_device_id);
-
-                       for(auto &resourceTypes : resource->getResourceTypes()) {
-                               resource_type = g_strdup(resourceTypes.c_str());
-                               LOG_DEBUG("Resource Type : %s", resource_type);
-                       }
-
-                       if (g_strcmp0(resource_type, "core.comp.group") == 0) {
-                               mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-                               if (g_strcmp0(resource_device_id, mdgd_ctx->device_uuid) == 0)
-                                       group_type = MDGD_GROUP_GROUP_LOCAL;
-                               else
-                                       group_type = MDGD_GROUP_GROUP_REMOTE;
-
-                               char *temp = g_strdup(resource_uri_path);
-                               char *ptr = strtok(temp, "/");
-                               ptr = strtok(NULL, "/");
-                               ptr = strtok(NULL, "/");
-
-                               LOG_DEBUG("group name is %s", ptr);
-                               mdgd_group_add_new(resource_uri_path, resource_device_id, ptr,
-                                                                  resource_host, resource_type, group_type);
-                               found_group_count++;
-
-                               g_free(temp);
-
-                       } else if (g_strcmp0(resource_type, "core.comp.device") == 0) {
-                               mdgd_command_t *cmd = (mdgd_command_t *)user_data;
-                               GVariant *parameters = (GVariant *)cmd->user_data;
-                               GVariant *device_info;
-                               bool mowned;
-                               GVariantIter *iter = NULL;
-                               gchar *key;
-                               mdgd_mot_device_t *device = NULL;
-
-                               if (NULL == parameters) {
-                                       LOG_ERR("No Multiple Owned devices found");
-                                       return TRUE;
-                               }
-
-                               if (!strncmp(cmd->arg1, "disc_mot_enb_devs_done", strlen(cmd->arg1)))
-                                       mowned = false;
-                               else
-                                       mowned = true;
-
-                               g_variant_get(parameters, "(aa{sv})", &iter);
-                               while ((device_info = g_variant_iter_next_value(iter))) {
-                                       GVariant *val = g_variant_lookup_value(device_info, "deviceId", G_VARIANT_TYPE_STRING);
-                                       gsize len = 0;
-                                       const char *device_id = g_variant_get_string(val, &len);
-                                       if (g_strcmp0(resource_device_id, device_id) == 0) {
-                                               device = (mdgd_mot_device_t *)g_try_malloc0(sizeof(mdgd_mot_device_t));
-
-                                               LOG_DEBUG("deviceId = %s", device_id);
-                                               device->device_id = g_strdup(device_id);
-
-                                               val = g_variant_lookup_value(device_info, "adapter", G_VARIANT_TYPE_INT32);
-                                               int adapter = g_variant_get_int32(val);
-                                               device->adapter = adapter;
-
-                                               val = g_variant_lookup_value(device_info, "flags", G_VARIANT_TYPE_INT32);
-                                               int flags = g_variant_get_int32(val);
-                                               LOG_DEBUG("flags = %d", flags);
-                                               device->flags = flags;
-
-                                               val = g_variant_lookup_value(device_info, "port", G_VARIANT_TYPE_UINT16);
-                                               int port = g_variant_get_uint16(val);
-                                               LOG_DEBUG("port = %d", port);
-                                               device->port = port;
-
-                                               val = g_variant_lookup_value(device_info, "addr", G_VARIANT_TYPE_STRING);
-                                               const char *addr = g_variant_get_string(val, &len);
-                                               LOG_DEBUG("addr = %s", addr);
-                                               device->addr = g_strdup(addr);
-
-                                               val = g_variant_lookup_value(device_info, "ifindex", G_VARIANT_TYPE_INT32);
-                                               int ifindex = g_variant_get_int32(val);
-                                               LOG_DEBUG("ifindex = %d", ifindex);
-                                               device->ifindex = ifindex;
-
-                                               val = g_variant_lookup_value(device_info, "routeData", G_VARIANT_TYPE_STRING);
-                                               const char *routeData = g_variant_get_string(val, &len);
-                                               LOG_DEBUG("routeData = %s", routeData);
-                                               device->route_data = g_strdup(routeData);
-
-                                               val = g_variant_lookup_value(device_info, "remoteId", G_VARIANT_TYPE_STRING);
-                                               const char *remoteId = g_variant_get_string(val, &len);
-                                               LOG_DEBUG("remoteId = %s", remoteId);
-                                               device->remote_id = g_strdup(remoteId);
-
-                                               val = g_variant_lookup_value(device_info, "connType", G_VARIANT_TYPE_UINT32);
-                                               int connType = g_variant_get_uint32(val);
-                                               LOG_DEBUG("connType = %d", connType);
-                                               device->conn_type = connType;
-
-                                               val = g_variant_lookup_value(device_info, "securePort", G_VARIANT_TYPE_UINT16);
-                                               int securePort = g_variant_get_uint16(val);
-                                               LOG_DEBUG("securePort = %d", securePort);
-                                               device->secure_port = securePort;
-#ifdef WITH_TCP
-                                               val = g_variant_lookup_value(device_info, "tcpPort", G_VARIANT_TYPE_UINT16);
-                                               int tcpPort = g_variant_get_uint16(val);
-                                               LOG_DEBUG("tcpPort = %d", tcpPort);
-                                               device->tcp_port = tcpPort;
-#endif
-                                               val = g_variant_lookup_value(device_info, "secVer", G_VARIANT_TYPE_STRING);
-                                               const char *secVer = g_variant_get_string(val, &len);
-                                               LOG_DEBUG("secVer = %s", secVer);
-                                               device->sec_ver = g_strdup(secVer);
-
-                                               val = g_variant_lookup_value(device_info, "devStatus", G_VARIANT_TYPE_UINT32);
-                                               int devStatus = g_variant_get_uint32(val);
-                                               LOG_DEBUG("devStatus = %d", devStatus);
-                                               device->dev_status = devStatus;
-
-                                               device->mowned = mowned;
-                                       }
-                               }
-
-                               mdgd_check_null_ret_error("device", device, TRUE);
-
-                               if (strncmp(cmd->uuid, resource_device_id, strlen(cmd->uuid))) {
-                                       LOG_DEBUG("Get peer description from another device");
-                                       /* Get Peer Description using "Get" operation */
-                                       device->type = MDGD_GROUP_DEVICE_REMOTE;
-                                       resource->get(QueryParamsMap(), std::bind(&_on_get, std::placeholders::_1,
-                                               std::placeholders::_2, std::placeholders::_3, device));
-                               } else {
-                                       LOG_DEBUG("It's me. Get peer description myself");
-                                       device->type = MDGD_GROUP_DEVICE_LOCAL;
-
-                                       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-                                       if (mdgd_ctx && (FALSE == mdgd_ctx->mot_me)) {
-                                               g_timeout_add(10, _perform_mot_me, NULL);
-                                               mdgd_ctx->mot_me = TRUE;
-                                       }
-
-                                       char *device_name = NULL;
-                                       char *model_name = NULL;
-                                       char *platform_ver = NULL;
-                                       char *profile = NULL;
-                                       char *vendor_id = NULL;
-
-                                       system_settings_get_value_string(SYSTEM_SETTINGS_KEY_DEVICE_NAME, &device_name);
-                                       system_info_get_platform_string(SYSTEM_INFO_MODEL_NAME, &model_name);
-                                       system_info_get_platform_string(SYSTEM_INFO_PLATFORM_VERSION, &platform_ver);
-                                       system_info_get_platform_string(SYSTEM_INFO_PROFILE, &profile);
-                                       /* How to get the vendor id? */
-
-                                       device->model_name = g_strdup(device_name);
-                                       device->platform_ver= g_strdup(model_name);
-                                       device->profile = g_strdup(platform_ver);
-                                       device->device_name = g_strdup(profile);
-                                       device->vendor_id = g_strdup("6FFF");
-
-                                       mdgd_group_change_mowned_device(device);
-                               }
-                       } else if (g_strcmp0(resource_type, "core.comp.data") == 0) {
-                               mdgd_command_t *cmd = (mdgd_command_t *)user_data;
-
-                               LOG_DEBUG("Resource Type %s", resource_type);
-                               LOG_DEBUG("Command Device ID: %s", cmd ? cmd->uuid : "NULL");
-
-                               if (cmd != NULL && !strncmp(cmd->uuid, resource_device_id, strlen(cmd->uuid))) {
-                                       OCRepresentation rep;
-
-                                       LOG_DEBUG("Request to Remote Device");
-
-                                       LOG_DEBUG("CMD = %s", command2string(cmd->command));
-
-                                       rep.setValue("CMD", cmd->command);
-
-                                       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-                                       rep.setValue("device_id", std::string(mdgd_ctx->device_uuid));
-
-                                       if (cmd->command == MDGD_REQ_CREATE_GROUP) { //request create group
-                                               rep.setValue("name", std::string(cmd->arg1));
-                                       } else if (cmd->command == MDGD_REQ_INVITE_DEVICE) { //request invite
-                                               rep.setValue("name", std::string(cmd->arg1));
-                                               rep.setValue("id", std::string(cmd->arg2));
-                                               rep.setValue("PIN", std::string(cmd->arg3));
-                                       } else if (cmd->command == MDGD_REQ_EJECT_DEVICE) { //request eject
-                                               rep.setValue("name", std::string(cmd->arg1));
-                                               rep.setValue("id", std::string(cmd->arg2));
-                                       } else if (cmd->command == MDGD_REQ_DELETE_GROUP) { //request delete group
-                                               rep.setValue("name", std::string(cmd->arg1));
-                                       } else { /* Send Data */
-#ifdef SUPPORT_BASE64_ENCODING
-                                               uint32_t outSize = 0;
-                                               size_t b64BufSize = B64ENCODE_OUT_SAFESIZE(
-                                                                          (cmd->data_len + 1));
-                                               char *b64Buf = (char *) g_malloc0(b64BufSize);
-                                               if (NULL == b64Buf) {
-                                                       _clear_user_data(cmd);
-                                                       return TRUE;
-                                               }
-                                               b64Encode(cmd->data, cmd->data_len,
-                                                                 b64Buf, b64BufSize, &outSize);
-                                               b64Buf[b64BufSize] = '\0';
-                                               rep.setValue("data", std::string(b64Buf));
-                                               LOG_DEBUG("b64BufSize =%d outSize = %d b64Buf = %s",
-                                                                 b64BufSize, outSize, b64Buf);
-                                               g_free(b64Buf);
-#else
-                                               rep.setValue("data", std::string(cmd->arg1));
-#endif
-                                       }
-                                       resource->post(rep, QueryParamsMap(),
-                                                  std::bind (&_on_post, std::placeholders::_1,
-                                                  std::placeholders::_2, std::placeholders::_3, cmd));
-                               }
-                       }
-
-                       g_free(resource_uri_path);
-                       g_free(resource_host);
-                       g_free(resource_type);
-                       g_free(resource_device_id);
-               }
-               else {
-                       LOG_ERR("Resource is invalid");
-               }
-       }
-       catch(std::exception& e)
-       {
-               LOG_ERR("Exception in foundResource: %s", e.what());
-       }
-
-       return TRUE;
-}
-
-void __invite_device(gpointer data, gpointer user_data)
-{
-       int sql_ret = SQLITE_OK;
-       char *sql = NULL;
-       sqlite3_stmt *stmt = NULL;
-
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       mdgd_grp_t *grp = (mdgd_grp_t *)data;
-       LOG_DEBUG("Group name : %s", grp->name);
-
-       sql = sqlite3_mprintf("SELECT device_id FROM %s WHERE group_name=%Q;",
-                               MDGD_DB_DEVICE_TABLE, grp->name);
-
-       if (sql != NULL) {
-               sql_ret = sqlite3_prepare_v2(mdgd_ctx->db, sql, strlen(sql), &stmt, NULL);
-               if (sql_ret != SQLITE_OK) {
-                       LOG_ERR("Error: %s", sqlite3_errmsg(mdgd_ctx->db));
-                       sqlite3_free(sql);
-                       return;
-               }
-
-               do {
-                       sql_ret = sqlite3_step(stmt);
-                       if (sql_ret != SQLITE_ROW) {
-                               break;
-                       }
-
-                       char *device_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
-                       mdgd_mot_device_t *device = mdgd_group_check_device_in_mot_enb_dev_list(device_id);
-
-                       if (device != NULL)
-                               mdgd_group_add_device_in_group(grp->name, device_id);
-               } while (sql_ret != SQLITE_DONE);
-
-               sqlite3_finalize(stmt);
-               sqlite3_free(sql);
-       }
-}
-
-static gboolean _timeout_cb(gpointer data)
-{
-       int ret = -1;
-       mdgd_command_t *cmd = (mdgd_command_t *)data;
-
-       if (cmd->resource_type == MDGD_RESOURCE_TYPE_GROUP) {
-               if (found_group_count > 0)
-                       ret = 0;
-
-               notify_group_find_finish(ret);
-
-       } else if (cmd->resource_type == MDGD_RESOURCE_TYPE_DATA) {
-               if (cmd->command != MDGD_REQ_KEEP_ALIVE)
-                       notify_send_data_finish("RESP_DATA", last_get_result);
-       } else if (cmd->resource_type == MDGD_RESOURCE_TYPE_DEVICE) {
-               if (!strncmp(cmd->arg1, "disc_mot_enb_devs_done", strlen(cmd->arg1))) {
-                       LOG_DEBUG("Device Find Done. notified");
-                       if (mdgd_group_get_mot_device_count() > 0)
-                               ret = 0;
-
-                       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-                       if (mdgd_ctx->first_search == true) {
-                               if (ret == 0)
-                                       g_list_foreach(mdgd_ctx->grp_list, __invite_device, NULL);
-                               mdgd_ctx->first_search = false;
-                       } else {
-                               mdgd_group_notify_mot_enable_device_done();
-                               notify_device_find_finish(ret);
-                       }
-               } else {
-                       LOG_DEBUG("MOT Device Find Done. notified");
-                       mdgd_group_notify_mowned_device_find_done();
-
-                       if (mdgd_group_get_mowned_device_count() > 0)
-                               ret = 0;
-
-                       notify_mowned_device_find_finish(ret);
-               }
-       }
-
-       _clear_user_data(data);
-
-       return false;
-}
-
-int mdgd_iot_discovery_resource(mdgd_resource_type_e resource_type, int timeout,
-       void *user_data)
-{
-       int ret;
-       std::ostringstream requestURI;
-       mdgd_command_t *cmd = (mdgd_command_t *) user_data;
-       mdgd_check_null_ret_error("cmd", cmd, MDGD_ERROR_INVALID_PARAMETER);
-
-       found_group_count = 0;
-
-       try {
-               requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=" <<
-                       mdgd_resource_get_type(resource_type);
-
-               auto found_cb = std::bind (&_found_resource, std::placeholders::_1,
-                                                                  cmd);
-               if (cmd) {
-                       LOG_DEBUG("Querying for Resource host address  %s",
-                                         cmd->host ? cmd->host : "NULL");
-
-                       if (cmd->host)
-                               ret = OCPlatform::findResource(cmd->host, requestURI.str(),
-                                                                                          CT_ADAPTER_IP,
-                                                                                          found_cb);
-                       else
-                               ret = OCPlatform::findResource("", requestURI.str(),
-                                                                                          CT_ADAPTER_IP,
-                                                                                          found_cb);
-               }
-       } catch (OCException &e) {
-               LOG_ERR("Failed to find resource %s", e.what());
-               ret = e.code();
-       }
-
-       cmd->resource_type = resource_type;
-       cmd->tid = g_timeout_add_seconds(timeout + 1, _timeout_cb, cmd);
-
-       LOG_DEBUG("find resource : %s", get_error_message(ret));
-
-       return ret;
-}
-
-int mdgd_iot_send_data(mdgd_resource_type_e resource_type, int timeout,
-                                          mdgd_command_t *cmd)
-{
-       int ret;
-       OCResource::Ptr resource;
-       std::string requestURI;
-       std::vector<std::string> ifaces = {DEFAULT_INTERFACE};
-       std::vector<std::string> resource_types;
-       resource_types = {mdgd_resource_get_type(resource_type)};
-
-       try {
-               requestURI = std::string(mdgd_resource_get_uri_prefix(resource_type)) +
-                                                       "1";
-
-               LOG_DEBUG("Request URI %s", requestURI.c_str());
-
-               resource = OCPlatform::constructResourceObject(std::string(cmd->host),
-                                                          requestURI, CT_ADAPTER_IP, false,
-                                                          resource_types, ifaces);
-               if (!resource) {
-                       LOG_ERR("Failed to construct resource");
-                       return -1;
-               }
-
-               OCRepresentation rep;
-               rep.setValue("CMD", cmd->command);
-
-               mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-               rep.setValue("device_id", std::string(mdgd_ctx->device_uuid));
-
-#ifdef SUPPORT_BASE64_ENCODING
-               uint32_t outSize = 0;
-               size_t b64BufSize;
-               char *b64Buf;
-#endif
-               switch (cmd->command) {
-               case MDGD_REQ_SEND_DATA:
-#ifdef SUPPORT_BASE64_ENCODING
-                       b64BufSize = B64ENCODE_OUT_SAFESIZE((cmd->data_len + 1));
-                       b64Buf = (char *) g_try_malloc0(b64BufSize + 1);
-                       if (NULL == b64Buf) {
-                               _clear_user_data(cmd);
-                               return TRUE;
-                       }
-                       b64Encode(cmd->data, cmd->data_len,
-                                         b64Buf, b64BufSize, &outSize);
-                       rep.setValue("data", std::string(b64Buf));
-                       LOG_DEBUG("b64BufSize =%d outSize = %d b64Buf = %s",
-                                         b64BufSize, outSize, b64Buf);
-                       g_free(b64Buf);
-#else
-                       rep.setValue("data", std::string(cmd->arg1));
-#endif
-                       break;
-               case MDGD_REQ_CREATE_GROUP:
-               case MDGD_REQ_DELETE_GROUP:
-                       rep.setValue("name", std::string(cmd->arg1));
-                       break;
-               case MDGD_REQ_INVITE_DEVICE:
-                       rep.setValue("name", std::string(cmd->arg1));
-                       rep.setValue("id", std::string(cmd->arg2));
-                       rep.setValue("PIN", std::string(cmd->arg3));
-                       break;
-               case MDGD_REQ_EJECT_DEVICE:
-                       rep.setValue("name", std::string(cmd->arg1));
-                       rep.setValue("id", std::string(cmd->arg2));
-                       break;
-               case MDGD_REQ_KEEP_ALIVE:
-                       rep.setValue("group_name", std::string(cmd->arg1));
-                       break;
-               default:
-                       LOG_ERR("Invalid command %d", cmd->command);
-                       return -1;
-               }
-
-               ret = resource->post(rep, QueryParamsMap(),
-                                                  std::bind (&_on_post, std::placeholders::_1,
-                                                  std::placeholders::_2, std::placeholders::_3, cmd));
-
-       } catch (OCException &e) {
-               LOG_ERR("Failed to send data %s", e.what());
-               ret = e.code();
-       }
-
-       cmd->resource_type = resource_type;
-       cmd->tid = g_timeout_add_seconds(timeout + 1, _timeout_cb, cmd);
-
-       LOG_DEBUG("Send Data : %s", get_error_message(ret));
-
-       return ret;
-}
-
-int mdgd_iot_delete_resource(mdgd_resource_type_e resource_type)
-{
-       //delete resource from resource list using resource_type and index
-       //delete DB
-       return MDGD_ERROR_NONE;
-}
-
-int mdgd_iot_deinitialize()
-{
-       return MDGD_ERROR_NONE;
-}
diff --git a/src/mdg-manager/src/mdgd_log.c b/src/mdg-manager/src/mdgd_log.c
deleted file mode 100644 (file)
index 71c75d0..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2018 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 <mdgd_log.h>
-
-const char *mdgd_log_get_error_string(int result)
-{
-       switch (result) {
-       case MDGD_ERROR_NONE:
-               return "MDGD_ERROR_NONE";
-       case MDGD_ERROR_IO_ERROR:
-               return "MDGD_ERROR_IO_ERROR";
-       case MDGD_ERROR_INVALID_PARAMETER:
-               return "MDGD_ERROR_INVALID_PARAMETER";
-       case MDGD_ERROR_OUT_OF_MEMORY:
-               return "MDGD_ERROR_OUT_OF_MEMORY";
-       case MDGD_ERROR_PERMISSION_DENIED:
-               return "MDGD_ERROR_PERMISSION_DENIED";
-       case MDGD_ERROR_NOT_SUPPORTED:
-               return "MDGD_ERROR_NOT_SUPPORTED";
-       case MDGD_ERROR_NO_DATA:
-               return "MDGD_ERROR_NO_DATA";
-       case MDGD_ERROR_OPERATION_FAILED:
-               return "MDGD_ERROR_OPERATION_FAILED";
-       case MDGD_ERROR_ALREADY_REGISTERED:
-               return "MDGD_ERROR_ALREADY_REGISTERED";
-       case MDGD_ERROR_IN_PROGRESS:
-               return "MDGD_ERROR_IN_PROGRESS";
-       case MDGD_ERROR_COMM_ERROR:
-               return "MDGD_ERROR_COMM_ERROR";
-       case MDGD_ERROR_RX:
-               return "MDGD_ERROR_RX";
-       case MDGD_ERROR_TX:
-               return "MDGD_ERROR_TX";
-       case MDGD_ERROR_PLUGIN_FAIL:
-               return "MDGD_ERROR_PLUGIN_FAIL";
-       case MDGD_ERROR_ALREADY_IN_PROGRESS:
-               return "MDGD_ERROR_ALREADY_IN_PROGRESS";
-       case MDGD_ERROR_ALREADY_INITIALIZED:
-               return "MDG_ERROR_ALREADY_INITIALIZED";
-       default:
-               return "UNKNOWN";
-       }
-}
diff --git a/src/mdg-manager/src/mdgd_manager.c b/src/mdg-manager/src/mdgd_manager.c
deleted file mode 100644 (file)
index c62b1d4..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2018 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 <mdgd_manager.h>
-#include <mdgd_mot_agent.h>
-
-int main(int argc, char *argv[])
-{
-       int ret;
-
-       LOG_DEBUG("COMP Manager start");
-
-       //1. create & get context
-       ret = mdgd_context_create();
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("COMP context create failed : %s", mdgd_log_get_error_string(ret));
-               goto EXIT;
-       }
-
-       //2. iotivity iniatlize
-       ret = mdgd_iot_initialize();
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("COMP iot initialize failed : %s", mdgd_log_get_error_string(ret));
-               goto EXIT;
-       }
-
-       //3. Initializing Data
-       ret = mdgd_db_init();
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("COMP db initialize failed : %s", mdgd_log_get_error_string(ret));
-               goto EXIT;
-       }
-
-       //4. dbus interface initialize
-       ret = mdgd_gdbus_init();
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("COMP gdbus initialize failed : %s", mdgd_log_get_error_string(ret));
-               goto EXIT;
-       }
-
-       //7. operation mgr initialize
-       ret = agent_dbus_start();
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("MOT agent interface initialize failed : %s",
-                       mdgd_log_get_error_string(ret));
-               goto EXIT;
-       }
-       agent_enable();
-
-       //example code
-       //6. group mgr initialize
-       ret = mdgd_group_initialize();
-       if (ret != MDGD_ERROR_NONE) {
-               LOG_ERR("COMP group initialize failed : %s", mdgd_log_get_error_string(ret));
-               goto EXIT;
-       }
-
-       //8. g main loop run
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       mdgd_check_null_ret_error("mdgd_ctx", mdgd_ctx, MDGD_ERROR_INVALID_PARAMETER);
-
-       mdgd_ctx->main_loop = g_main_loop_new(NULL, FALSE);
-       g_main_loop_run(mdgd_ctx->main_loop);
-
-EXIT:
-       //9. deinitialize phase
-       agent_disable();
-       ret = agent_dbus_stop();
-       if (ret != MDGD_ERROR_NONE)
-               LOG_ERR("MOT agent interface deinitialize failed : %s",
-                       mdgd_log_get_error_string(ret));
-
-       ret = mdgd_group_deinitialize();
-       if (ret != MDGD_ERROR_NONE)
-               LOG_ERR("COMP group deinitialize failed : %s", mdgd_log_get_error_string(ret));
-
-       ret = mdgd_db_deinit();
-       if (ret != MDGD_ERROR_NONE)
-               LOG_ERR("COMP db deinitialize failed : %s", mdgd_log_get_error_string(ret));
-
-       ret = mdgd_iot_deinitialize();
-       if (ret != MDGD_ERROR_NONE)
-               LOG_ERR("COMP iot deinitialize failed : %s", mdgd_log_get_error_string(ret));
-
-       ret = mdgd_context_destroy();
-       if (ret != MDGD_ERROR_NONE)
-               LOG_ERR("COMP context destroy failed : %s", mdgd_log_get_error_string(ret));
-
-       LOG_DEBUG("COMP Manager exit");
-
-       return 0;
-}
diff --git a/src/mdg-manager/src/mdgd_mot_agent.c b/src/mdg-manager/src/mdgd_mot_agent.c
deleted file mode 100644 (file)
index 16911bd..0000000
+++ /dev/null
@@ -1,824 +0,0 @@
-/*
- * Copyright (c) 2018 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 <stdio.h>
-#include <stdlib.h>
-#include <error.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <mdgd_log.h>
-#include <mdgd_enum.h>
-#include <mdgd_group.h>
-#include <mdgd_gdbus_group.h>
-
-#define AGENT_SERVER_NAME "net.ma"
-#define AGENT_OBJECT_PATH "/net/ma"
-#define AGENT_SERVICE_INTERFACE "net.ma"
-
-#define AGENT_ENABLER_NAME "net.ma.enabler"
-#define AGENT_ENABLER_OBJ_PATH "/net/ma/enabler"
-#define AGENT_ENABLER_INTERFACE "net.ma.enabler"
-
-#define AGENT_DBUS_PROXY_TIMEOUT ((9.5 + 2) * 1000) /**< default timeout for GDBus */
-
-struct agent_s {
-       GDBusProxy *gproxy_agent_service; /**< Proxy for MOT agent */
-       gpointer dbus_connection; /**< Dbus connection for MOT agent */
-       GCancellable *ca; /**< Cancellable for MOT agent */
-       GList *dbus_sub_ids; /**< DBus ID for MOT agent */
-};
-struct agent_s agent; /**< MOT agent context */
-
-#ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
-static bool mot_dev2 = false;
-static char *device_uuid1 = NULL;
-static char *device_uuid2 = NULL;
-#endif
-
-static int _check_agent_vaild(void)
-{
-       if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
-               LOG_ERR("I/O error");
-               return MDGD_ERROR_IO_ERROR;
-       }
-       return MDGD_ERROR_NONE;
-}
-
-int agent_get_ownerid(char* deviceid)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "get_ownerid",
-                       NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(si)", deviceid, &result);
-               LOGD("get_ownerid status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_find_mot_enable_devices(int timeout)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_UNKNOWN;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "disc_mot_enb_devs",
-                               g_variant_new("(i)", timeout), G_DBUS_CALL_FLAGS_NONE,  -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOGD("disc_mot_enb_devs status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_find_mowned_devices(int timeout)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_UNKNOWN;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "disc_mowned_devs",
-                               g_variant_new("(i)", timeout), G_DBUS_CALL_FLAGS_NONE,  -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOGD("disc_mowned_devs status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_mot(char* uuid_str, char *pin)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "mot",
-                       g_variant_new("(ss)", uuid_str, pin), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOGD("mot status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_resources_pairwise(char* target1, char *subject1, char *uri1,
-       char *rt1, char *interface1, int permission1, char* target2, char *subject2, char *uri2,
-       char *rt2, char *interface2, int permission2)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "pairwise",
-                       g_variant_new("(sssssisssssi)",
-                               target1, subject1, uri1, rt1, interface1, permission1,
-                               target2, subject2, uri2, rt2, interface2, permission2),
-                               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOGD("pairwise status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_unlink_resources(char* uuid_str1, char *uuid_str2)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "unlink",
-                       g_variant_new("(ss)", uuid_str1, uuid_str2), G_DBUS_CALL_FLAGS_NONE,
-                       -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOGD("remove_subowner status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-#ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
-       if (result == MDGD_ERROR_NONE) {
-               device_uuid1 = g_strdup(uuid_str1);
-               device_uuid2 = g_strdup(uuid_str2);
-       }
-#endif
-       return result;
-}
-
-int agent_remove_subowner(char* uuid_str)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "remove_subowner",
-                       g_variant_new("(s)", uuid_str), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOGD("remove_subowner status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_remove_subowned(char* uuid_str)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "remove_device",
-                       g_variant_new("(s)", uuid_str), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOGD("remove_cred_cocal status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_pair(const char *pin, char* target1, const char *subject1, char *uri1,
-       char *rt1, char *interface1, int permission1, const char* target2,
-       char *subject2, char *uri2, char *rt2, char *interface2, int permission2)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "pair",
-                       g_variant_new("(ssssssisssssi)", pin,
-                               target1, subject1, uri1, rt1, interface1, permission1,
-                               target2, subject2, uri2, rt2, interface2, permission2),
-                               G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOGD("pair status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_unpair(char* uuid_str1, const char *uuid_str2)
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "unpair",
-                       g_variant_new("(ss)", uuid_str1, uuid_str2), G_DBUS_CALL_FLAGS_NONE,
-                       -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOGD("remove_subowner status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_enable()
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_connection_call_sync(agent.dbus_connection,
-                       AGENT_ENABLER_NAME, AGENT_ENABLER_OBJ_PATH, AGENT_ENABLER_INTERFACE,
-                       "enable", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOG_DEBUG("MOT Agent Enabled status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-
-       return result;
-}
-
-int agent_disable()
-{
-       GVariant *variant = NULL;
-       int result = MDGD_ERROR_NONE;
-       GError *error = NULL;
-
-       result = _check_agent_vaild();
-       if (MDGD_ERROR_NONE != result)
-               return result;
-
-       variant = g_dbus_connection_call_sync(agent.dbus_connection,
-                       AGENT_ENABLER_NAME, AGENT_ENABLER_OBJ_PATH, AGENT_ENABLER_INTERFACE,
-                       "disable", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-       if (variant) {
-               g_variant_get(variant, "(i)", &result);
-               LOG_DEBUG("MOT Agent Disabled status 0x%x", result);
-       } else if (error) {
-               LOGE("Failed DBus call [%s]", error->message);
-               g_error_free(error);
-               /* Restart mot-agent */
-               agent_enable();
-               result = MDGD_ERROR_IO_ERROR;
-       }
-       return result;
-}
-
-static int _close_gdbus_call()
-{
-       /* CHECK: is connection ref count required? */
-       g_object_unref(agent.dbus_connection);
-       agent.dbus_connection = NULL;
-
-       return MDGD_ERROR_NONE;
-}
-
-static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec,
-               gpointer *userdata)
-{
-       GDBusProxy *proxy = G_DBUS_PROXY(object);
-       gchar *name_owner = g_dbus_proxy_get_name_owner(proxy);
-
-       NOTUSED(userdata);
-
-       LOG_DEBUG("Name owner notify [%s]", name_owner);
-
-       if (NULL == name_owner)
-               _close_gdbus_call();
-
-       g_free(name_owner);
-}
-
-static int _create_gdbus_call()
-{
-       int id;
-       GError *error = NULL;
-
-       if (agent.dbus_connection != NULL)
-               return MDGD_ERROR_ALREADY_IN_PROGRESS;
-
-       agent.dbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-       if (NULL == agent.dbus_connection) {
-               if (error != NULL) {
-                       LOG_ERR("Failed to connect to the D-BUS daemon [%s]", error->message);
-                       g_error_free(error);
-               }
-               return MDGD_ERROR_IO_ERROR;
-       }
-
-       id = g_signal_connect(agent.dbus_connection, "notify::g-name-owner",
-                       G_CALLBACK(_dbus_name_owner_notify), &agent);
-       if (0 == id) {
-               LOGE("g_signal_connect() Fail");
-               g_object_unref(agent.dbus_connection);
-               agent.dbus_connection = NULL;
-               return MDGD_ERROR_IO_ERROR;
-       }
-
-       return MDGD_ERROR_NONE;
-}
-
-static GDBusProxy *_get_proxy_service()
-{
-       GDBusProxy *proxy = NULL;
-
-       if (NULL == agent.gproxy_agent_service) {
-               proxy = g_dbus_proxy_new_sync(agent.dbus_connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
-                       AGENT_SERVER_NAME, AGENT_OBJECT_PATH, AGENT_SERVICE_INTERFACE,
-                       NULL, NULL);
-       } else
-               proxy = agent.gproxy_agent_service;
-
-       return proxy;
-}
-
-#ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
-static gboolean __perform_agent_pairwise(gpointer data)
-{
-       int ret;
-
-       mot_dev2 = false;
-
-       mdgd_group_invite_info_t *group_invite_info;
-
-       group_invite_info = mdgd_group_get_invite_info();
-       mdgd_check_null_ret_error("group_invite_info", group_invite_info, FALSE);
-
-       ret = agent_pairwise(group_invite_info->uuid_dev1, group_invite_info->uuid_dev2,
-                                                group_invite_info->uri_1, group_invite_info->rt_1,
-                                                group_invite_info->interface_1,
-                                                group_invite_info->permission_1,
-                                                group_invite_info->uuid_dev2, group_invite_info->uuid_dev1,
-                                                group_invite_info->uri_2, group_invite_info->rt_2,
-                                                group_invite_info->interface_2,
-                                                group_invite_info->permission_2);
-       if (ret != MDGD_ERROR_NONE)
-               mdgd_group_notify_group_invite(ret);
-
-       return FALSE;
-}
-
-static gboolean __perform_remove_mot_dev2(gpointer data)
-{
-       int ret;
-
-       ret = agent_remove_subowner(device_uuid2);
-       if (ret != MDGD_ERROR_NONE) {
-               mdgd_group_notify_group_dismiss(ret);
-               g_free(device_uuid1);
-               device_uuid1 = NULL;
-               g_free(device_uuid2);
-               device_uuid1 = NULL;
-       }
-
-       return FALSE;
-}
-
-static gboolean __perform_remove_cred_at_local(gpointer data)
-{
-       int ret;
-
-       ret = agent_remove_subowned(device_uuid2);
-       if (ret != MDGD_ERROR_NONE) {
-               mdgd_group_notify_group_dismiss(ret);
-               g_free(device_uuid1);
-               device_uuid1 = NULL;
-               g_free(device_uuid2);
-               device_uuid1 = NULL;
-       }
-       return FALSE;
-}
-#endif
-
-static void _agent_signal_handler(GDBusConnection *connection,
-               const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
-               const gchar *signal_name, GVariant *parameters, gpointer userdata)
-{
-       int result = MDGD_ERROR_NONE;
-       mdgd_check_null_ret("userdata", userdata);
-
-       LOG_DEBUG("signal received = %s", signal_name);
-
-       if (0 == g_strcmp0(signal_name, "subowner_enabled")) {
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-       } else if (0 == g_strcmp0(signal_name, "disc_mot_enb_devs_done") ||
-                               0 == g_strcmp0(signal_name, "disc_mowned_devs_done")) {
-
-               mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-               mdgd_check_null_ret("mdgd_ctx", mdgd_ctx);
-               mdgd_check_null_ret("parameters", parameters);
-
-               mdgd_command_t *cmd = g_new0(mdgd_command_t, 1);
-               mdgd_check_null_ret("cmd", cmd);
-
-               cmd->uuid = g_strdup(mdgd_ctx->device_uuid);
-               cmd->user_data = (void *)g_variant_ref(parameters);
-               cmd->arg1 = g_strdup(signal_name);
-
-               /* Start peer-discovery */
-               mdgd_iot_discovery_resource(MDGD_RESOURCE_TYPE_DEVICE, 2, cmd);
-               LOG_DEBUG("Peer description discovery Start");
-
-       } else if (0 == g_strcmp0(signal_name, "acl_done")) {
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-       } else if (0 == g_strcmp0(signal_name, "cred_done")) {
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-       } else if (0 == g_strcmp0(signal_name, "mot_done")) {
-#ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
-               mdgd_mot_device_t *device;
-               mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-               mdgd_check_null_ret("mdgd_ctx", mdgd_ctx);
-
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-
-               if (result != 0 && result != 49 &&
-                       (mdgd_group_get_invite_info() != NULL))
-                       mdgd_group_notify_group_invite(result);
-
-               if (mdgd_ctx && (TRUE == mdgd_ctx->mot_me))
-                       g_timeout_add(10, __perform_agent_pairwise, NULL);
-#endif
-       } else if (0 == g_strcmp0(signal_name, "remove_mo_done")) {
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-#ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
-               g_timeout_add(10, __perform_remove_cred_at_local, NULL);
-#endif
-       } else if (0 == g_strcmp0(signal_name, "remove_cred_local_done")) {
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-#ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
-               mdgd_group_notify_group_dismiss(result);
-               g_free(device_uuid1);
-               device_uuid1 = NULL;
-               g_free(device_uuid2);
-               device_uuid1 = NULL;
-#endif
-       } else if (0 == g_strcmp0(signal_name, "pairwise_done")) {
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-
-               if (mdgd_group_get_invite_info() != NULL)
-                       mdgd_group_notify_group_invite(result);
-       } else if (0 == g_strcmp0(signal_name, "unlink_done")) {
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-#ifdef INVITE_EJECT_DEVICE_BY_MULTI_RUN
-               if (result != 0) {
-                       mdgd_group_notify_group_dismiss(result);
-                       g_free(device_uuid1);
-                       device_uuid1 = NULL;
-                       g_free(device_uuid2);
-                       device_uuid1 = NULL;
-               }
-
-               g_timeout_add(10, __perform_remove_mot_dev2, NULL);
-#endif
-       } else if (0 == g_strcmp0(signal_name, "pair_done")) {
-
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-
-               mdgd_group_notify_group_invite(result);
-       } else if (0 == g_strcmp0(signal_name, "unpair_done")) {
-
-               g_variant_get(parameters, "(i)", &result);
-               LOG_DEBUG("Result : %d", result);
-
-               mdgd_group_notify_group_dismiss(result);
-       }
-}
-static int _subscribe_event()
-{
-       unsigned int id;
-       struct agent_s *h = &agent;
-
-       /* subowner_enabled */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "subowner_enabled", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(subowner_enabled) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (subowner_enabled) signal %d", id);
-
-       /* disc_mot_enb_devs_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "disc_mot_enb_devs_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(disc_mot_enb_devs_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (disc_mot_enb_devs_done) signal %d", id);
-
-       /* disc_mowned_devs_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "disc_mowned_devs_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(disc_mowned_devs_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (disc_mowned_devs_done) signal %d", id);
-
-       /* mot_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "mot_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(mot_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (mot_done) signal %d", id);
-
-       /* acl_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "acl_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(acl_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (acl_done) signal %d", id);
-
-       /*cred_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "cred_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(cred_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (cred_done) signal %d", id);
-
-       /*pairwise_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "pairwise_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(pairwise_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (pairwise_done) signal %d", id);
-
-       /*unlink_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "unlink_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(unlink_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (unlink_done) signal %d", id);
-
-       /* remove_mo_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "remove_mo_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(remove_mo_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (remove_mo_done) signal %d", id);
-
-       /* remove_cred_local_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "remove_cred_local_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(remove_cred_local_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (remove_cred_local_done) signal %d", id);
-
-       /*pair_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "pair_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(pair_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (pair_done) signal %d", id);
-
-       /*unpair_done */
-       id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
-                       "unpair_done", AGENT_OBJECT_PATH, NULL,
-                       G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
-       if (0 == id) {
-               LOG_ERR("g_dbus_connection_signal_subscribe(unpair_done) Fail(%d)", errno);
-               return -1;
-       }
-       h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
-       LOG_DEBUG("subscribed for (unpair_done) signal %d", id);
-
-       return 0;
-}
-
-static void _on_unsubscribe_ids(gpointer data, gpointer userdata)
-{
-       unsigned int id = GPOINTER_TO_UINT(data);
-       struct agent_s *h = (struct agent_s*)userdata;
-       if (NULL == h) {
-               LOG_ERR("Invaild parameter");
-               return;
-       }
-       LOG_DEBUG("[Signal unsubscribe] : %d", id);
-       g_dbus_connection_signal_unsubscribe(h->dbus_connection, id);
-}
-static void _unsubscribe_event()
-{
-       g_list_foreach(agent.dbus_sub_ids, _on_unsubscribe_ids, &agent);
-       g_list_free(agent.dbus_sub_ids);
-       agent.dbus_sub_ids = NULL;
-}
-
-int agent_dbus_start()
-{
-       int ret = MDGD_ERROR_NONE;
-
-       ret = _create_gdbus_call();
-       if (MDGD_ERROR_NONE != ret)
-               return ret;
-
-       agent.ca = g_cancellable_new();
-
-       /* Create all proxies here */
-       agent.gproxy_agent_service = _get_proxy_service();
-       if (NULL == agent.gproxy_agent_service) {
-               LOG_ERR("Couldn't get _get_proxy_service");
-               return MDGD_ERROR_IO_ERROR;
-       }
-
-       g_dbus_proxy_set_default_timeout(
-               G_DBUS_PROXY(agent.gproxy_agent_service), AGENT_DBUS_PROXY_TIMEOUT);
-
-       /* Subscribe events */
-       _subscribe_event();
-
-       return MDGD_ERROR_NONE;
-}
-
-int agent_dbus_stop()
-{
-       int ret = MDGD_ERROR_NONE;
-
-       _unsubscribe_event();
-
-       /* Unref all proxies here */
-       if (agent.gproxy_agent_service) {
-               g_object_unref(agent.gproxy_agent_service);
-               agent.gproxy_agent_service = NULL;
-       }
-
-       g_cancellable_cancel(agent.ca);
-       g_object_unref(agent.ca);
-       agent.ca = NULL;
-
-       ret = _close_gdbus_call();
-       return ret;
-}
-
diff --git a/src/mdg-manager/src/mdgd_resource.c b/src/mdg-manager/src/mdgd_resource.c
deleted file mode 100644 (file)
index 122764f..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2018 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 <mdgd_resource.h>
-
-/* resource_type, type, uri, policies */
-static mdgd_rd_t mdgd_rds[] = {
-       {MDGD_RESOURCE_TYPE_GROUP, "core.comp.group", "/comp/group/",
-               OC_DISCOVERABLE | OC_OBSERVABLE},
-       {MDGD_RESOURCE_TYPE_DEVICE, "core.comp.device", "/comp/device",
-               OC_DISCOVERABLE | OC_OBSERVABLE},
-       {MDGD_RESOURCE_TYPE_OPERATION, "core.comp.operation", "/comp/operation/",
-               OC_DISCOVERABLE | OC_OBSERVABLE},
-       {MDGD_RESOURCE_TYPE_DATA, "core.comp.data", "/comp/data/",
-               OC_DISCOVERABLE | OC_OBSERVABLE | OC_SECURE},
-};
-
-int mdgd_resource_append(mdgd_resource_type_e resource_type, const char *uri)
-{
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-       GList *list = mdgd_ctx->resource_list[resource_type];
-
-       //append resource handle / name to list
-       mdgd_re_t *element = g_new0(mdgd_re_t, 1);
-       element->uri = g_strdup(uri);
-       list = g_list_append(list, element);
-
-       mdgd_ctx->resource_list[resource_type] = list;
-
-       return 0;
-}
-
-char *mdgd_resource_get_type(mdgd_resource_type_e resource_type)
-{
-       return mdgd_rds[resource_type].type;
-}
-
-char *mdgd_resource_get_uri_prefix(mdgd_resource_type_e resource_type)
-{
-       return mdgd_rds[resource_type].uri_prefix;
-}
-
-unsigned char mdgd_resource_get_policies(mdgd_resource_type_e resource_type)
-{
-       return mdgd_rds[resource_type].policies;
-}
-
-void __print_foreach_resource(gpointer data, gpointer user_data)
-{
-       mdgd_re_t *re = (mdgd_re_t *)data;
-       LOG_DEBUG("    ** uri : %s", re->uri);
-}
-
-void mdgd_resource_print_list()
-{
-       mdgd_context_t *mdgd_ctx = mdgd_context_get_context();
-
-       LOG_DEBUG("-------------------Print resource list-----------------------");
-
-       for (int i = 0; i < MDGD_RESOURCE_TYPE_MAX; i++) {
-               LOG_DEBUG("Resource type %d list length : %d",
-                       i, g_list_length(mdgd_ctx->resource_list[i]));
-               g_list_foreach(mdgd_ctx->resource_list[i], __print_foreach_resource, NULL);
-       }
-
-       LOG_DEBUG("-------------------Print resource list end-------------------");
-}
-
diff --git a/src/mdg-manager/src/mdgd_util.c b/src/mdg-manager/src/mdgd_util.c
deleted file mode 100644 (file)
index b9648f3..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (c) 2018 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <net/if.h>
-#include <sys/ioctl.h>
-#include <arpa/inet.h>
-#include <dirent.h>
-#include <glib.h>
-
-#include <mdgd_log.h>
-#include <mdgd_util.h>
-
-#define IPV6_ADDR_GLOBAL 0x0000U
-#define IPV6_ADDR_LOOPBACK 0x0010U
-#define IPV6_ADDR_LINKLOCAL 0x0020U
-#define IPV6_ADDR_SITELOCAL 0x0040U
-#define IPV6_ADDR_COMPATv4 0x0080U
-
-typedef struct _ipv4_info_s {
-       char *ifname; /**< Network interface name */
-       char *mac; /**< MAC address */
-       bool active; /**< interface active or not */
-       int mtu; /**< MTU size */
-       char *ip; /**< IPv4 address */
-       char *broadcast; /**< Broadcast address */
-       char *mask; /**< Net-mask */
-} ipv4_info_s;
-
-typedef struct _ipv6_info_s {
-       char *ifname; /**< Network interface name */
-       char *ip; /**< IPv6 address */
-       int prefix; /**< Prefix length  */
-       char *scope; /**< Scope */
-} ipv6_info_s;
-
-typedef struct _ip_info_s {
-       GList *ipv4_list; /**< IPv4 address list */
-       GList *ipv6_list; /**< IPv6 address list */
-} ip_info_s;
-
-ip_info_s g_ip_info; /**< Local IP address list */
-
-static void __free_ipv4_info(gpointer data)
-{
-       ipv4_info_s *ipv4info = (ipv4_info_s *)data;
-       if (NULL == data)
-               return;
-
-       if (ipv4info->ifname) {
-               free(ipv4info->ifname);
-               ipv4info->ifname = NULL;
-       }
-       if (ipv4info->mac) {
-               free(ipv4info->mac);
-               ipv4info->mac = NULL;
-       }
-       if (ipv4info->ip) {
-               free(ipv4info->ip);
-               ipv4info->ip = NULL;
-       }
-       if (ipv4info->broadcast) {
-               free(ipv4info->broadcast);
-               ipv4info->broadcast = NULL;
-       }
-       if (ipv4info->mask) {
-               free(ipv4info->mask);
-               ipv4info->mask = NULL;
-       }
-       free(ipv4info);
-       ipv4info = NULL;
-}
-
-static void __free_ipv6_info(gpointer data)
-{
-       ipv6_info_s *ipv6info = (ipv6_info_s *)data;
-       if (NULL == data)
-               return;
-
-       if (ipv6info->ifname) {
-               free(ipv6info->ifname);
-               ipv6info->ifname = NULL;
-       }
-       if (ipv6info->ip) {
-               free(ipv6info->ip);
-               ipv6info->ip = NULL;
-       }
-       if (ipv6info->scope) {
-               free(ipv6info->scope);
-               ipv6info->scope= NULL;
-       }
-       free(ipv6info);
-       ipv6info = NULL;
-}
-
-void mdgd_remove_ip_info(void)
-{
-       if (g_ip_info.ipv4_list) {
-               g_list_free_full(g_ip_info.ipv4_list, __free_ipv4_info);
-               g_ip_info.ipv4_list = NULL;
-       }
-       if (g_ip_info.ipv6_list) {
-               g_list_free_full(g_ip_info.ipv6_list, __free_ipv6_info);
-               g_ip_info.ipv6_list = NULL;
-       }
-}
-
-static void _parse_inet6(const char *ifname) {
-    FILE *f;
-    int scope, prefix;
-    unsigned char ipv6[16];
-    char dname[IFNAMSIZ];
-    char address[INET6_ADDRSTRLEN];
-    char *scopestr;
-
-    f = fopen("/proc/net/if_inet6", "r");
-    if (f == NULL) {
-               LOGE("Failed to access /proc/net/if_inet6");
-        return;
-    }
-
-    while (19 == fscanf(f," %2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx" \
-               "%2hhx%2hhx%2hhx%2hhx%2hhx %*x %x %x %*x %s",
-               &ipv6[0], &ipv6[1], &ipv6[2], &ipv6[3], &ipv6[4], &ipv6[5], &ipv6[6], &ipv6[7],
-               &ipv6[8], &ipv6[9], &ipv6[10], &ipv6[11], &ipv6[12], &ipv6[13], &ipv6[14],
-               &ipv6[15], &prefix, &scope, dname)) {
-
-        if (strcmp(ifname, dname) != 0)
-            continue;
-
-        if (inet_ntop(AF_INET6, ipv6, address, sizeof(address)) == NULL)
-            continue;
-
-               ipv6_info_s *_ipv6 = calloc(1, sizeof(ipv6_info_s));
-               if (NULL == _ipv6) {
-                       LOGE("Memory allocation failed");
-                        goto FINISH_READING_IPV6;
-               }
-               _ipv6->ifname = g_strdup(ifname);
-
-        switch (scope) {
-        case IPV6_ADDR_GLOBAL:
-            scopestr = "Global";
-            break;
-        case IPV6_ADDR_LINKLOCAL:
-            scopestr = "Link";
-            break;
-        case IPV6_ADDR_SITELOCAL:
-            scopestr = "Site";
-            break;
-        case IPV6_ADDR_COMPATv4:
-            scopestr = "Compat";
-            break;
-        case IPV6_ADDR_LOOPBACK:
-            scopestr = "Host";
-            break;
-        default:
-            scopestr = "Unknown";
-        }
-               _ipv6->ip = g_strdup(address); /* ex) fe80::212:34ff:fe5a:ec0e */
-               _ipv6->prefix = prefix; /* ex) 64 */
-               _ipv6->scope = g_strdup(scopestr); /* Link */
-
-               g_ip_info.ipv6_list = g_list_append(g_ip_info.ipv6_list, _ipv6);
-    }
-FINISH_READING_IPV6:
-    fclose(f);
-}
-
-static void _parse_ioctl(const char *ifname)
-{
-    int sock;
-    struct ifreq ifr;
-    struct sockaddr_in *ipaddr;
-    char address[INET_ADDRSTRLEN];
-    size_t ifnamelen;
-
-    /* copy ifname to ifr object */
-    ifnamelen = strlen(ifname);
-    if (ifnamelen >= sizeof(ifr.ifr_name)) {
-        return ;
-    }
-    memcpy(ifr.ifr_name, ifname, ifnamelen);
-    ifr.ifr_name[ifnamelen] = '\0';
-
-    /* open socket */
-    sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
-    if (sock < 0) {
-               LOGE("socket creation faild");
-        return;
-    }
-
-       ipv4_info_s *_ipv4 = calloc(1, sizeof(ipv4_info_s));
-       if (NULL == _ipv4) {
-               LOGE("Memory allocation failed");
-                goto FINISH_READING_IPV4;
-       }
-       _ipv4->ifname = g_strdup(ifname); /* ex) wlan0 */
-
-    /* process mac */
-    if (ioctl(sock, SIOCGIFHWADDR, &ifr) != -1) {
-               char buf[64] = {0,};
-               snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x",
-                       ifr.ifr_hwaddr.sa_data[0], ifr.ifr_hwaddr.sa_data[1],
-                       ifr.ifr_hwaddr.sa_data[2], ifr.ifr_hwaddr.sa_data[3],
-                       ifr.ifr_hwaddr.sa_data[4], ifr.ifr_hwaddr.sa_data[5]);
-               _ipv4->mac = g_strdup(buf); /* ex) 00:12:34:5a:ec:0e */
-    }
-
-    /* process mtu */
-    if (ioctl(sock, SIOCGIFMTU, &ifr) != -1) {
-               _ipv4->mtu = ifr.ifr_mtu; /* ex) 1492 */
-    }
-
-    /* die if cannot get address */
-    if (ioctl(sock, SIOCGIFADDR, &ifr) == -1) {
-               _ipv4->active = false;
-        goto FINISH_READING_IPV4;
-    }
-
-    /* process ip */
-    ipaddr = (struct sockaddr_in *)&ifr.ifr_addr;
-    if (inet_ntop(AF_INET, &ipaddr->sin_addr, address, sizeof(address)) != NULL) {
-               _ipv4->ip = g_strdup(address); /* ex) 192.168.86.111 */
-    }
-
-    /* try to get broadcast */
-    if (ioctl(sock, SIOCGIFBRDADDR, &ifr) != -1) {
-        ipaddr = (struct sockaddr_in *)&ifr.ifr_broadaddr;
-        if (inet_ntop(AF_INET, &ipaddr->sin_addr, address, sizeof(address)) != NULL) {
-                       _ipv4->broadcast = g_strdup(address); /* ex) 192.168.86.255 */
-        }
-    }
-
-    /* try to get mask */
-    if (ioctl(sock, SIOCGIFNETMASK, &ifr) != -1) {
-        ipaddr = (struct sockaddr_in *)&ifr.ifr_netmask;
-        if (inet_ntop(AF_INET, &ipaddr->sin_addr, address, sizeof(address)) != NULL) {
-                       _ipv4->mask = g_strdup(address); /* ex) 255.255.255.0 */
-        }
-    }
-FINISH_READING_IPV4:
-    close(sock);
-       g_ip_info.ipv4_list = g_list_append(g_ip_info.ipv4_list, _ipv4);
-}
-
-
-int mdgd_make_ip_info(void)
-{
-    DIR *d;
-    struct dirent *de;
-
-    d = opendir("/sys/class/net/");
-    if (d == NULL) {
-               LOGE("Failed to access /sys/class/net/");
-        return -1;
-    }
-
-    while (NULL != (de = readdir(d))) {
-        if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)
-            continue;
-
-        _parse_ioctl(de->d_name);
-        _parse_inet6(de->d_name);
-    }
-    closedir(d);
-
-    return 0;
-}
-
-int mdgd_is_local_ip(char *ipdata)
-{
-       char *ip = NULL;
-       char *ifname = NULL;
-       char *save_str = NULL;
-       char *addr = NULL;
-       GList *iter = NULL;
-       ipv6_info_s *ipv6info = NULL;
-       ipv4_info_s *ipv4info = NULL;
-
-       addr = g_strdup(ipdata);
-
-       ip = strtok_r(addr, "%", &save_str);
-       ifname = strtok_r(NULL, "%", &save_str);
-
-       iter = g_list_first(g_ip_info.ipv6_list);
-       while (NULL != iter) {
-               ipv6info = iter->data;
-               if (ipv6info && ipv6info->ip && !strncmp(ipv6info->ip, ip,
-                                                                                                INET6_ADDRSTRLEN)) {
-                       g_free(addr);
-                       return LOCAL_IP;
-               }
-               iter = g_list_next(iter);
-       }
-
-       iter = g_list_first(g_ip_info.ipv4_list);
-       while (NULL != iter) {
-               ipv4info = iter->data;
-               if (ipv4info && ipv4info->ip && !strncmp(ipv4info->ip, ip,
-                                                                                                INET_ADDRSTRLEN)) {
-                       g_free(addr);
-                       return LOCAL_IP;
-               }
-               iter = g_list_next(iter);
-       }
-
-       g_free(addr);
-       return REMOTE_IP;
-}
-
similarity index 100%
rename from capi/src/mdg.c
rename to src/mdg.c
similarity index 100%
rename from capi/src/mdg_dbus.c
rename to src/mdg_dbus.c
similarity index 100%
rename from capi/src/mdg_dbus.h
rename to src/mdg_dbus.h
similarity index 100%
rename from capi/src/mdg_debug.h
rename to src/mdg_debug.h
similarity index 100%
rename from capi/src/mdg_private.h
rename to src/mdg_private.h
similarity index 100%
rename from capi/src/mdg_util.c
rename to src/mdg_util.c
similarity index 100%
rename from capi/src/mdg_util.h
rename to src/mdg_util.h
diff --git a/src/mot-agent/CMakeLists.txt b/src/mot-agent/CMakeLists.txt
deleted file mode 100644 (file)
index b475e20..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-MESSAGE("===================================================================")
-MESSAGE("Building...MOT client")
-MESSAGE("===================================================================")
-
-SET(INTROSPECTION_PATH ${CMAKE_CURRENT_SOURCE_DIR}/introspection)
-ADD_CUSTOM_COMMAND(
-       OUTPUT dbus1
-       COMMAND gdbus-codegen
-               --interface-prefix net.ma.
-               --generate-c-code ma-generated-code
-               --c-generate-object-manager
-               --generate-docbook generated-docs
-               ${INTROSPECTION_PATH}/ma.xml
-               ${INTROSPECTION_PATH}/enabler.xml
-       COMMENT "Generating MOT agent GDBus .c/.h"
-)
-
-MESSAGE(" - Check cmake packagesion")
-pkg_check_modules(ma_pkgs REQUIRED ${COMMON_DEPS} ${TIZEN_DEPS}
-       capi-network-wifi-manager
-       sqlite3
-       )
-
-ADD_CUSTOM_TARGET(GENERATED_MA_DBUS_CODE DEPENDS dbus1)
-MESSAGE(" - Set source folder")
-FILE(GLOB MOT_AGENT_SRCS *.c)
-SET(MOT_AGENT_SRCS ${MOT_AGENT_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/ma-generated-code.c)
-SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/ma-generated-code.c PROPERTIES GENERATED TRUE)
-
-INCLUDE_DIRECTORIES(${ma_pkgs_INCLUDE_DIRS})
-LINK_DIRECTORIES(${ma_pkgs_LIBRARY_DIRS})
-
-SET(MOT_AGENT "mot-agent")
-ADD_EXECUTABLE(${MOT_AGENT} ${MOT_AGENT_SRCS})
-ADD_DEPENDENCIES(${MOT_AGENT} GENERATED_MA_DBUS_CODE)
-TARGET_LINK_LIBRARIES(${MOT_AGENT} ${ma_pkgs_LIBRARIES} pthread)
-INSTALL(TARGETS ${MOT_AGENT} DESTINATION bin)
-INSTALL(FILES oic_svr_db_ma.dat DESTINATION ${NETWORK_FW_DATADIR})
diff --git a/src/mot-agent/introspection/enabler.xml b/src/mot-agent/introspection/enabler.xml
deleted file mode 100644 (file)
index 03cb9bd..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!DOCTYPE node PUBLIC
-       "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
-       "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
-
-<node>
-       <interface name="net.ma.enabler">
-               <!-- Method definitions -->
-               <method name="enable">
-                       <arg type="i" name="result" direction="out"/>
-               </method>
-               <method name="disable">
-                       <arg type="i" name="result" direction="out"/>
-               </method>
-       </interface>
-</node>
diff --git a/src/mot-agent/introspection/gen.sh b/src/mot-agent/introspection/gen.sh
deleted file mode 100755 (executable)
index 07eba3e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-gdbus-codegen --interface-prefix net.ma. \
-        --generate-c-code ma-generated-code \
-        --c-generate-object-manager \
-        --generate-docbook generated-docs \
-        ma.xml \
-        enabler.xml
diff --git a/src/mot-agent/introspection/ma.xml b/src/mot-agent/introspection/ma.xml
deleted file mode 100644 (file)
index c734f79..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>\r
-\r
-<!DOCTYPE node PUBLIC\r
-     "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"\r
-    "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">\r
-\r
-<node>\r
-    <interface name="net.ma">\r
-        <!-- Method definitions -->\r
-        <method name="get_ownerid">\r
-            <arg type="s" name="devownerid" direction="out"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-        </method>\r
-        <method name="disc_mot_enb_devs">\r
-            <arg type="i" name="timeout" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-        </method>\r
-            <method name="disc_mowned_devs">\r
-            <arg type="i" name="timeout" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-        </method>\r
-        <method name="mot">\r
-            <arg type="s" name="target" direction="in"/>\r
-            <arg type="s" name="pin" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-            </method>\r
-        <method name="remove_subowner">\r
-            <arg type="s" name="target" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-            </method>\r
-        <method name="remove_device">\r
-            <arg type="s" name="target" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-            </method>\r
-        <method name="acl">\r
-            <arg type="s" name="target" direction="in"/>\r
-            <arg type="s" name="subject" direction="in"/>\r
-            <arg type="s" name="uri" direction="in"/>\r
-            <arg type="s" name="rt" direction="in"/>\r
-            <arg type="s" name="interface" direction="in"/>\r
-            <arg type="i" name="permission" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-        </method>\r
-        <method name="cred">\r
-            <arg type="s" name="dev1" direction="in"/>\r
-            <arg type="s" name="dev2" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-        </method>\r
-        <method name="pairwise">\r
-            <arg type="s" name="target_1" direction="in"/>\r
-            <arg type="s" name="subject_1" direction="in"/>\r
-            <arg type="s" name="uri_1" direction="in"/>\r
-            <arg type="s" name="rt_1" direction="in"/>\r
-            <arg type="s" name="interface_1" direction="in"/>\r
-            <arg type="i" name="permission_1" direction="in"/>\r
-            <arg type="s" name="target_2" direction="in"/>\r
-            <arg type="s" name="subject_2" direction="in"/>\r
-            <arg type="s" name="uri_2" direction="in"/>\r
-            <arg type="s" name="rt_2" direction="in"/>\r
-            <arg type="s" name="interface_2" direction="in"/>\r
-            <arg type="i" name="permission_2" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-        </method>\r
-         <method name="unlink">\r
-            <arg type="s" name="uuid_dev1" direction="in"/>\r
-            <arg type="s" name="uuid_dev2" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-        </method>\r
-        <method name="pair">\r
-           <arg type="s" name="pin" direction="in"/>\r
-            <arg type="s" name="target_1" direction="in"/>\r
-            <arg type="s" name="subject_1" direction="in"/>\r
-            <arg type="s" name="uri_1" direction="in"/>\r
-            <arg type="s" name="rt_1" direction="in"/>\r
-            <arg type="s" name="interface_1" direction="in"/>\r
-            <arg type="i" name="permission_1" direction="in"/>\r
-            <arg type="s" name="target_2" direction="in"/>\r
-            <arg type="s" name="subject_2" direction="in"/>\r
-            <arg type="s" name="uri_2" direction="in"/>\r
-            <arg type="s" name="rt_2" direction="in"/>\r
-            <arg type="s" name="interface_2" direction="in"/>\r
-            <arg type="i" name="permission_2" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-        </method>\r
-        <method name="unpair">\r
-            <arg type="s" name="owner_uuid" direction="in"/>\r
-            <arg type="s" name="owned_uuid" direction="in"/>\r
-            <arg type="i" name="result" direction="out"/>\r
-        </method>\r
-\r
-        <!-- Signal (D-Bus) definitions -->\r
-        <signal name="subowner_enabled">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-        <signal name="disc_mot_enb_devs_done">\r
-            <arg type="aa{sv}" name="list" direction="out"/>\r
-        </signal>\r
-        <signal name="disc_mowned_devs_done">\r
-            <arg type="aa{sv}" name="list" direction="out"/>\r
-        </signal>\r
-        <signal name="mot_done">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-       <signal name="remove_mo_done">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-       <signal name="remove_cred_local_done">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-        <signal name="acl_done">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-        <signal name="cred_done">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-        <signal name="pairwise_done">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-        <signal name="unlink_done">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-        <signal name="pair_done">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-        <signal name="unpair_done">\r
-            <arg type="i" name="result" direction="out"/>\r
-        </signal>\r
-    </interface>\r
-</node>\r
diff --git a/src/mot-agent/ma-log.h b/src/mot-agent/ma-log.h
deleted file mode 100644 (file)
index ec20a24..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MA_LOG_H__
-#define __MA_LOG_H__
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#ifdef USE_DLOG
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "MOT_AGENT"
-
-#define COLOR_RED "\033[0;31m"
-#define COLOR_GREEN "\033[0;32m"
-#define COLOR_BROWN "\033[0;33m"
-#define COLOR_BLUE "\033[0;34m"
-#define COLOR_PURPLE "\033[0;35m"
-#define COLOR_CYAN "\033[0;36m"
-#define COLOR_LIGHTBLUE "\033[0;37m"
-#define COLOR_END "\033[0;m"
-
-#define MA_LOGV(format, args...) LOGV(format, ##args)
-#define MA_LOGD(format, args...) LOGD(COLOR_LIGHTBLUE" "format COLOR_END, ##args)
-#define MA_LOGI(format, args...) LOGI(COLOR_GREEN" "format COLOR_END, ##args)
-#define MA_LOGW(format, args...) LOGW(COLOR_CYAN" "format COLOR_END, ##args)
-#define MA_LOGE(format, args...) LOGE(COLOR_RED" "format COLOR_END, ##args)
-#define MA_LOGF(format, args...) LOGF(format, ##args)
-
-#define __MA_LOG_FUNC_ENTER__ LOGD("Enter")
-#define __MA_LOG_FUNC_EXIT__ LOGD("Quit")
-
-#define MA_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, MA_LOG_TAG, format, ##args)
-#define MA_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, MA_LOG_TAG, format, ##args)
-
-#else /* USE_DLOG */
-
-#define MA_LOGV(format, args...)
-#define MA_LOGD(format, args...)
-#define MA_LOGI(format, args...)
-#define MA_LOGW(format, args...)
-#define MA_LOGE(format, args...)
-#define MA_LOGF(format, args...)
-
-#define __MA_LOG_FUNC_ENTER__
-#define __MA_LOG_FUNC_EXIT__
-
-#define MA_SECLOGI(format, args...)
-#define MA_SECLOGD(format, args...)
-
-#endif /* USE_DLOG */
-
-#endif /* __MA_LOG_H__ */
diff --git a/src/mot-agent/ma-service-interface.c b/src/mot-agent/ma-service-interface.c
deleted file mode 100644 (file)
index d680a6a..0000000
+++ /dev/null
@@ -1,625 +0,0 @@
-/*
- * Copyright (c) 2018 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 <glib.h>
-
-#include "ma.h"
-#include "ma-log.h"
-#include "ma-util.h"
-#include "ma-service.h"
-#include "ma-subowner.h"
-#include "ma-service-interface.h"
-#include "ma-generated-code.h"
-
-static NetMa *ma_dbus_object;
-static Enabler *ma_activator_dbus_object;
-
-/* global list to care resource handle for each client */
-static GList *ma_dbus_client_list;
-static GMutex ma_dbus_client_list_mutex;
-
-typedef struct _ma_dbus_client_s {
-       gchar *bus_name;
-} ma_dbus_client_s;
-
-NetMa* ma_dbus_get_object()
-{
-       return ma_dbus_object;
-}
-
-static int _ma_dbus_client_list_cleanup(GList *client_list)
-{
-       ma_dbus_client_s *client;
-
-       ma_check_null_ret_error("client_list", client_list, FALSE);
-
-       client = client_list->data;
-
-       g_free(client->bus_name);
-       client->bus_name = NULL;
-       g_free(client);
-       g_list_free(client_list);
-
-       return MA_ERROR_NONE;
-}
-
-static int _ma_dbus_client_list_compare_bus_name(const void *a, const void *b)
-{
-       const ma_dbus_client_s *client = a;
-       return g_strcmp0(client->bus_name, b);
-}
-
-static inline GList* _ma_dbus_client_list_find_client(const gchar *owner)
-{
-       return g_list_find_custom(ma_dbus_client_list, owner,
-                       _ma_dbus_client_list_compare_bus_name);
-}
-
-static void _ma_dbus_name_owner_changed_cb(GDBusConnection *conn,
-               const gchar *sender_name,
-               const gchar *object_path,
-               const gchar *interface_name,
-               const gchar *signal_name,
-               GVariant *parameters,
-               gpointer user_data)
-{
-       int ret;
-       GList *client = NULL;
-       gchar *name, *old_owner, *new_owner;
-
-       NOTUSED(conn);
-       NOTUSED(sender_name);
-       NOTUSED(object_path);
-       NOTUSED(interface_name);
-       NOTUSED(signal_name);
-       NOTUSED(user_data);
-
-       g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
-
-       if (0 == strlen(new_owner)) {
-               g_mutex_lock(&ma_dbus_client_list_mutex);
-               client = _ma_dbus_client_list_find_client(old_owner);
-               if (client) { /* found bus name in our bus list */
-                       MA_LOGD("bus(%s) stopped", old_owner);
-                       ma_dbus_client_list = g_list_remove_link(ma_dbus_client_list, client);
-               }
-               g_mutex_unlock(&ma_dbus_client_list_mutex);
-
-               if (client) {
-                       ret = _ma_dbus_client_list_cleanup(client);
-                       if (MA_ERROR_NONE != ret)
-                               MA_LOGE("_ma_dbus_client_list_cleanup() Fail(%d)", ret);
-               }
-       }
-}
-
-static int _ma_dbus_subscribe_name_owner_changed(GDBusConnection *conn)
-{
-       unsigned int id;
-
-       id = g_dbus_connection_signal_subscribe(conn,
-                       "org.freedesktop.DBus", /* bus name */
-                       "org.freedesktop.DBus", /* interface */
-                       "NameOwnerChanged", /* member */
-                       "/org/freedesktop/DBus", /* path */
-                       NULL, /* arg0 */
-                       G_DBUS_SIGNAL_FLAGS_NONE,
-                       _ma_dbus_name_owner_changed_cb,
-                       NULL,
-                       NULL);
-       if (0 == id) {
-               MA_LOGE("g_dbus_connection_signal_subscribe() Fail");
-               return MA_ERROR_IO_ERROR;
-       }
-
-       return MA_ERROR_NONE;
-}
-
-static gboolean _ma_dbus_handle_get_ownerid(NetMa *object,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       gchar *uuid_str = NULL;
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-       ret = ma_request_get_ownerid(service, &uuid_str);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_get_ownerid [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_get_ownerid(object, invocation, uuid_str, ret);
-
-       if (uuid_str)
-               g_free(uuid_str);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_disc_mot_enb_devs(NetMa *object,
-               GDBusMethodInvocation *invocation,
-               gint timeout,
-               gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-       ret = ma_request_disc_mot_enb_devs(service, timeout);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_disc_mot_enb_devs [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_disc_mot_enb_devs(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_disc_mowned_devs(NetMa *object,
-               GDBusMethodInvocation *invocation,
-               gint timeout,
-               gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-
-       ret = ma_request_disc_owned_devs(service, timeout);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_disc_owned_devs [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_disc_mowned_devs(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_mot(NetMa *object,
-               GDBusMethodInvocation *invocation,  gchar *arg_target, gchar *arg_pin,
-               gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-
-       ret = ma_request_mot(service, arg_target, arg_pin);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_disc_moted_devs [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_mot(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_acl(NetMa *object,
-               GDBusMethodInvocation *invocation, gchar *arg_target, gchar *arg_subject,
-               gchar *arg_uri, gchar *arg_rt, gchar *arg_interface, gint arg_permission,
-               gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-
-       ret = ma_request_prov_acl(service, arg_target, arg_subject, arg_uri, arg_rt,
-               arg_interface, arg_permission);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_prov_acl [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_acl(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_cred(NetMa *object,
-               GDBusMethodInvocation *invocation, gchar *arg_dev1, gchar *arg_dev2,
-               gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-
-       ret = ma_request_prov_cred(service, arg_dev1, arg_dev2);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_prov_cred [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_cred(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_pairwise(NetMa *object,
-                                         GDBusMethodInvocation *invocation, gchar *target_1,
-                                         gchar *subject_1, gchar *uri_1, gchar *rt_1,
-                                         gchar *interface_1, int permission_1, gchar *target_2,
-                                         gchar *subject_2, gchar *uri_2, gchar *rt_2,
-                                         gchar *interface_2, int permission_2, gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-
-       ret = ma_request_rsrc_pairwise(service, target_1, subject_1, uri_1, rt_1,
-                                       interface_1, permission_1, target_2, subject_2, uri_2,
-                                       rt_2, interface_2, permission_2);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_pairwise [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_pairwise(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_unlink(NetMa *object,
-               GDBusMethodInvocation *invocation, gchar *uuid_dev1, gchar *uuid_dev2,
-               gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-       ret = ma_request_unlink_rsrc(service, uuid_dev1, uuid_dev2);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_unpair [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_unpair(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_remove_subowner(NetMa *object,
-               GDBusMethodInvocation *invocation,  gchar *arg_target, gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-
-       ret = ma_request_remove_subowner(service, arg_target);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_remove_subowner [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_remove_subowner(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_remove_device(NetMa *object,
-               GDBusMethodInvocation *invocation,  gchar *arg_target, gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-
-       ret = ma_request_remove_device(service, arg_target);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_remove_subowner [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_remove_device(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_pair(NetMa *object,
-         GDBusMethodInvocation *invocation, gchar *pin,
-         gchar *target_1, gchar *subject_1, gchar *uri_1,
-         gchar *rt_1, gchar *interface_1, int permission_1,
-         gchar *target_2, gchar *subject_2, gchar *uri_2,
-         gchar *rt_2, gchar *interface_2, int permission_2,
-         gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-
-       ret = ma_request_pair(service, pin, target_1, subject_1, uri_1, rt_1,
-                                       interface_1, permission_1, target_2, subject_2, uri_2,
-                                       rt_2, interface_2, permission_2);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_pair [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_pair(object, invocation, ret);
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_unpair(NetMa *object,
-               GDBusMethodInvocation *invocation, gchar *uuid_owner, gchar *uuid_owned,
-               gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       ma_check_null_ret_error("service", service, FALSE);
-
-       ret = ma_request_unpair(service, uuid_owner, uuid_owned);
-       if (MA_ERROR_NONE != ret)
-               MA_LOGE("Failed to ma_request_unpair [%d][%s]",
-                       ret, ma_erro_to_string(ret));
-
-       net_ma_complete_unpair(object, invocation, ret);
-
-       return TRUE;
-}
-
-static void _ma_dbus_on_bus_acquired(GDBusConnection *conn, const gchar *name,
-               gpointer user_data)
-{
-       gboolean ret;
-       GError *error = NULL;
-       ma_service *service = (ma_service *)user_data;
-
-       NOTUSED(name);
-
-       ma_dbus_object = net_ma_skeleton_new();
-       if (NULL == ma_dbus_object) {
-               MA_LOGE("net_ma_skeleton_new() Fail");
-               return;
-       }
-       g_signal_connect(ma_dbus_object, "handle-get-ownerid",
-                       G_CALLBACK(_ma_dbus_handle_get_ownerid), service);
-       g_signal_connect(ma_dbus_object, "handle-disc-mot-enb-devs",
-                       G_CALLBACK(_ma_dbus_handle_disc_mot_enb_devs), service);
-       g_signal_connect(ma_dbus_object, "handle-disc-mowned-devs",
-                       G_CALLBACK(_ma_dbus_handle_disc_mowned_devs), service);
-       g_signal_connect(ma_dbus_object, "handle-mot",
-                       G_CALLBACK(_ma_dbus_handle_mot), service);
-       g_signal_connect(ma_dbus_object, "handle-pairwise",
-                       G_CALLBACK(_ma_dbus_handle_pairwise), service);
-       g_signal_connect(ma_dbus_object, "handle-unlink",
-                       G_CALLBACK(_ma_dbus_handle_unlink), service);
-       g_signal_connect(ma_dbus_object, "handle-remove-subowner",
-                       G_CALLBACK(_ma_dbus_handle_remove_subowner), service);
-       g_signal_connect(ma_dbus_object, "handle-remove-device",
-                       G_CALLBACK(_ma_dbus_handle_remove_device), service);
-       g_signal_connect(ma_dbus_object, "handle-acl",
-                       G_CALLBACK(_ma_dbus_handle_acl), service);
-       g_signal_connect(ma_dbus_object, "handle-cred",
-                       G_CALLBACK(_ma_dbus_handle_cred), service);
-       g_signal_connect(ma_dbus_object, "handle-pair",
-                       G_CALLBACK(_ma_dbus_handle_pair), service);
-       g_signal_connect(ma_dbus_object, "handle-unpair",
-                       G_CALLBACK(_ma_dbus_handle_unpair), service);
-
-       ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(ma_dbus_object),
-                       conn, MA_DBUS_OBJPATH, &error);
-       if (FALSE == ret) {
-               MA_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);
-               g_error_free(error);
-       }
-
-       ret = _ma_dbus_subscribe_name_owner_changed(conn);
-       if (MA_ERROR_NONE != ret) {
-               MA_LOGE("_ma_dbus_subscribe_name_owner_changed() Fail(%d)", ret);
-               return;
-       }
-}
-
-static void _ma_dbus_on_name_lost(GDBusConnection *conn, const gchar *name,
-               gpointer user_data)
-{
-       NOTUSED(conn);
-       NOTUSED(user_data);
-
-       MA_LOGD("Lost the name %s", name);
-}
-
-static void _ma_dbus_on_name_acquired(GDBusConnection *conn, const gchar *name,
-               gpointer user_data)
-{
-       NOTUSED(conn);
-       NOTUSED(user_data);
-
-       MA_LOGD("Acquired the name %s", name);
-}
-
-static gboolean _ma_dbus_handle_enable(Enabler *object,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       __MA_LOG_FUNC_ENTER__;
-
-       /* Do API response first */
-       enabler_complete_enable(object, invocation, ret);
-       service->ma_activated = TRUE;
-
-       /* Intialize subowner client */
-       ret = ma_request_enable(service);
-       if (MA_ERROR_NONE != ret) {
-               MA_LOGE("ma_request_enable() Fail(%d)", ret);
-               return FALSE;
-       }
-
-       /* Notify d2ds enabled */
-       net_ma_emit_subowner_enabled(ma_dbus_get_object(), ret);
-
-       __MA_LOG_FUNC_EXIT__;
-
-       return TRUE;
-}
-
-static gboolean _ma_dbus_handle_disable(Enabler *object,
-               GDBusMethodInvocation *invocation,
-               gpointer user_data)
-{
-       int ret = MA_ERROR_NONE;
-       ma_service *service = (ma_service *)user_data;
-
-       __MA_LOG_FUNC_ENTER__;
-
-       /* Make response first */
-       enabler_complete_disable(object, invocation, ret);
-
-       /* De-Intialize subowner client */
-       ret = ma_request_disable(service);
-       if (MA_ERROR_NONE != ret) {
-               MA_LOGE("ma_request_disable() Fail(%d)", ret);
-               return FALSE;
-       }
-
-       /* Terminate daemon */
-       ma_service_exit(service);
-
-       return TRUE;
-}
-
-static void _ma_dbus_on_activator_bus_acquired(GDBusConnection *conn,
-               const gchar *name, gpointer user_data)
-{
-       gboolean ret;
-       GError *error = NULL;
-       ma_service *service = (ma_service *)user_data;
-
-       NOTUSED(name);
-
-       __MA_LOG_FUNC_ENTER__;
-
-       ma_activator_dbus_object = enabler_skeleton_new();
-       if (NULL == ma_activator_dbus_object) {
-               MA_LOGE("enabler_skeleton_new() Fail");
-               return;
-       }
-
-       g_signal_connect(ma_activator_dbus_object, "handle-enable",
-                       G_CALLBACK(_ma_dbus_handle_enable), service);
-       g_signal_connect(ma_activator_dbus_object, "handle-disable",
-                       G_CALLBACK(_ma_dbus_handle_disable), service);
-
-       ret = g_dbus_interface_skeleton_export(
-                               G_DBUS_INTERFACE_SKELETON(ma_activator_dbus_object),
-                               conn, MA_DBUS_ENABLER_OBJPATH, &error);
-       if (FALSE == ret) {
-               MA_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);
-               g_error_free(error);
-       }
-
-       __MA_LOG_FUNC_EXIT__;
-
-}
-
-static gboolean _ma_dbus_interface_init(ma_service *service)
-{
-       guint id;
-       guint activation_dbus_id;
-       ma_check_null_ret_error("service", service, FALSE);
-
-       id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
-                       MA_DBUS_INTERFACE,
-                       G_BUS_NAME_OWNER_FLAGS_REPLACE,
-                       _ma_dbus_on_bus_acquired,
-                       _ma_dbus_on_name_acquired,
-                       _ma_dbus_on_name_lost,
-                       service,
-                       NULL);
-       if (0 == id) {
-               MA_LOGE("g_bus_own_name() Fail");
-               return FALSE;
-       }
-
-       /* Get D-Bus owner to activate subowner service daemon */
-       activation_dbus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
-                       MA_DBUS_INTERFACE".enabler",
-                       G_BUS_NAME_OWNER_FLAGS_REPLACE,
-                       _ma_dbus_on_activator_bus_acquired,
-                       NULL,
-                       NULL,
-                       service,
-                       NULL);
-
-       service->dbus_id = id;
-       service->activation_dbus_id = activation_dbus_id;
-
-       return TRUE;
-}
-
-void ma_notify_mot_env_devs(GVariant *devices)
-{
-       /* Notify d2ds enabled */
-       net_ma_emit_disc_mot_enb_devs_done(ma_dbus_get_object(), devices);
-}
-
-void ma_notify_mowned_devs(GVariant *devices)
-{
-       /* Notify d2ds enabled */
-       net_ma_emit_disc_mowned_devs_done(ma_dbus_get_object(), devices);
-}
-
-static void _ma_dbus_deinit(ma_service *service)
-{
-       ma_check_null_ret("service", service);
-
-       g_bus_unown_name(service->dbus_id);
-       g_bus_unown_name(service->activation_dbus_id);
-}
-
-gboolean ma_service_interface_init(ma_service *service)
-{
-       guint ret;
-       ma_check_null_ret_error("service", service, FALSE);
-
-       __MA_LOG_FUNC_ENTER__;
-
-       /* Initialize dbus interface */
-       ret = _ma_dbus_interface_init(service);
-       if (FALSE == ret) {
-               MA_LOGE("%s failed!!!", __func__);
-               return FALSE;
-       }
-
-       __MA_LOG_FUNC_EXIT__;
-
-       return TRUE;
-}
-
-void ma_service_interface_deinit(ma_service *service)
-{
-       ma_check_null_ret("service", service);
-
-       /* De-initialize dbus interface */
-       _ma_dbus_deinit(service);
-       /* De-initialize mot-agent instance */
-       ma_delete_mot_agent(service);
-}
-
diff --git a/src/mot-agent/ma-service-interface.h b/src/mot-agent/ma-service-interface.h
deleted file mode 100644 (file)
index 69decf3..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MA_SERVICE_INTERFACE_H__
-#define __MA_SERVICE_INTERFACE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**< Mesh D-BUS service*/
-#define MA_DBUS_SERVICE "net.ma"
-
-/**< Mesh D-BUS service path */
-#define MA_DBUS_PATH "/net/ma"
-
-#ifndef MA_DBUS_INTERFACE
-#define MA_DBUS_INTERFACE "net.ma"
-#endif
-
-#ifndef MA_DBUS_OBJPATH
-#define MA_DBUS_OBJPATH "/net/ma"
-#endif
-
-#ifndef MA_DBUS_ENABLER_OBJPATH
-#define MA_DBUS_ENABLER_OBJPATH "/net/ma/enabler"
-#endif
-
-struct _NetMa;
-typedef struct _NetMa NetMa;
-
-NetMa* ma_dbus_get_object();
-gboolean ma_service_interface_init(ma_service *service);
-void ma_service_interface_deinit(ma_service *service);
-void ma_notify_mot_env_devs(GVariant *devices);
-void ma_notify_mowned_devs(GVariant *devices);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MA_SERVICE_INTERFACE_H__ */
-
diff --git a/src/mot-agent/ma-service.c b/src/mot-agent/ma-service.c
deleted file mode 100644 (file)
index 7b252c2..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2018 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 <glib.h>
-
-#include "ma.h"
-#include "ma-log.h"
-#include "ma-util.h"
-
-ma_service *ma_service_new()
-{
-       ma_service *service;
-
-       service = g_malloc0(sizeof(struct _ma_service));
-
-       /* Create g-main loop */
-       service->main_loop = g_main_loop_new(NULL, FALSE);
-       if (G_UNLIKELY(NULL == service->main_loop)) {
-               MA_LOGE("g-main loop creation failed!!!");
-               g_free(service);
-               return NULL;
-       }
-
-       return service;
-}
-
-void ma_service_free(ma_service *service)
-{
-       ma_check_null_ret("service", service);
-
-       /* Unref 'g-main loop' */
-       if (service->main_loop)
-               g_main_loop_unref(service->main_loop);
-
-       g_free(service);
-}
-
-gboolean ma_service_run(ma_service *service)
-{
-       ma_check_null_ret_error("service", service, FALSE);
-       ma_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
-
-       g_main_loop_run(service->main_loop);
-
-       return TRUE;
-}
-
-gboolean ma_service_exit(ma_service *service)
-{
-       ma_check_null_ret_error("service", service, FALSE);
-       ma_check_null_ret_error("service->main_loop", service->main_loop, FALSE);
-
-       g_main_loop_quit(service->main_loop);
-
-       return TRUE;
-}
diff --git a/src/mot-agent/ma-service.h b/src/mot-agent/ma-service.h
deleted file mode 100644 (file)
index fc6fe4e..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MA_SERVICE_H__
-#define __MA_SERVICE_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-ma_service* ma_service_new();
-void ma_service_free(ma_service *service);
-gboolean ma_service_run(ma_service *service);
-gboolean ma_service_exit(ma_service *service);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MA_SERVICE_H__ */
-
diff --git a/src/mot-agent/ma-subowner.c b/src/mot-agent/ma-subowner.c
deleted file mode 100644 (file)
index 7833bd4..0000000
+++ /dev/null
@@ -1,2479 +0,0 @@
-/*
- * Copyright (c) 2018 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 <errno.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <utlist.h>
-#include <oic_malloc.h>
-#include <oxmjustworks.h>
-#include <oxmrandompin.h>
-#include <iotivity_config.h>
-#include <platform_features.h>
-#include <ocprovisioningmanager.h>
-#include <securevirtualresourcetypes.h>
-
-#include "ma.h"
-#include "ma-log.h"
-#include "ma-util.h"
-#include "ma-subowner.h"
-#include "ma-service-interface.h"
-#include "ma-generated-code.h"
-
-#define MAX_FILE_PATH_LEN 1024 /**< Max. file path length */
-#define ACL_RESRC_MAX_LEN 128 /**< '128' is ACL_RESRC_MAX_LEN */
-#define ACL_RESRC_ARRAY_SIZE 3 /**< This value is used only for sample (not OCF spec) */
-
-#define DISCOVERY_TIMEOUT  6 /**< 6 sec */
-#define CALLBACK_TIMEOUT_10S 10 * 1000 /**< 10 sec = 10 * 1000 * 1ms */
-#define CALLBACK_TIMEOUT_5S 5 * 1000 /**< 5sec = 5 * 1000 * 1ms */
-
-/* '_' for separaing from the same constant variable in srmresourcestrings.c  */
-static const char* SVR_DB_FILE_NAME = "oic_svr_db_ma.dat";
-static const char* PRVN_DB_FILE_NAME = "oic_pdm_ma.db";
-
-#ifdef TEST
-static const OicSecPrm_t  SUPPORTED_PRMS[2] = { PRM_PRE_CONFIGURED, PRM_RANDOM_PIN };
-#endif
-
-/**< GetDoxmDevOwnerId() is IoTivity function */
-OCStackResult GetDoxmDevOwnerId(OicUuid_t *devownerid);
-
-typedef struct {
-       int ret; /** Result of command */
-       ma_cmd_id_e cid; /**< Command ID */
-       int tid; /**< Timer ID */
-       int timeout; /**< Timeout value */
-       GThread *thread; /**< Thread handle */
-       unsigned int sid; /**< Subcribed signal ID */
-       bool found; /**< Whether we discoverd devices */
-       void *cb; /**< Callback function pointer */
-       void *userdata; /**< User data */
-
-       /* To-Do : Change belows to union type */
-
-       /* For MOT */
-       gchar *uuid_target_str; /**< Target device*/
-       gchar *pin; /**< PIN */
-
-       /* For ACL provisioning */
-       gchar *uuid_subject_str;/**< Subject device for ACL */
-       gchar *rsrc_uri; /**< Resource URI */
-       gchar *rsrc_type; /**< Resouce Type */
-       gchar *rsrc_interface; /**< Resource Interface Array To-Do : Make this as array */
-       int permission;/**< Permision */
-
-       /* For CRED provisioning */
-       gchar *uuid_dev1; /**< 1st device for CRED provisiong */
-       gchar *uuid_dev2; /**< 2nd device for CRED provisiong  */
-
-       /* For Pairwaise linking */
-       gchar *target_1; /**< Target device 1*/
-       gchar *target_2; /**< Target device 1*/
-
-       gchar *subject_1; /**< Target device for ACL */
-       gchar *rsrc_uri_1; /**< Resource URI */
-       gchar *rsrc_type_1; /**< Resouce Type */
-       gchar *rsrc_interface_1; /**< Resource Interface Array To-Do : Make this as array */
-       int permission_1;/**< Permision */
-       gchar *subject_2; /**< Target device for ACL */
-       gchar *rsrc_uri_2; /**< Resource URI */
-       gchar *rsrc_type_2; /**< Resouce Type */
-       gchar *rsrc_interface_2; /**< Resource Interface Array To-Do : Make this as array */
-       int permission_2;/**< Permision */
-
-       /* For unpair  */
-       gchar *target_to_revoke; /**< Target device to revoke */
-
-} ma_req_cb_s;
-
-typedef struct _ma_subowner {
-       GThread *thread; /**< Worker Thread */
-       GAsyncQueue *queue; /**< Async Queue to be handled */
-       gint pending; /**< Is there any pending operation? */
-       GMutex iotivity_mutex; /**< Mutex for IoTivity stack */
-
-       OCProvisionDev_t* g_motdev_list; /**< Discoverd MOT enabled devices list */
-       OCProvisionDev_t* g_mowned_list; /**< My owned MOT enabled devices list */
-
-       int g_motdev_cnt; /**< Number of MOT enabled devices */
-       int g_mowndev_cnt; /**< Number of my owned MOT enabled devices */
-
-       bool g_doneCB; /**< This means callback completed or not */
-
-       char *rnd_pin; /**< Random PIN */
-       int rnd_pin_len; /**< Random PIN length */
-} ma_subowner_s;
-
-ma_subowner_s *g_client; /**< MOT agent client instance */
-
-#ifdef THREAD_COND_WAIT_USED
-/*
- * data structure
- */
-typedef struct _proc {
-       char name[2]; /**< Thread name */
-       int data; /**< User data */
-       pthread_t thread; /**< POSIX Thread */
-       pthread_mutex_t lock; /**< POSIX Mutex */
-       pthread_cond_t cond; /**< POSIX condition */
-       long int waits; /**< How long we have to wait */
-} PROC;
-
-void _exec_and_wait(void* args)
-{
-       OCStackResult ret = OC_STACK_OK;
-       static struct timespec time_to_wait = {0, 0};
-       PROC *proc = (PROC*) args;
-       int TIMES = proc->waits /100;
-
-       time_to_wait.tv_sec = time(NULL) + proc->waits / 1000;
-       time_to_wait.tv_nsec = (proc->waits % 1000) * 1000000;
-
-       MA_LOGE("before increase proc[%s] data to [%d]", proc->name, proc->data);
-
-       while (g_client->g_doneCB && proc->data < TIMES) {
-               MA_LOGE("increase proc[%s] data to [%d]", proc->name, proc->data);
-               pthread_mutex_lock(&proc->lock);
-               pthread_cond_timedwait(&proc->cond, &proc->lock, &time_to_wait);
-               proc->data++;
-
-               ret = OCProcess();
-               if (OC_STACK_OK != ret) {
-                       MA_LOGE("OCStack process error = %d", ret);
-                       proc->data = TIMES;
-               }
-
-               pthread_mutex_unlock(&proc->lock);
-       }
-}
-
-int _init_proc(PROC *proc, void *(*routine) (void *))
-{
-       pthread_attr_t attr;
-
-       MA_LOGI("try to init proc [%s]", proc->name);
-       pthread_attr_init(&attr);
-       pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-
-       pthread_mutex_init(&proc->lock, NULL);
-       pthread_cond_init(&proc->cond, NULL);
-
-       pthread_create(&proc->thread, &attr, routine, (void*) proc);
-       pthread_attr_destroy(&attr);
-
-       return MA_ERROR_NONE;
-}
-#endif
-
-static FILE* _fopen_prvn_mng(const char* path, const char* mode)
-{
-       char data_dir[MAX_FILE_PATH_LEN] = {0,};
-
-       snprintf(data_dir, MAX_FILE_PATH_LEN, "%s/network/%s",
-                       "/opt/usr/data", SVR_DB_FILE_NAME);
-
-       NOTUSED(path);
-#if 0
-       MA_LOGD("Unsed DB path  %s\n", path);
-#endif
-
-       return fopen(data_dir, mode);
-}
-
-static int _wait_cb_ret(int msec)
-{
-       OCStackResult ret = OC_STACK_OK;
-       struct timespec tim, tim2;
-       tim.tv_sec = 0;
-       tim.tv_nsec = 100 * 1000000;
-
-       ma_check_null_ret_error("g_client", g_client, OC_STACK_INVALID_PARAM);
-
-#ifdef THREAD_COND_WAIT_USED
-       int result_a = 0;
-       PROC proc_a;
-
-       strcpy(proc_a.name, "A\0");
-       proc_a.data = 0;
-       proc_a.waits = msec;
-
-       if (MA_ERROR_NONE != _init_proc(&proc_a, _exec_and_wait))
-               MA_LOGE("Fail to init proc [%s]", proc_a.name);
-
-       pthread_join(proc_a.thread, (void*) &result_a);
-#else
-       for (int i = 0; !g_client->g_doneCB && msec > i; i += 100) {
-               /*
-                 * Basically, nanosleep is more thread-safe function,
-                 * But, in our case, nanosleep cause crash frequently
-                 */
-               ret = nanosleep(&tim, &tim2);
-               if (0 > ret)
-                       MA_LOGE("nanosleep failed=%d", errno);
-
-               g_mutex_lock(&g_client->iotivity_mutex);
-               ret = OCProcess();
-               g_mutex_unlock(&g_client->iotivity_mutex);
-
-               if (OC_STACK_OK != ret) {
-                       MA_LOGE("OCStack process error = %d", ret);
-                       break;
-               }
-       }
-#endif
-       if (!g_client->g_doneCB)
-               OCPDMCleanupForTimeout();
-
-       return ret;
-}
-
-static void _input_pin_cb(char* pin, size_t len)
-{
-       ma_check_null_ret("g_client", g_client);
-
-       if (!pin || OXM_RANDOM_PIN_MAX_SIZE >= len) {
-               MA_LOGE("inputPinCB invalid parameters");
-               return;
-       }
-
-       memcpy(pin, g_client->rnd_pin, g_client->rnd_pin_len);
-       MA_LOGI("Random PIN : %s", g_client->rnd_pin);
-}
-
-static void _remove_mot_client()
-{
-       ma_check_null_ret("g_client", g_client);
-
-       if (g_client->g_motdev_list) {
-               OCDeleteDiscoveredDevices(g_client->g_motdev_list);
-               g_client->g_motdev_list = NULL;
-       }
-}
-
-static void _remove_owned_client()
-{
-       ma_check_null_ret("g_client", g_client);
-
-       if (g_client->g_mowned_list) {
-               OCDeleteDiscoveredDevices(g_client->g_mowned_list);
-               g_client->g_mowned_list = NULL;
-       }
-}
-
-static void _request_cleanup(gpointer data)
-{
-       ma_req_cb_s *con = (ma_req_cb_s *)data;
-       ma_check_null_ret("con", con);
-       ma_service *service = (ma_service *)con->userdata;
-       ma_check_null_ret("service", service);
-
-       if (con->tid) {
-               g_source_remove(con->tid);
-               con->tid = 0;
-       }
-       con->sid = 0;
-       con->found = FALSE;
-
-       if (con->pin) {
-               g_free(con->pin);
-               con->pin  = NULL;
-       }
-       if (con->rsrc_uri) {
-               g_free(con->rsrc_uri);
-               con->rsrc_uri = NULL;
-       }
-       if (con->rsrc_type) {
-               g_free(con->rsrc_type);
-               con->rsrc_type  = NULL;
-       }
-       if (con->rsrc_interface) {
-               g_free(con->rsrc_interface);
-               con->rsrc_interface = NULL;
-       }
-       if (con->uuid_target_str) {
-               g_free(con->uuid_target_str);
-               con->uuid_target_str = NULL;
-       }
-       if (con->uuid_dev1) {
-               g_free(con->uuid_dev1);
-               con->uuid_dev1 = NULL;
-       }
-       if (con->uuid_dev2) {
-               g_free(con->uuid_dev2);
-               con->uuid_dev2 = NULL;
-       }
-       if (con->target_1) {
-               g_free(con->target_1);
-               con->target_1 = NULL;
-       }
-       if (con->subject_1) {
-               g_free(con->subject_1);
-               con->subject_1 = NULL;
-       }
-       if (con->rsrc_uri_1) {
-               g_free(con->rsrc_uri_1);
-               con->rsrc_uri_1 = NULL;
-       }
-       if (con->rsrc_type_1) {
-               g_free(con->rsrc_type_1);
-               con->rsrc_type_1 = NULL;
-       }
-       if (con->rsrc_interface_1) {
-               g_free(con->rsrc_interface_1);
-               con->rsrc_interface_1 = NULL;
-       }
-       if (con->target_2) {
-               g_free(con->target_1);
-               con->target_1 = NULL;
-       }
-       if (con->subject_2) {
-               g_free(con->subject_1);
-               con->subject_1 = NULL;
-       }
-       if (con->rsrc_uri_2) {
-               g_free(con->rsrc_uri_2);
-               con->rsrc_uri_2 = NULL;
-       }
-       if (con->rsrc_type_2) {
-               g_free(con->rsrc_type_2);
-               con->rsrc_type_2 = NULL;
-       }
-       if (con->rsrc_interface_2) {
-               g_free(con->rsrc_interface_2);
-               con->rsrc_interface_2 = NULL;
-       }
-
-       /* Set d2ds status 'pending' */
-       if (g_client)
-               g_atomic_int_set(&g_client->pending, 0);
-
-       if (con) {
-               g_free(con);
-               con = NULL;
-       }
-}
-
-static gpointer ___notify_found_devs(gpointer data)
-{
-       GVariantBuilder builder;
-       GVariant* devices;
-       OCProvisionDev_t *iter = NULL;
-
-       ma_req_cb_s *con = (ma_req_cb_s *)data;
-       ma_check_null_ret_error("con", con, NULL);
-       ma_service *service = (ma_service *)con->userdata;
-       ma_check_null_ret_error("service", service, NULL);
-       ma_check_null_ret_error("g_client", g_client, NULL);
-
-       /* g_mowned_list would be filled above request */
-       g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
-
-       if (MA_FIND_MOT_ENABLED_DEVICES == con->cid) {
-               iter = g_client->g_motdev_list;
-               g_client->g_motdev_cnt = ma_print_dev_list(g_client->g_motdev_list);
-               MA_LOGD("Found %d MOT enabled devices", g_client->g_motdev_cnt);
-       } else if (MA_FIND_MULTIPLE_OWNED_DEVICES == con->cid) {
-               iter = g_client->g_mowned_list;
-               g_client->g_mowndev_cnt = ma_print_dev_list(g_client->g_mowned_list);
-               MA_LOGD("Found %d Mowned devices", g_client->g_mowndev_cnt);
-       }
-
-       while (iter != NULL) {
-               OicUuid_t *uuid = &iter->doxm->deviceID;
-               ma_check_null_ret_error("uuid", uuid, NULL);
-
-               g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
-
-               g_variant_builder_add(&builder, "{sv}", "deviceId",
-                               g_variant_new_string(ma_get_readable_uuid(uuid)));
-               g_variant_builder_add(&builder, "{sv}", "adapter",
-                               g_variant_new_uint32(iter->endpoint.adapter));
-               g_variant_builder_add(&builder, "{sv}", "flags",
-                               g_variant_new_int32(iter->endpoint.flags));
-               g_variant_builder_add(&builder, "{sv}", "port",
-                               g_variant_new_uint16(iter->endpoint.port));
-               g_variant_builder_add(&builder, "{sv}", "addr",
-                               g_variant_new_string(iter->endpoint.addr));
-               g_variant_builder_add(&builder, "{sv}", "ifindex",
-                               g_variant_new_int32(iter->endpoint.ifindex));
-               g_variant_builder_add(&builder, "{sv}", "routeData",
-                               g_variant_new_string(iter->endpoint.routeData));
-               g_variant_builder_add(&builder, "{sv}", "remoteId",
-                               g_variant_new_string(iter->endpoint.remoteId));
-
-               g_variant_builder_add(&builder, "{sv}", "connType",
-                               g_variant_new_uint32(iter->connType));
-               g_variant_builder_add(&builder, "{sv}", "securePort",
-                               g_variant_new_uint16(iter->securePort));
-#ifdef WITH_TCP
-               g_variant_builder_add(&builder, "{sv}", "tcpPort",
-                               g_variant_new_uint16(iter->tcpPort));
-#endif
-               g_variant_builder_add(&builder, "{sv}", "secVer",
-                               g_variant_new_string(iter->secVer));
-               g_variant_builder_add(&builder, "{sv}", "devStatus",
-                               g_variant_new_uint32(iter->devStatus));
-               g_variant_builder_close(&builder);
-
-               iter = iter->next;
-       }
-
-       devices = g_variant_builder_end(&builder);
-
-       if (MA_FIND_MOT_ENABLED_DEVICES == con->cid)
-               ma_notify_mot_env_devs(devices);
-       else if (MA_FIND_MULTIPLE_OWNED_DEVICES == con->cid)
-               ma_notify_mowned_devs(devices);
-
-       g_variant_builder_unref(&builder);
-       g_variant_unref(devices);
-
-       _request_cleanup(con);
-       g_thread_exit(GINT_TO_POINTER(1));
-
-       return NULL;
-}
-
-static int __notify_found_devs(ma_req_cb_s *con)
-{
-       con->thread = g_thread_try_new("notify_devs", ___notify_found_devs, con, NULL);
-       if (!con->thread) {
-               MA_LOGE("Failed to create thread");
-               _request_cleanup(con);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-       g_thread_unref(con->thread);
-
-       return MA_ERROR_NONE;
-}
-
-static void _disc_mot_env_devs_func(ma_req_cb_s *con)
-{
-       int ret = OC_STACK_OK;
-
-       ma_check_null_ret("con", con);
-       ma_check_null_ret("g_client", g_client);
-
-       MA_LOGI("Discovering MOT enabled Devices on Network..");
-
-       /* delete mot device lists before updating them */
-       _remove_mot_client();
-
-       g_mutex_lock(&g_client->iotivity_mutex);
-       OCDiscoverMultipleOwnerEnabledDevices(con->timeout, &g_client->g_motdev_list);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCDiscoverMultipleOwnerEnalbedDevices API error");
-               goto DISC_MOT_ENB_DEVS_END;
-       }
-
-       __notify_found_devs(con);
-
-       return;
-
-DISC_MOT_ENB_DEVS_END:
-       _request_cleanup(con);
-}
-
-static int _disc_mot_enb_devs(ma_service *service, int timeout)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (NULL == con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_FIND_MOT_ENABLED_DEVICES;
-
-       if (timeout < 1)
-               timeout = DISCOVERY_TIMEOUT;
-       con->timeout = timeout;
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static void _disc_owned_devs_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = OC_STACK_OK;
-
-       ma_check_null_ret("con", con);
-       ma_check_null_ret("g_client", g_client);
-
-       /* delete un/owned device lists before updating them */
-       _remove_owned_client();
-
-       MA_LOGD("Discovering MOWNED Devices");
-
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCDiscoverMultipleOwnedDevices(con->timeout,
-                                                                                &g_client->g_mowned_list);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCDiscoverMultipleOwnerEnabledDevices API error");
-               goto DISC_OWNED_DEVS_END;
-       }
-
-       __notify_found_devs(con);
-
-       return;
-
-DISC_OWNED_DEVS_END:
-       _request_cleanup(con);
-}
-
-static int _disc_owned_devs(ma_service *service, int timeout)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (NULL == con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_FIND_MULTIPLE_OWNED_DEVICES;
-
-       if (timeout < 1)
-               timeout = DISCOVERY_TIMEOUT;
-       con->timeout = timeout;
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static gpointer ___notify_result(gpointer data)
-{
-       ma_req_cb_s *con = (ma_req_cb_s *)data;
-       ma_check_null_ret_error("con", con, NULL);
-       ma_service *service = (ma_service *)con->userdata;
-       ma_check_null_ret_error("service", service, NULL);
-       ma_check_null_ret_error("g_client", g_client, NULL);
-
-       switch (con->cid) {
-               case MA_DO_MOT:
-                       /* Notify ACL result  */
-                       net_ma_emit_acl_done(ma_dbus_get_object(), con->ret);
-                       break;
-               case MA_DO_ACL_PROVISIONING:
-                       net_ma_emit_acl_done(ma_dbus_get_object(), con->ret);
-                       break;
-               case MA_DO_CRED_PROVISIONING:
-                       net_ma_emit_cred_done(ma_dbus_get_object(), con->ret);
-                       break;
-               case MA_DO_RESOURCES_PAIRWISE:
-                       net_ma_emit_pairwise_done(ma_dbus_get_object(), con->ret);
-                       break;
-               case MA_REMOVE_MULTIPLE_OWNED_DEVICE:
-                       net_ma_emit_remove_mo_done(ma_dbus_get_object(), con->ret);
-                       break;
-               case MA_REMOVE_DEVICE_WITH_UUID_IN_SVR:
-                       net_ma_emit_remove_cred_local_done(ma_dbus_get_object(), con->ret);
-                       break;
-               case MA_UNLINK_RESOURCES:
-                       net_ma_emit_unpair_done(ma_dbus_get_object(), con->ret);
-                       break;
-               case MA_MAKE_PAIR:
-                       net_ma_emit_pair_done(ma_dbus_get_object(), con->ret);
-                       break;
-               case MA_MAKE_UNPAIR:
-                       net_ma_emit_unpair_done(ma_dbus_get_object(), con->ret);
-                       break;
-               default:
-                       break;
-       }
-
-       _request_cleanup(con);
-
-       g_thread_exit(GINT_TO_POINTER(1));
-
-       return NULL;
-}
-
-
-static int __notify_result(ma_req_cb_s *con)
-{
-       con->thread = g_thread_try_new("notify_result", ___notify_result, con, NULL);
-       if (!con->thread) {
-               MA_LOGE("Failed to create thread");
-               _request_cleanup(con);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-       g_thread_unref(con->thread);
-
-       return MA_ERROR_NONE;
-}
-
-static void _mot_cb(void* ctx, int num, OCProvisionResult_t* arr, bool has_error)
-{
-       ma_subowner_s *client = (ma_subowner_s *)ctx;
-
-       if (!has_error)  {
-               MA_LOGD("Multiple Ownership Transfer SUCCEEDED");
-       } else {
-               MA_LOGD("Multiple Ownership Transfer FAILED ");
-               ma_print_result_list((const OCProvisionResult_t*) arr, num);
-       }
-       client->g_doneCB = true;
-}
-
-static void _mot_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = OC_STACK_OK;
-       OCProvisionDev_t *src_dev = NULL;
-       OCProvisionDev_t *next_dev = NULL;
-       OicUuid_t *uuid_target = NULL;
-
-       if (!g_client) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("mot agent is not initialized");
-               goto MOT_ENDED;
-       }
-       if (NULL == con) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("container is NULL");
-               goto MOT_ENDED;
-       }
-
-       if (!con->uuid_target_str) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("Target device UUID is NULL");
-               goto MOT_ENDED;
-       }
-
-       uuid_target = ma_convert_uuid(con->uuid_target_str);
-       src_dev = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_target);
-       if (!src_dev) {
-               MA_LOGE("We can't find in MOT dev list");
-               goto MOT_ENDED;
-       }
-#ifndef MULTIPLE_OWN_AT_ONCE
-       /* Copy next MOT enabled device pointer temporally */
-       next_dev = src_dev->next;
-       /* Next MOT enabled device set NULL to MOT a single device */
-       src_dev->next = NULL;
-#endif
-
-       g_client->g_doneCB = false;
-
-#ifdef MULTIPLE_OWN_AT_ONCE
-       OCProvisionDev_t* dev = NULL;
-       LL_FOREACH(g_client->g_motdev_list, dev) {
-               if (OIC_PRECONFIG_PIN == dev->doxm->oxmSel) {
-                       /* Pre-Configured PIN initialization */
-                       const char* testPreconfigPin = con->pin;/* Ex) "12341234" */
-                       ret = OCAddPreconfigPin(dev, testPreconfigPin, strlen(testPreconfigPin));
-                       if (OC_STACK_OK != ret) {
-                               MA_LOGE("Failed to save the pre-configured PIN");
-                               MA_LOGE("You can't use the pre-configured PIN OxM for MOT");
-                               goto MOT_ENDED;
-                       }
-               }
-       }
-       ret = OCDoMultipleOwnershipTransfer(g_client, g_client->g_motdev_list, _mot_cb);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCDoMultipleOwnershipTransfer: ret = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto MOT_ENDED;
-       }
-
-#else
-       if (OIC_PRECONFIG_PIN == src_dev->doxm->oxmSel) {
-               /* Pre-Configured PIN initialization */
-               const char* testPreconfigPin = con->pin;/* Ex) "12341234" */
-               ret = OCAddPreconfigPin(src_dev, testPreconfigPin, strlen(testPreconfigPin));
-               if (OC_STACK_OK != ret) {
-                       MA_LOGE("Failed to save the pre-configured PIN");
-                       goto MOT_ENDED;
-               }
-       }
-       ret = OCDoMultipleOwnershipTransfer(g_client, src_dev, _mot_cb);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCDoMultipleOwnershipTransfer: ret = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto MOT_ENDED;
-       }
-#endif
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (ret) {
-               MA_LOGE("OCDoMultipleOwnershipTransfer callback error = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto MOT_ENDED;
-       }
-       MA_LOGI("Registered Discovered Devices");
-
-MOT_ENDED:
-#ifndef MULTIPLE_OWN_AT_ONCE
-       /* Restore MOT enabled devices */
-       src_dev->next = next_dev;
-#endif
-
-       /* Notify of MOT result */
-       con->ret = ret;
-       __notify_result(con);
-
-       if (uuid_target)
-               g_free(uuid_target);
-}
-
-static int _mot(ma_service *service, gchar *uuid_str, gchar *pin)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (NULL == con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_DO_MOT;
-       con->uuid_target_str = g_strdup(uuid_str);
-
-       if (pin) {
-               con->pin = g_malloc0(OXM_RANDOM_PIN_MAX_SIZE+1);
-               if (!pin) {
-                       MA_LOGE("Failed to allocate PIN number");
-                       _request_cleanup(con);
-                       return MA_ERROR_OUT_OF_MEMORY;
-               }
-               memcpy(con->pin, pin, OXM_RANDOM_PIN_MAX_SIZE);
-       }
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static OicSecAcl_t* _create_target_acl(const OicUuid_t* target, const OicUuid_t* subject,
-       const char *rsrc_uri, const char *rsrc_type, const char *rsrc_interface, int permission)
-{
-       /* For example
-         * subejct = "12341234-1234-1234-12341234"
-         * rsrc_uri = "/a/led"
-         * rsrc_type = "oic.r.core"
-         * rsrc_interface = "oic.if.baseline"
-         * rsrc_permission = MA_PERMISSION_FULL
-         */
-       size_t len;
-       OicSecAcl_t* acl = NULL;
-       OicSecAce_t* ace = NULL;
-       OicSecRsrc_t* rsrc = NULL;
-
-       ma_check_null_ret_error(target, "target", NULL);
-       ma_check_null_ret_error(subject, "subject", NULL);
-
-#ifdef DEBUG_UUID
-       MA_LOGD("target = %s", ma_get_readable_uuid(target));
-       MA_LOGD("subject = %s", ma_get_readable_uuid(subject));
-       MA_LOGD("rsrc_uri = %s", rsrc_uri);
-       MA_LOGD("rsrc_type = %s", rsrc_type);
-       MA_LOGD("rsrc_interface = %s", rsrc_interface);
-       MA_LOGD("permission = %d", permission);
-#endif
-       acl = (OicSecAcl_t*)calloc(1, sizeof(OicSecAcl_t));
-       if (!acl) {
-               MA_LOGE("acl : calloc failed = %d", errno);
-               return NULL;
-       }
-       ace = (OicSecAce_t*) calloc(1, sizeof(OicSecAce_t));
-       if (!ace) {
-               MA_LOGE("ace : calloc failed = %d", errno);
-               return NULL;
-       }
-       LL_APPEND(acl->aces, ace);
-       memcpy(ace->subjectuuid.id, subject->id, sizeof(subject->id));
-
-       /* fill the href */
-       rsrc = (OicSecRsrc_t*)calloc(1, sizeof(OicSecRsrc_t));
-       if (!rsrc) {
-               MA_LOGE("rsrc: calloc failed = %d", errno);
-               goto CREATE_ACL_ERROR;
-       }
-
-       len = strlen(rsrc_uri)+1;  // '1' for null termination
-       rsrc->href = (char*) calloc(len, sizeof(char));
-       if (!rsrc->href) {
-               MA_LOGE("rsrc->href: calloc failed = %d", errno);
-               goto CREATE_ACL_ERROR;
-       }
-       memcpy(rsrc->href, rsrc_uri, len);
-
-       /* Fill the resource type (rt) */
-       rsrc->typeLen = 1;
-       rsrc->types = (char**)calloc(1, sizeof(char*));
-       if (!rsrc->types) {
-               MA_LOGE("rsrc->types: calloc failed = %d", errno);
-               goto CREATE_ACL_ERROR;
-       }
-       rsrc->types[0] = g_strdup(rsrc_type);
-       if (!rsrc->types[0]) {
-               MA_LOGE("rsrc->types[0]: g_strdup failed = %d", errno);
-               goto CREATE_ACL_ERROR;
-       }
-
-       /* Fill the interface (if) */
-       rsrc->interfaceLen = 1;
-       rsrc->interfaces = (char**)calloc(1, sizeof(char*));
-       if (!rsrc->interfaces) {
-               MA_LOGE("rsrc->interfaces: calloc failed = %d", errno);
-               goto CREATE_ACL_ERROR;
-       }
-       rsrc->interfaces[0] = g_strdup(rsrc_interface);
-       if (!rsrc->interfaces[0]) {
-               MA_LOGE("rsrc->interfaces[0] : g_strdup failed = %d", errno);
-               goto CREATE_ACL_ERROR;
-       }
-
-       LL_APPEND(ace->resources, rsrc);
-
-       /* Fill permission for the reource */
-       ace->permission = permission;
-
-       ace->eownerID = (OicUuid_t*)calloc(1, sizeof(OicUuid_t));
-       if (NULL == ace->eownerID) {
-               MA_LOGE("ace->eownerID : calloc failed = %d", errno);
-               goto CREATE_ACL_ERROR;
-       }
-       memcpy(ace->eownerID->id, subject->id, sizeof(subject->id));
-
-       return acl;
-
-CREATE_ACL_ERROR:
-       OCDeleteACLList(acl);
-       return NULL;
-}
-
-static void _acl_provisioning_cb(void* ctx, int nOfRes, OCProvisionResult_t* arr,
-       bool has_error)
-{
-       ma_subowner_s *client = (ma_subowner_s *)ctx;
-
-       if (!has_error)  {
-               MA_LOGD("Provision ACL SUCCEEDED");
-       } else {
-               MA_LOGD("Provision ACL FAILED ");
-               ma_print_result_list((const OCProvisionResult_t*) arr, nOfRes);
-       }
-       client->g_doneCB = true;
-}
-static void _acl_provisioning_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = OC_STACK_OK;
-
-       OicSecAcl_t* acl = NULL;
-       OicUuid_t *uuid1 = NULL;
-       OicUuid_t *uuid2 = NULL;
-       OCProvisionDev_t *target_dev = NULL;
-       OCProvisionDev_t *subject_dev = NULL;
-
-       if (!g_client) {
-               MA_LOGE("mot agent is not initialized");
-               goto PV_ACL_END;
-       }
-       if (NULL == con) {
-               MA_LOGE("container is NULL");
-               goto PV_ACL_END;
-       }
-
-       uuid1 = ma_convert_uuid(con->uuid_target_str);
-       target_dev = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid1);
-       if (!target_dev) {
-               MA_LOGE("We can't find target in MOT enabled dev list");
-               goto PV_ACL_END;
-       }
-
-       uuid2 = ma_convert_uuid(con->uuid_subject_str);
-       subject_dev = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid2);
-       if (!subject_dev) {
-               MA_LOGE("We can't find subject in MOT enabled dev list");
-               goto PV_ACL_END;
-       }
-
-       g_client->g_doneCB = false;
-       MA_LOGI(" Provisioning Selected ACL..");
-
-       acl = _create_target_acl(&target_dev->doxm->deviceID,
-               &subject_dev->doxm->deviceID, con->rsrc_uri, con->rsrc_type,
-               con->rsrc_interface, con->permission);
-       if (NULL == acl) {
-               MA_LOGE("Failed to create ACL for %s", con->rsrc_uri);
-               goto PV_ACL_END;
-       }
-
-       /* Do ACL provisioning */
-       ret = OCProvisionACL((void*) g_client, target_dev, acl, _acl_provisioning_cb);
-       if (OC_STACK_OK != ret) {
-               MA_LOGD("OCProvisionACL API error: %d (%s)", ret, ma_ocf_error_to_string(ret));
-               goto PV_ACL_END;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (ret) {
-               MA_LOGE("OCProvisionCredentials Faild = %d", errno);
-               goto PV_ACL_END;
-       }
-       /* display the ACL-provisioned result */
-       MA_LOGI(" Provisioned Selected ACL Successfully");
-
-PV_ACL_END:
-       /* Notify ACL result */
-       con->ret = ret;
-       __notify_result(con);
-
-       if (acl)
-               OCDeleteACLList(acl);
-       if (uuid1)
-               g_free(uuid1);
-       if (uuid2)
-               g_free(uuid2);
-}
-
-static int _acl_provisioning(ma_service *service, gchar *target, gchar *subject,
-       gchar *rsrc_uri, gchar *rsrc_type, gchar *rsrc_interface, int permission)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (NULL == con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_DO_ACL_PROVISIONING;
-       con->uuid_target_str = g_strdup(target);
-       con->uuid_subject_str = g_strdup(subject);
-       con->rsrc_uri = g_strdup(rsrc_uri);
-       con->rsrc_type = g_strdup(rsrc_type);
-       con->rsrc_interface = g_strdup(rsrc_interface);
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static void _cred_provisioning_cb(void* ctx, int nOfRes, OCProvisionResult_t* arr,
-       bool has_error)
-{
-       ma_subowner_s *client = (ma_subowner_s *)ctx;
-
-       if (!has_error)  {
-               MA_LOGD("Provision ACL SUCCEEDED");
-       } else {
-               MA_LOGD("Provision ACL FAILED ");
-               ma_print_result_list((const OCProvisionResult_t*) arr, nOfRes);
-       }
-       client->g_doneCB = true;
-}
-
-static void _cred_provisioning_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = OC_STACK_OK;
-
-       OicUuid_t *uuid1 = NULL;
-       OicUuid_t *uuid2 = NULL;
-       OCProvisionDev_t *dev1 = NULL;
-       OCProvisionDev_t *dev2 = NULL;
-       OCProvisionDev_t *dev1_next = NULL;
-       OCProvisionDev_t *dev2_next = NULL;
-
-       if (!g_client) {
-               MA_LOGE("mot agent is not initialized");
-               goto PV_CRED_END;
-       }
-       if (NULL == con) {
-               MA_LOGE("container is NULL");
-               goto PV_CRED_END;
-       }
-
-       if (!con->uuid_dev1) {
-               MA_LOGE("dev1 is NULL");
-               goto PV_CRED_END;
-       }
-       if (!con->uuid_dev2) {
-               MA_LOGE("dev2 is NULL");
-               goto PV_CRED_END;
-       }
-
-       uuid1 = ma_convert_uuid(con->uuid_dev1);
-       dev1 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid1);
-       if (!dev1) {
-               MA_LOGE("We can't find in MOWNED dev list");
-               goto PV_CRED_END;
-       }
-
-       uuid2 = ma_convert_uuid(con->uuid_dev2);
-       dev2 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid2);
-       if (!dev2) {
-               MA_LOGE("We can't find in MOWNED dev list");
-               goto PV_CRED_END;
-       }
-
-       /* To do ACL provisioning only one */
-       dev1_next = dev1->next;
-       dev1->next = NULL;
-       dev2_next = dev2->next;
-       dev2->next = NULL;
-
-       g_client->g_doneCB = false;
-
-       MA_LOGI("Provisioning Selected Pairwise Devices..");
-       ret = OCProvisionCredentials((void*) g_client,
-               SYMMETRIC_PAIR_WISE_KEY, OWNER_PSK_LENGTH_256,
-               dev1, dev2, _cred_provisioning_cb);
-       if (OC_STACK_OK != ret)  {
-               MA_LOGD("OCProvisionPairwiseDevices API error: %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto PV_CRED_END;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (ret)  {
-               MA_LOGE("OCProvisionCredentials Faild = %d", errno);
-               goto PV_CRED_END;
-       }
-
-       /* display the pairwise-provisioned result */
-       MA_LOGI("Provisioned Selected Pairwise Devices");
-
-PV_CRED_END:
-       /* Restore MOT enabled device list */
-       dev1->next = dev1_next;
-       dev2->next = dev2_next;
-
-       /* Notify CRED provisiong result  */
-       con->ret = ret;
-       __notify_result(con);
-
-       if (uuid1)
-               g_free(uuid1);
-       if (uuid2)
-               g_free(uuid2);
-}
-
-static int _cred_provisioning(ma_service *service,
-       gchar *uuid_dev1, gchar *uuid_dev2)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (!con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_DO_CRED_PROVISIONING;
-
-       if (!uuid_dev1 || !uuid_dev2) {
-               MA_LOGE("Invaild Prameters");
-               _request_cleanup(con);
-               return MA_ERROR_INVALID_PARAMETER;
-       }
-
-       con->uuid_dev1 = g_strdup(uuid_dev1);
-       con->uuid_dev2 = g_strdup(uuid_dev2);
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static void _resources_pairwise_cb(void* ctx, int nOfRes, OCProvisionResult_t* arr,
-       bool has_error)
-{
-       ma_subowner_s *client = (ma_subowner_s *)ctx;
-
-       if (!has_error)  {
-               MA_LOGD("Provision pairwise SUCCEEDED");
-       } else {
-               MA_LOGD("Provision pairwise FAILED ");
-               ma_print_result_list((const OCProvisionResult_t*) arr, nOfRes);
-       }
-       client->g_doneCB = true;
-}
-
-static void _resources_pairwise_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = OC_STACK_OK;
-
-       OicUuid_t *uuid_1 = NULL;
-       OicUuid_t *uuid_2 = NULL;
-       OicUuid_t *uuid_3 = NULL;
-       OicUuid_t *uuid_4 = NULL;
-
-       OicSecAcl_t* acl_1 = NULL;
-       OicSecAcl_t* acl_2 = NULL;
-
-       OCProvisionDev_t *target_dev_1 = NULL;
-       OCProvisionDev_t *target_dev_2 = NULL;
-       OCProvisionDev_t *subject_dev_1 = NULL;
-       OCProvisionDev_t *subject_dev_2 = NULL;
-
-       if (!g_client) {
-               MA_LOGE("mot agent is not initialized");
-               goto PVPAIRWIE_ERROR;
-       }
-       if (NULL == con) {
-               MA_LOGE("container is NULL");
-               goto PVPAIRWIE_ERROR;
-       }
-
-       uuid_1 = ma_convert_uuid(con->target_1);
-       target_dev_1 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_1);
-       if (!target_dev_1) {
-               MA_LOGE("We can't find target in MOT enabled dev list");
-               goto PVPAIRWIE_ERROR;
-       }
-
-       uuid_2 = ma_convert_uuid(con->target_2);
-       target_dev_2 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_2);
-       if (!target_dev_2) {
-               MA_LOGE("We can't find target in MOT enabled dev list");
-               goto PVPAIRWIE_ERROR;
-       }
-
-       uuid_3 = ma_convert_uuid(con->subject_1);
-       subject_dev_1 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_3);
-       if (!subject_dev_1) {
-               MA_LOGE("We can't find subject in MOWNED dev list");
-               goto PVPAIRWIE_ERROR;
-       }
-
-       uuid_4 = ma_convert_uuid(con->subject_2);
-       subject_dev_2 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_4);
-       if (!subject_dev_2) {
-               MA_LOGE("We can't find subject in MOWNED dev list");
-               goto PVPAIRWIE_ERROR;
-       }
-
-       g_client->g_doneCB = false;
-       MA_LOGI(" Provisioning Selected Pairwise..");
-
-       acl_1 = _create_target_acl(&target_dev_1->doxm->deviceID,
-                                                          &subject_dev_1->doxm->deviceID, con->rsrc_uri_1,
-                                                          con->rsrc_type_1,
-                                                          con->rsrc_interface_1, con->permission_1);
-       if (NULL == acl_1) {
-               MA_LOGE("Failed to create ACL for %s", con->rsrc_uri);
-               goto PVPAIRWIE_ERROR;
-       }
-
-       acl_2 = _create_target_acl(&target_dev_2->doxm->deviceID,
-                                                          &subject_dev_2->doxm->deviceID, con->rsrc_uri_2,
-                                                          con->rsrc_type_2,
-                                                          con->rsrc_interface_2, con->permission_2);
-       if (NULL == acl_2) {
-               MA_LOGE("Failed to create ACL for %s", con->rsrc_uri);
-               goto PVPAIRWIE_ERROR;
-       }
-
-       /* Do both resources pairwise */
-       ret = OCProvisionPairwiseDevices((void*) g_client, SYMMETRIC_PAIR_WISE_KEY,
-                                                        OWNER_PSK_LENGTH_256, target_dev_1, acl_1,
-                                                        target_dev_2, acl_2, _resources_pairwise_cb);
-       if (OC_STACK_OK != ret) {
-               MA_LOGD("OCProvisionPairwiseDevices API error: %d (%s)", ret,
-                                  ma_ocf_error_to_string(ret));
-               goto PVPAIRWIE_ERROR;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (ret) {
-               MA_LOGE("OCProvisionPairwise Faild = %d", errno);
-               goto PVPAIRWIE_ERROR;
-       }
-       /* display the pairwise-provisioned result */
-       MA_LOGI(" Provision pairwise Done");
-
-PVPAIRWIE_ERROR:
-
-       /* Notify resource pairwise result  */
-       con->ret = ret;
-       __notify_result(con);
-
-       if (uuid_1)
-               g_free(uuid_1);
-       if (uuid_2)
-               g_free(uuid_2);
-       if (uuid_3)
-               g_free(uuid_3);
-       if (uuid_4)
-               g_free(uuid_4);
-       if (acl_1)
-               OCDeleteACLList(acl_1);
-       if (acl_2)
-               OCDeleteACLList(acl_2);
-}
-
-static int _resources_pairwise(ma_service *service, gchar *target_1,
-       gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1,
-       int permission_1, gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2,
-       gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (NULL == con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_DO_RESOURCES_PAIRWISE;
-
-       con->target_1 = g_strdup(target_1);
-       con->subject_1 = g_strdup(subject_1);
-       con->rsrc_uri_1 = g_strdup(rsrc_uri_1);
-       con->rsrc_type_1 = g_strdup(rsrc_type_1);
-       con->rsrc_interface_1 = g_strdup(rsrc_interface_1);
-       con->permission_1 = permission_1;
-
-       con->target_2 = g_strdup(target_2);
-       con->subject_2 = g_strdup(subject_2);
-       con->rsrc_uri_2 = g_strdup(rsrc_uri_2);
-       con->rsrc_type_2 = g_strdup(rsrc_type_2);
-       con->rsrc_interface_2 = g_strdup(rsrc_interface_2);
-       con->permission_2 = permission_2;
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static void _unlink_resources_cb(void* ctx, int nOfRes, OCProvisionResult_t* arr,
-       bool has_error)
-{
-       ma_subowner_s *client = (ma_subowner_s *)ctx;
-
-       if (!has_error)  {
-               MA_LOGD("unlink SUCCEEDED");
-       } else {
-               MA_LOGD("unlink FAILED ");
-               ma_print_result_list((const OCProvisionResult_t*) arr, nOfRes);
-       }
-       client->g_doneCB = true;
-}
-
-static void _unlink_resources_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = OC_STACK_OK;
-
-       OicUuid_t *uuid1 = NULL;
-       OicUuid_t *uuid2 = NULL;
-       OCProvisionDev_t *dev1 = NULL;
-       OCProvisionDev_t *dev2 = NULL;
-
-       if (!g_client) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("mot agent is not initialized");
-               goto PVUNLINKPAIRWISE_ERROR;
-       }
-       if (NULL == con) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("container is NULL");
-               goto PVUNLINKPAIRWISE_ERROR;
-       }
-
-       if (!con->uuid_dev1) {
-               MA_LOGE("dev1 is NULL");
-               goto PVUNLINKPAIRWISE_ERROR;
-       }
-       if (!con->uuid_dev2) {
-               MA_LOGE("dev2 is NULL");
-               goto PVUNLINKPAIRWISE_ERROR;
-       }
-
-       uuid1 = ma_convert_uuid(con->uuid_dev1);
-       dev1 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid1);
-       if (!dev1) {
-               MA_LOGE("We can't find in MOWNED dev list");
-               goto PVUNLINKPAIRWISE_ERROR;
-       }
-
-       uuid2 = ma_convert_uuid(con->uuid_dev2);
-       dev2 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid2);
-       if (!dev2) {
-               MA_LOGE("We can't find in MOWNED dev list");
-               goto PVUNLINKPAIRWISE_ERROR;
-       }
-
-       g_client->g_doneCB = false;
-
-       MA_LOGI("Unlink Selected Pairwise Devices..");
-       ret = OCUnlinkDevices((void*) g_client, dev1, dev2, _unlink_resources_cb);
-       if (OC_STACK_OK != ret)  {
-               MA_LOGD("OCUnlinkDevices API error: %d (%s)", ret, ma_ocf_error_to_string(ret));
-               goto PVUNLINKPAIRWISE_ERROR;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (ret)  {
-               MA_LOGE("OCUnlinkDevices Faild = %d", errno);
-               goto PVUNLINKPAIRWISE_ERROR;
-       }
-
-       /* display the pairwise-provisioned result */
-       MA_LOGI("Unlink Devices");
-
-PVUNLINKPAIRWISE_ERROR:
-       /* Notify resource unpair result */
-       con->ret = ret;
-       __notify_result(con);
-
-       if (uuid1)
-               g_free(uuid1);
-       if (uuid2)
-               g_free(uuid2);
-}
-
-static int _unlink_resources(ma_service *service,
-       gchar *uuid_dev1, gchar *uuid_dev2)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (!con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_UNLINK_RESOURCES;
-
-       if (!uuid_dev1 || !uuid_dev2) {
-               MA_LOGE("Invaild Prameters");
-               _request_cleanup(con);
-               return MA_ERROR_INVALID_PARAMETER;
-       }
-
-       con->uuid_dev1 = g_strdup(uuid_dev1);
-       con->uuid_dev2 = g_strdup(uuid_dev2);
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static void _remove_subowner_cb(void* ctx, int num, OCProvisionResult_t* arr,
-       bool has_error)
-{
-       ma_subowner_s *client = (ma_subowner_s *)ctx;
-
-       if (!has_error)  {
-               MA_LOGD("Remove Multiple Ownership SUCCEEDED");
-       } else {
-               MA_LOGD("Remove Multiple Ownership FAILED ");
-               ma_print_result_list((const OCProvisionResult_t*) arr, num);
-       }
-       client->g_doneCB = true;
-}
-
-static void _remove_subowner_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = MA_ERROR_OPERATION_FAILED;
-
-       OCProvisionDev_t *src_dev = NULL;
-       OicUuid_t uuid_mowner;
-       OicUuid_t *uuid_target = NULL;
-
-       if (!g_client) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("mot agent is not initialized");
-               goto REMOVE_SUBOWNER_ENDED;
-       }
-       if (NULL == con) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("container is NULL");
-               goto REMOVE_SUBOWNER_ENDED;
-       }
-
-       if (!con->uuid_target_str) {
-               MA_LOGE("Target device UUID is NULL");
-               goto REMOVE_SUBOWNER_ENDED;
-       }
-
-       uuid_target = ma_convert_uuid(con->uuid_target_str);
-       src_dev = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_target);
-       if (!src_dev) {
-               MA_LOGE("We can't find in MOT dev list");
-               goto REMOVE_SUBOWNER_ENDED;
-       }
-
-       g_client->g_doneCB = false;
-
-       ret = GetDoxmDevOwnerId(&uuid_mowner);
-       if (OC_STACK_OK  != ret) {
-               MA_LOGE("GetDoxmDevOwnerId faild = [%d][%s]",
-                       ret, ma_ocf_error_to_string(ret));
-               goto REMOVE_SUBOWNER_ENDED;
-       }
-       ret = OCRemoveSubOwner(g_client, src_dev, &uuid_mowner, _remove_subowner_cb);
-       if (OC_STACK_OK != ret)  {
-               MA_LOGE("OCRemoveSubOwner: ret = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto REMOVE_SUBOWNER_ENDED;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (ret) {
-               MA_LOGE("OCRemoveSubOwner callback error = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto REMOVE_SUBOWNER_ENDED;
-       }
-
-       MA_LOGI("Remove Multiple Ownership Done");
-
-REMOVE_SUBOWNER_ENDED:
-       /* Notify remove multiple owner at the remote device */
-       con->ret = ret;
-       __notify_result(con);
-
-       if (uuid_target)
-               g_free(uuid_target);
-}
-
-static int _ma_remove_subowner(ma_service *service, gchar *uuid_str)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (NULL == con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_REMOVE_MULTIPLE_OWNED_DEVICE;
-       con->uuid_target_str = g_strdup(uuid_str);
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static void _remove_remove_device_cb(void* ctx, int num,
-       OCProvisionResult_t* arr, bool has_error)
-{
-       ma_subowner_s *client = (ma_subowner_s *)ctx;
-
-       if (!has_error)  {
-               MA_LOGD("Remove CRED for mowned device SUCCEEDED");
-       } else {
-               MA_LOGD("Remove CRED for mowned device  FAILED ");
-               ma_print_result_list((const OCProvisionResult_t*) arr, num);
-       }
-       client->g_doneCB = true;
-}
-
-static void _remove_device_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = OC_STACK_OK;
-       OicUuid_t *uuid = NULL;
-
-       if (!g_client) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("mot agent is not initialized");
-               goto REMOVE_DEVICE_END;
-       }
-       if (NULL == con) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("container is NULL");
-               goto REMOVE_DEVICE_END;
-       }
-       if (!con->target_to_revoke) {
-               MA_LOGE("Some parameters are wrong");
-               MA_LOGE("%s", con->target_to_revoke);
-               goto REMOVE_DEVICE_END;
-       }
-
-       uuid = ma_convert_uuid(con->target_to_revoke);
-
-       g_client->g_doneCB = false;
-       MA_LOGI(" Removing CRED for remote device at local SVR DB");
-
-       ret = OCRemoveDeviceWithUuid((void*) g_client, CALLBACK_TIMEOUT_5S, uuid,
-               _remove_subowner_cb);
-       if (OC_STACK_OK != ret) {
-               MA_LOGD("OCRemoveDeviceWithUuid API error: %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto REMOVE_DEVICE_END;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (ret) {
-               MA_LOGE("OCRemoveDeviceWithUuid Faild = %d", errno);
-               goto REMOVE_DEVICE_END;
-       }
-       /* Disaply result result */
-       MA_LOGI(" Removing CRED info. at local SVR DB - Done");
-
-REMOVE_DEVICE_END:
-       /* Notify of result of removing CRED infor at local SVR DB  */
-       con->ret = ret;
-       __notify_result(con);
-
-       if (uuid)
-               g_free(uuid);
-}
-
-static int _remove_device(ma_service *service, gchar *uuid_str)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (NULL == con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_REMOVE_DEVICE_WITH_UUID_IN_SVR;
-       con->target_to_revoke = g_strdup(uuid_str);
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static void _make_devices_pair_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = OC_STACK_OK;
-
-       OicUuid_t *uuid_1 = NULL;
-       OicUuid_t *uuid_2 = NULL;
-       OicUuid_t *uuid_3 = NULL;
-       OicUuid_t *uuid_4 = NULL;
-
-       OicSecAcl_t* acl_1 = NULL;
-       OicSecAcl_t* acl_2 = NULL;
-
-       OCProvisionDev_t *target_dev_1 = NULL;
-       OCProvisionDev_t *target_dev_2 = NULL;
-       OCProvisionDev_t *subject_dev_1 = NULL;
-       OCProvisionDev_t *subject_dev_2 = NULL;
-
-       OCProvisionDev_t *src_dev = NULL;
-       OCProvisionDev_t *next_dev = NULL;
-
-       if (!g_client) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("mot agent is not initialized");
-               goto PV_PAIR_END;
-       }
-       if (NULL == con) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("container is NULL");
-               goto PV_PAIR_END;
-       }
-
-       uuid_1 = ma_convert_uuid(con->target_1);
-       target_dev_1 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_1);
-       if (!target_dev_1) {
-               MA_LOGE("We can't find target in MOT enabled dev list");
-               goto PV_PAIR_END;
-       }
-
-       uuid_2 = ma_convert_uuid(con->target_2);
-       target_dev_2 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_2);
-       if (!target_dev_2) {
-               MA_LOGE("We can't find target in MOT enabled dev list");
-               goto PV_PAIR_END;
-       }
-
-       uuid_3 = ma_convert_uuid(con->subject_1);
-       subject_dev_1 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_3);
-       if (!subject_dev_1) {
-               MA_LOGE("We can't find subject in MOWNED dev list");
-               goto PV_PAIR_END;
-       }
-
-       uuid_4 = ma_convert_uuid(con->subject_2);
-       subject_dev_2 = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_4);
-       if (!subject_dev_2) {
-               MA_LOGE("We can't find subject in MOWNED dev list");
-               goto PV_PAIR_END;
-       }
-
-       src_dev = ma_get_dev_by_uuid(g_client->g_motdev_list, uuid_2);
-       if (!src_dev) {
-               MA_LOGE("We can't find in MOT dev list");
-               goto PV_PAIR_END;
-       }
-       /* Copy next MOT enabled device pointer temporally */
-       next_dev = src_dev->next;
-       /* Next MOT enabled device set NULL to MOT a single device */
-       src_dev->next = NULL;
-
-       g_client->g_doneCB = false;
-
-       if (OIC_PRECONFIG_PIN == src_dev->doxm->oxmSel) {
-               /* Pre-Configured PIN initialization */
-               const char* testPreconfigPin = con->pin;/* Ex) "12341234" */
-               g_mutex_lock(&g_client->iotivity_mutex);
-               ret = OCAddPreconfigPin(src_dev, testPreconfigPin, strlen(testPreconfigPin));
-               g_mutex_unlock(&g_client->iotivity_mutex);
-               if (OC_STACK_OK != ret) {
-                       MA_LOGE("Failed to save the pre-configured PIN");
-                       MA_LOGE("You can't use the pre-configured PIN OxM for MOT");
-                       goto PV_PAIR_END;
-               }
-       }
-
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCDoMultipleOwnershipTransfer(g_client, src_dev, _mot_cb);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCDoMultipleOwnershipTransfer: ret = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto PV_PAIR_END;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCDoMultipleOwnershipTransfer callback error = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto PV_PAIR_END;
-       }
-
-       MA_LOGI("Registered Discovered Devices");
-
-       g_client->g_doneCB = false;
-
-       MA_LOGI(" Provisioning Selected Pairwise..");
-
-       acl_1 = _create_target_acl(&target_dev_1->doxm->deviceID,
-                                                          &subject_dev_1->doxm->deviceID, con->rsrc_uri_1,
-                                                          con->rsrc_type_1,
-                                                          con->rsrc_interface_1, con->permission_1);
-       if (NULL == acl_1) {
-               MA_LOGE("Failed to create ACL for %s", con->rsrc_uri);
-               goto PV_PAIR_END;
-       }
-
-       acl_2 = _create_target_acl(&target_dev_2->doxm->deviceID,
-                                                          &subject_dev_2->doxm->deviceID, con->rsrc_uri_2,
-                                                          con->rsrc_type_2,
-                                                          con->rsrc_interface_2, con->permission_2);
-       if (NULL == acl_2) {
-               MA_LOGE("Failed to create ACL for %s", con->rsrc_uri);
-               goto PV_PAIR_END;
-       }
-
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCProvisionPairwiseDevices((void*) g_client, SYMMETRIC_PAIR_WISE_KEY,
-                                                        OWNER_PSK_LENGTH_256, target_dev_1, acl_1,
-                                                        target_dev_2, acl_2, _resources_pairwise_cb);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGD("OCProvisionPairwiseDevices API error: %d (%s)", ret,
-                                  ma_ocf_error_to_string(ret));
-               goto PV_PAIR_END;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (ret) {
-               MA_LOGE("OCProvisionPairwise Faild = %d", errno);
-               goto PV_PAIR_END;
-       }
-       /* display the pairwise-provisioned result */
-       MA_LOGI(" Provision pairwise Done");
-
-PV_PAIR_END:
-       /* Restore MOT enabled devices */
-       if (src_dev)
-               src_dev->next = next_dev ;
-
-       /* Notify pair result  */
-       con->ret = ret;
-       __notify_result(con);
-
-       if (uuid_1)
-               g_free(uuid_1);
-       if (uuid_2)
-               g_free(uuid_2);
-       if (uuid_3)
-               g_free(uuid_3);
-       if (uuid_4)
-               g_free(uuid_4);
-       if (acl_1)
-               OCDeleteACLList(acl_1);
-       if (acl_2)
-               OCDeleteACLList(acl_2);
-}
-
-static int _make_devices_pair(ma_service *service, gchar *pin, gchar *target_1,
-       gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1, gchar *rsrc_interface_1,
-       int permission_1, gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2,
-       gchar *rsrc_type_2, gchar *rsrc_interface_2, int permission_2)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (NULL == con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_MAKE_PAIR;
-
-       con->pin = g_strdup(pin);
-       con->target_1 = g_strdup(target_1);
-       con->subject_1 = g_strdup(subject_1);
-       con->rsrc_uri_1 = g_strdup(rsrc_uri_1);
-       con->rsrc_type_1 = g_strdup(rsrc_type_1);
-       con->rsrc_interface_1 = g_strdup(rsrc_interface_1);
-       con->permission_1 = permission_1;
-
-       con->target_2 = g_strdup(target_2);
-       con->subject_2 = g_strdup(subject_2);
-       con->rsrc_uri_2 = g_strdup(rsrc_uri_2);
-       con->rsrc_type_2 = g_strdup(rsrc_type_2);
-       con->rsrc_interface_2 = g_strdup(rsrc_interface_2);
-       con->permission_2 = permission_2;
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static void _make_devices_unpair_func(ma_req_cb_s *con)
-{
-       OCStackResult ret = OC_STACK_OK;
-
-       OicUuid_t uuid_mowner;
-       OicUuid_t *owner_uuid = NULL;
-       OicUuid_t *owned_uuid = NULL;
-       OCProvisionDev_t *owner_dev = NULL;
-       OCProvisionDev_t *owned_dev = NULL;
-
-       if (NULL == g_client) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("mot agent is not initialized");
-               goto PV_UNPAIR_END;
-       }
-       if (NULL == con) {
-               ret = OC_STACK_INVALID_PARAM;
-               MA_LOGE("container is NULL");
-               goto PV_UNPAIR_END;
-       }
-
-       if (NULL == con->uuid_dev1) {
-               MA_LOGE("dev1 is NULL");
-               goto PV_UNPAIR_END;
-       }
-       if (NULL == con->uuid_dev2) {
-               MA_LOGE("dev2 is NULL");
-               goto PV_UNPAIR_END;
-       }
-
-       owner_uuid = ma_convert_uuid(con->uuid_dev1);
-       owner_dev = ma_get_dev_by_uuid(g_client->g_motdev_list, owner_uuid);
-       if (!owner_dev) {
-               MA_LOGE("We can't find in MOT enabled dev list");
-               goto PV_UNPAIR_END;
-       }
-
-       owned_uuid = ma_convert_uuid(con->uuid_dev2);
-       owned_dev = ma_get_dev_by_uuid(g_client->g_motdev_list, owned_uuid);
-       if (!owned_dev) {
-               MA_LOGE("We can't find in MOT enabled dev list");
-               goto PV_UNPAIR_END;
-       }
-
-       g_client->g_doneCB = false;
-
-       MA_LOGI("Unlink Selected Pairwise Devices..");
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCUnlinkDevices((void*) g_client, owner_dev, owned_dev, _unlink_resources_cb);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret)  {
-               MA_LOGD("OCUnlinkDevices API error = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-       } else {
-               ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-               if (OC_STACK_OK != ret)  {
-                       MA_LOGD("OCUnlinkDevices Timeout = %d (%s)",
-                               ret, ma_ocf_error_to_string(ret));
-                       goto PV_UNPAIR_END;
-               }
-       }
-
-       /* display the pairwise-provisioned result */
-       MA_LOGI("Unlink Devices Done");
-
-       g_client->g_doneCB = false;
-
-       ret = GetDoxmDevOwnerId(&uuid_mowner);
-       if (OC_STACK_OK  != ret) {
-               MA_LOGE("GetDoxmDevOwnerId faild = [%d][%s]",
-                       ret, ma_ocf_error_to_string(ret));
-               goto PV_UNPAIR_END;
-       }
-
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCRemoveSubOwner(g_client, owned_dev, &uuid_mowner, _remove_subowner_cb);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCRemoveSubOwner: ret = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto PV_UNPAIR_END;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (OC_STACK_OK  != ret) {
-               MA_LOGE("OCRemoveSubOwner Timeout = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto PV_UNPAIR_END;
-       }
-
-       MA_LOGI("Remove Multiple Ownership Done");
-
-       g_client->g_doneCB = false;
-
-       MA_LOGI(" Removing CRED for remote device at local SVR DB");
-
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCRemoveDeviceWithUuid((void*) g_client, CALLBACK_TIMEOUT_5S, owned_uuid,
-               _remove_remove_device_cb);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGD("OCRemoveDeviceWithUuid API error = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto PV_UNPAIR_END;
-       }
-
-       ret = _wait_cb_ret(CALLBACK_TIMEOUT_5S);
-       if (OC_STACK_OK  != ret) {
-               MA_LOGD("OCRemoveDeviceWithUuid Timeout = %d (%s)",
-                       ret, ma_ocf_error_to_string(ret));
-               goto PV_UNPAIR_END;
-       }
-       /* Disaply result result */
-       MA_LOGI(" Removing CRED info. at local SVR DB - Done");
-
-PV_UNPAIR_END:
-       /* Notify unpair result  */
-       con->ret = ret;
-       __notify_result(con);
-
-       if (owner_uuid)
-               g_free(owner_uuid);
-       if (owned_uuid)
-               g_free(owned_uuid);
-}
-
-static int _make_devices_unpair(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (!con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-
-       con->userdata = service;
-       con->cid = MA_MAKE_UNPAIR;
-
-       if (!uuid_dev1 || !uuid_dev2) {
-               MA_LOGE("Invaild Prameters");
-               _request_cleanup(con);
-               return MA_ERROR_INVALID_PARAMETER;
-       }
-
-       con->uuid_dev1 = g_strdup(uuid_dev1);
-       con->uuid_dev2 = g_strdup(uuid_dev2);
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static int _disable(ma_service *service)
-{
-       ma_req_cb_s *con = NULL;
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       con = g_malloc0(sizeof(ma_req_cb_s));
-       if (!con) {
-               MA_LOGE("g_malloc0() Fail=%d", errno);
-               /* Unset d2ds status 'pending' */
-               g_atomic_int_set(&g_client->pending, 0);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-       con->userdata = service;
-       con->cid = -1;
-
-       g_async_queue_push(g_client->queue, GINT_TO_POINTER(con));
-
-       return MA_ERROR_NONE;
-}
-
-static gpointer _worker_thread(gpointer data)
-{
-       ma_req_cb_s *con = NULL;
-       ma_subowner_s *client = (ma_subowner_s *)data;
-
-       while (1) {
-               if (0 == g_atomic_int_get(&client->pending)) {
-                       con = g_async_queue_pop(client->queue);
-                       if (NULL == con) continue;
-                       switch (con->cid) {
-                       case MA_FIND_MOT_ENABLED_DEVICES:
-                               _disc_mot_env_devs_func(con);
-                               break;
-                       case MA_FIND_MULTIPLE_OWNED_DEVICES:
-                               _disc_owned_devs_func(con);
-                               break;
-                       case MA_DO_MOT:
-                               _mot_func(con);
-                               break;
-                       case MA_DO_ACL_PROVISIONING:
-                               _acl_provisioning_func(con);
-                               break;
-                       case MA_DO_CRED_PROVISIONING:
-                               _cred_provisioning_func(con);
-                               break;
-                       case MA_DO_RESOURCES_PAIRWISE:
-                               _resources_pairwise_func(con);
-                               break;
-                       case MA_REMOVE_MULTIPLE_OWNED_DEVICE:
-                               _remove_subowner_func(con);
-                               break;
-                       case MA_REMOVE_DEVICE_WITH_UUID_IN_SVR:
-                               _remove_device_func(con);
-                               break;
-                       case MA_UNLINK_RESOURCES:
-                               _unlink_resources_func(con);
-                               break;
-                       case MA_MAKE_PAIR:
-                               _make_devices_pair_func(con);
-                               break;
-                       case MA_MAKE_UNPAIR:
-                               _make_devices_unpair_func(con);
-                               break;
-                       default:
-                               _request_cleanup(con);
-                               goto WORKER_EXIT;
-                       }
-               }
-       }
-WORKER_EXIT:
-       g_thread_exit(GINT_TO_POINTER(1));
-       return NULL;
-}
-
-static int _init_provision_client(void)
-{
-       int ret = OC_STACK_OK;
-       char data_dir[MAX_FILE_PATH_LEN] = {0,};
-
-       if (g_client)
-               return ret;
-
-       g_client = g_malloc0(sizeof(ma_subowner_s));
-       if (!g_client) {
-               MA_LOGE("memory allocation error = %d", errno);
-               return MA_ERROR_OUT_OF_MEMORY;
-       }
-       g_mutex_init(&g_client->iotivity_mutex);
-       g_client->thread = g_thread_try_new("worker", _worker_thread, g_client, NULL);
-       g_client->queue = g_async_queue_new();
-       g_client->g_motdev_list = NULL;
-       g_client->g_mowned_list = NULL;
-       g_client->rnd_pin = NULL;
-
-       snprintf(data_dir, MAX_FILE_PATH_LEN, "%s/network/%s",
-                       "/opt/usr/data", PRVN_DB_FILE_NAME);
-
-       /* initialize persistent storage for SVR DB */
-       static OCPersistentStorage ps = { _fopen_prvn_mng, fread, fwrite, fclose, unlink };
-
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCRegisterPersistentStorageHandler(&ps);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCRegisterPersistentStorageHandler error = %d", ret);
-               return ret;
-       }
-#if 0
-       ma_set_device_id_seed();
-#endif
-       /* initialize OC stack and provisioning manager */
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCInit(NULL, 0, OC_CLIENT_SERVER);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCInit() error = [%d][%s]", ret, ma_ocf_error_to_string(ret));
-               return ret;
-       }
-
-       /* Do Self-Ownership Transfer */
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCConfigSelfOwnership();
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCConfigSelfOwnership() error = [%d][%s]",
-                       ret, ma_ocf_error_to_string(ret));
-       }
-
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCInitPM(data_dir);
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret) {
-               MA_LOGE("OCInitPM() error = [%d][%s]", ret, ma_ocf_error_to_string(ret));
-               return ret;
-       }
-
-       SetInputPinCB(_input_pin_cb);
-
-       return ret;
-}
-
-int ma_request_get_ownerid(ma_service *service, gchar **uuid_str)
-{
-       int ret = MA_ERROR_NONE;
-       OicUuid_t uuid;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Get Device ID");
-
-       ret = GetDoxmDevOwnerId(&uuid);
-       if (OC_STACK_OK  != ret)
-               MA_LOGE("GetDoxmDevOwnerId faild = [%d][%s]", ret, ma_ocf_error_to_string(ret));
-
-       ret = ConvertUuidToStr(&uuid, uuid_str);
-       if (OC_STACK_OK  != ret)
-               MA_LOGE("ConvertUuidToStr faild = [%d][%s]", ret, ma_ocf_error_to_string(ret));
-
-       return ret;
-}
-
-int ma_request_disc_mot_enb_devs(ma_service *service, int timeout)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Find MOT enabled devices");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _disc_mot_enb_devs(service, timeout);
-
-       return ret;
-}
-
-int ma_request_disc_owned_devs(ma_service *service, int timeout)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Find owned devices");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _disc_owned_devs(service, timeout);
-
-       return ret;
-}
-
-int ma_request_mot(ma_service *service, gchar* uuid_str, gchar *pin)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Do Mullti Ownership Transfer");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       if (!uuid_str || !pin) {
-               MA_LOGE("uuid_str = %s", uuid_str);
-               MA_LOGE("pin = %s", pin);
-               return MA_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _mot(service, uuid_str, pin);
-
-       return ret;
-}
-
-int ma_request_prov_acl(ma_service *service, gchar *target, gchar *subject,
-       gchar *rsrc_uri, gchar *rsrc_type, gchar *rsrc_interface, int permission)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Provisioning ACL");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       ma_check_null_ret_error("target", target, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("subject", subject, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_uri", rsrc_uri, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_type", rsrc_type, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_interface", rsrc_interface, MA_ERROR_INVALID_PARAMETER);
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _acl_provisioning(service, target, subject, rsrc_uri, rsrc_type, rsrc_interface,
-               permission);
-
-       return ret;
-}
-
-int ma_request_prov_cred(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Provisioning credential");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       if (!uuid_dev1 || !uuid_dev2) {
-               MA_LOGE("uuid_dev1 = %s", uuid_dev1);
-               MA_LOGE("uuid_dev2 = %s", uuid_dev2);
-               return MA_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _cred_provisioning(service, uuid_dev1, uuid_dev2);
-
-       return ret;
-}
-
-int ma_request_rsrc_pairwise(ma_service *service, gchar *target_1,
-                                         gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1,
-                                         gchar *rsrc_interface_1, int permission_1,
-                                         gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2,
-                                         gchar *rsrc_type_2, gchar *rsrc_interface_2,
-                                         int permission_2)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Link both resources pairwise");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       ma_check_null_ret_error("target_1", target_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("subject_1", subject_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_uri_1", rsrc_uri_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_type_1", rsrc_type_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_interface_1", rsrc_interface_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("target_2", target_2, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("subject_2", subject_2, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_uri_2", rsrc_uri_2, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_type_2", rsrc_type_2, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_interface_2", rsrc_interface_2, MA_ERROR_INVALID_PARAMETER);
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _resources_pairwise(service, target_1, subject_1, rsrc_uri_1,
-               rsrc_type_1, rsrc_interface_1, permission_1, target_2,
-               subject_2, rsrc_uri_2, rsrc_type_2, rsrc_interface_2,
-               permission_2);
-
-       return ret;
-
-}
-
-int ma_request_unlink_rsrc(ma_service *service, gchar *uuid_dev1,
-                                                gchar *uuid_dev2)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Unlink both devices");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       if (!uuid_dev1 || !uuid_dev2) {
-               MA_LOGE("uuid_dev1 = %s", uuid_dev1);
-               MA_LOGE("uuid_dev2 = %s", uuid_dev2);
-               return MA_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _unlink_resources(service, uuid_dev1, uuid_dev2);
-
-       return ret;
-}
-
-int ma_request_remove_subowner(ma_service *service, gchar* uuid_str)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Remove Mulltiple Ownership");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       if (!uuid_str) {
-               MA_LOGE("uuid_str = %s", uuid_str);
-               return MA_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _ma_remove_subowner(service, uuid_str);
-
-       return ret;
-}
-
-int ma_request_remove_device(ma_service *service, gchar* uuid_str)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Remove target CRED in local SVR");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       if (!uuid_str) {
-               MA_LOGE("uuid_str = %s", uuid_str);
-               return MA_ERROR_INVALID_PARAMETER;
-       }
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _remove_device(service, uuid_str);
-
-       return ret;
-}
-
-int ma_request_pair(ma_service *service, gchar *pin, gchar *target_1,
-                                         gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1,
-                                         gchar *rsrc_interface_1, int permission_1,
-                                         gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2,
-                                         gchar *rsrc_type_2, gchar *rsrc_interface_2,
-                                         int permission_2)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Make both devices pair ");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       ma_check_null_ret_error("pin", pin, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("target_1", target_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("subject_1", subject_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_uri_1", rsrc_uri_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_type_1", rsrc_type_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_interface_1", rsrc_interface_1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("target_2", target_2, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("subject_2", subject_2, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_uri_2", rsrc_uri_2, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_type_2", rsrc_type_2, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("rsrc_interface_2", rsrc_interface_2, MA_ERROR_INVALID_PARAMETER);
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _make_devices_pair(service, pin, target_1, subject_1, rsrc_uri_1,
-                 rsrc_type_1, rsrc_interface_1, permission_1, target_2,
-                 subject_2, rsrc_uri_2, rsrc_type_2, rsrc_interface_2,
-                 permission_2);
-
-       return ret;
-
-}
-
-int ma_request_unpair(ma_service *service, gchar *uuid_dev1,
-                                                gchar *uuid_dev2)
-{
-       int ret = MA_ERROR_NONE;
-
-       ma_check_null_ret_error("g_client", g_client, MA_ERROR_NO_DATA);
-       ma_check_null_ret_error("service", service, FALSE);
-
-       MA_LOGD("[IPC] Make both devices unpair");
-
-       /* If we are working now? */
-       if (g_atomic_int_get(&g_client->pending))
-               return MA_ERROR_IN_PROGRESS;
-
-       ma_check_null_ret_error("uuid_dev1", uuid_dev1, MA_ERROR_INVALID_PARAMETER);
-       ma_check_null_ret_error("uuid_dev2", uuid_dev2, MA_ERROR_INVALID_PARAMETER);
-
-       /* Set d2ds status 'pending' */
-       g_atomic_int_set(&g_client->pending, 1);
-
-       ret = _make_devices_unpair(service, uuid_dev1, uuid_dev2);
-
-       return ret;
-}
-
-int ma_request_enable(ma_service *service)
-{
-       int ret = MA_ERROR_NONE;
-       ma_check_null_ret_error("service", service, FALSE);
-       ret = _init_provision_client();
-       return ret;
-}
-
-int ma_request_disable(ma_service *service)
-{
-       if (NULL == g_client)
-               return MA_ERROR_NONE;
-
-       return _disable(service);
-}
-
-int ma_delete_mot_agent(ma_service *service)
-{
-       int ret = MA_ERROR_NONE;
-
-       NOTUSED(service);
-
-       if (NULL == g_client)
-               return MA_ERROR_NONE;
-
-       /* Wait until worker thread exits */
-       if (g_client->thread) {
-               g_thread_join(g_client->thread);
-               g_thread_unref(g_client->thread);
-               g_client->thread = NULL;
-       }
-
-       /* Stop OCF threads */
-       g_mutex_lock(&g_client->iotivity_mutex);
-       ret = OCStop();
-       g_mutex_unlock(&g_client->iotivity_mutex);
-       if (OC_STACK_OK != ret)
-               MA_LOGE("OCStack stop error");
-
-       /* Stop provisioning */
-       g_mutex_lock(&g_client->iotivity_mutex);
-       OCTerminatePM();
-       g_mutex_unlock(&g_client->iotivity_mutex);
-
-       g_mutex_clear(&g_client->iotivity_mutex);
-
-       /* Remove found devices list */
-       _remove_owned_client();
-       _remove_mot_client();
-
-       /* Remove random PIN number */
-       if (g_client->rnd_pin) {
-               g_free(g_client->rnd_pin);
-               g_client->rnd_pin = NULL;
-       }
-
-       g_free(g_client);
-       g_client = NULL;
-
-       return ret;
-}
-
diff --git a/src/mot-agent/ma-subowner.h b/src/mot-agent/ma-subowner.h
deleted file mode 100644 (file)
index e341507..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MA_SUBONWER_H__
-#define __MA_SUBONWER_H__
-
-#include "ma.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* command id */
-typedef enum {
-       MA_FIND_MOT_ENABLED_DEVICES = 0, /**< Discover MOT enabled devices */
-       MA_FIND_MULTIPLE_OWNED_DEVICES, /**< Discover my owned MOT enabled devices */
-       MA_DO_MOT, /**< Do Multiple Onwership Transfer */
-       MA_DO_ACL_PROVISIONING, /**< ACL Provisioning */
-       MA_DO_CRED_PROVISIONING, /**< CRED Provisioning */
-       MA_UNLINK_RESOURCES, /**< Unlink */
-       MA_REMOVE_MULTIPLE_OWNED_DEVICE, /**< Remove Multiple Ownership */
-       MA_REMOVE_DEVICE_WITH_UUID_IN_SVR, /**< Remove CRED my owned device in MOT agent's SVR DB */
-       MA_MAKE_PAIR, /**< Pair 2 devices */
-       MA_MAKE_UNPAIR, /**< Unpair 2 devices */
-       MA_DO_RESOURCES_PAIRWISE, /** < Pairwise Provisioning */
-} ma_cmd_id_e;
-
-/* ACL Permission type */
-typedef enum {
-       MA_PERMISSION_CREATE =  (1 << 0), /**< C */
-       MA_PERMISSION_READ = (1 << 1), /**< R */
-       MA_PERMISSION_WRITE = (1 << 2), /**< U */
-       MA_PERMISSION_DELETE =  (1 << 3), /**< D */
-       MA_PERMISSION_NOTIFY = (1 << 4), /**< N */
-       MA_PERMISSION_FULL = 0x11111 /**< CRUDN */
-} ma_permission_e;
-
-int ma_request_enable(ma_service *service);
-int ma_request_disable(ma_service *service);
-int ma_request_get_ownerid(ma_service *service, gchar **uuid_str);
-int ma_request_disc_mot_enb_devs(ma_service *service, int timeout);
-int ma_request_disc_owned_devs(ma_service *service, int timeout);
-int ma_request_mot(ma_service *service, gchar* uuid, gchar *pin);
-int ma_request_prov_acl(ma_service *service, gchar *target, gchar *subject,
-       gchar *rsrc_uri, gchar *rsrc_type, gchar *rsrc_interface, int permission);
-int ma_request_prov_cred(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2);
-int ma_request_rsrc_pairwise(ma_service *service, gchar *target_1, gchar *subject_1,
-                                               gchar *rsrc_uri_1, gchar *rsrc_type_1,
-                                               gchar *rsrc_interface_1, int permission_1,
-                                               gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2,
-                                               gchar *rsrc_type_2, gchar *rsrc_interface_2,
-                                               int permission_2);
-int ma_request_unlink_rsrc(ma_service *service, gchar *uuid_dev1, gchar *uuid_dev2);
-int ma_request_remove_subowner(ma_service *service, gchar* uuid_str);
-int ma_request_remove_device(ma_service *service, gchar* uuid_str);
-int ma_request_pair(ma_service *service, gchar *pin, gchar *target_1,
-                                         gchar *subject_1, gchar *rsrc_uri_1, gchar *rsrc_type_1,
-                                         gchar *rsrc_interface_1, int permission_1,
-                                         gchar *target_2, gchar *subject_2, gchar *rsrc_uri_2,
-                                         gchar *rsrc_type_2, gchar *rsrc_interface_2,
-                                         int permission_2);
-int ma_request_unpair(ma_service *service, gchar *uuid_owner, gchar *uuid_owned);
-int ma_delete_mot_agent(ma_service *service);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MA_SUBONWER_H__ */
diff --git a/src/mot-agent/ma-util.c b/src/mot-agent/ma-util.c
deleted file mode 100644 (file)
index f059b1a..0000000
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * Copyright (c) 2018 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 <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <glib.h>
-#include <wifi-manager.h>
-#include <tzplatform_config.h>
-
-#include <iotivity_config.h>
-#include <platform_features.h>
-
-#include "ma.h"
-#include "ma-log.h"
-#include "ma-util.h"
-
-#define CASE_TO_STR(x) case x: return #x;
-const char* ma_ocf_error_to_string(OCStackResult err)
-{
-       switch (err) {
-       /* CHECK: List all enum values here */
-       CASE_TO_STR(OC_STACK_OK)
-       CASE_TO_STR(OC_STACK_RESOURCE_CREATED)
-       CASE_TO_STR(OC_STACK_RESOURCE_DELETED)
-       CASE_TO_STR(OC_STACK_CONTINUE)
-       CASE_TO_STR(OC_STACK_RESOURCE_CHANGED)
-       CASE_TO_STR(OC_STACK_INVALID_URI)
-       CASE_TO_STR(OC_STACK_INVALID_QUERY)
-       CASE_TO_STR(OC_STACK_INVALID_IP)
-       CASE_TO_STR(OC_STACK_INVALID_PORT)
-       CASE_TO_STR(OC_STACK_INVALID_CALLBACK)
-       CASE_TO_STR(OC_STACK_INVALID_METHOD)
-       CASE_TO_STR(OC_STACK_INVALID_PARAM)
-       CASE_TO_STR(OC_STACK_INVALID_OBSERVE_PARAM)
-
-       CASE_TO_STR(OC_STACK_NO_MEMORY)
-       CASE_TO_STR(OC_STACK_COMM_ERROR)
-       CASE_TO_STR(OC_STACK_TIMEOUT)
-       CASE_TO_STR(OC_STACK_ADAPTER_NOT_ENABLED)
-       CASE_TO_STR(OC_STACK_NOTIMPL)
-       CASE_TO_STR(OC_STACK_RESOURCE_ERROR)
-       CASE_TO_STR(OC_STACK_SLOW_RESOURCE)
-       CASE_TO_STR(OC_STACK_DUPLICATE_REQUEST)
-       CASE_TO_STR(OC_STACK_OBSERVER_NOT_FOUND)
-       CASE_TO_STR(OC_STACK_VIRTUAL_DO_NOT_HANDLE)
-       CASE_TO_STR(OC_STACK_INVALID_OPTION)
-       CASE_TO_STR(OC_STACK_MALFORMED_RESPONSE)
-       CASE_TO_STR(OC_STACK_PERSISTENT_BUFFER_REQUIRED)
-
-       CASE_TO_STR(OC_STACK_INVALID_REQUEST_HANDLE)
-       CASE_TO_STR(OC_STACK_INVALID_DEVICE_INFO)
-       CASE_TO_STR(OC_STACK_INVALID_JSON)
-       CASE_TO_STR(OC_STACK_UNAUTHORIZED_REQ)
-       CASE_TO_STR(OC_STACK_TOO_LARGE_REQ)
-       CASE_TO_STR(OC_STACK_PDM_IS_NOT_INITIALIZED)
-       CASE_TO_STR(OC_STACK_DUPLICATE_UUID)
-       CASE_TO_STR(OC_STACK_INCONSISTENT_DB)
-       CASE_TO_STR(OC_STACK_SVR_DB_NOT_EXIST)
-       CASE_TO_STR(OC_STACK_AUTHENTICATION_FAILURE)
-       CASE_TO_STR(OC_STACK_NOT_ALLOWED_OXM)
-#ifdef WITH_PRESENCE
-       CASE_TO_STR(OC_STACK_PRESENCE_STOPPED)
-       CASE_TO_STR(OC_STACK_PRESENCE_TIMEOUT)
-       CASE_TO_STR(OC_STACK_PRESENCE_DO_NOT_HANDLE)
-#endif
-       CASE_TO_STR(OC_STACK_USER_DENIED_REQ)
-       CASE_TO_STR(OC_STACK_NOT_ACCEPTABLE)
-       CASE_TO_STR(OC_STACK_METHOD_NOT_ALLOWED)
-       CASE_TO_STR(OC_STACK_FORBIDDEN_REQ)
-       CASE_TO_STR(OC_STACK_INTERNAL_SERVER_ERROR)
-       CASE_TO_STR(OC_STACK_NOT_IMPLEMENTED)
-       CASE_TO_STR(OC_STACK_BAD_GATEWAY)
-       CASE_TO_STR(OC_STACK_SERVICE_UNAVAILABLE)
-       CASE_TO_STR(OC_STACK_GATEWAY_TIMEOUT)
-       CASE_TO_STR(OC_STACK_PROXY_NOT_SUPPORTED)
-       CASE_TO_STR(OC_STACK_ERROR)
-       default :
-               return "Unknown Error";
-       }
-}
-
-const char* ma_wifi_error_to_string(wifi_manager_error_e err)
-{
-       switch (err) {
-       /* CHECK: List all enum values here */
-       CASE_TO_STR(WIFI_MANAGER_ERROR_NONE)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_INVALID_PARAMETER)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_OUT_OF_MEMORY)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_INVALID_OPERATION)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_OPERATION_FAILED)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_NO_CONNECTION)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_NOW_IN_PROGRESS)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_ALREADY_EXISTS)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_OPERATION_ABORTED)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_DHCP_FAILED)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_INVALID_KEY)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_NO_REPLY)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_SECURITY_RESTRICTED)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_ALREADY_INITIALIZED)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_PERMISSION_DENIED)
-       CASE_TO_STR(WIFI_MANAGER_ERROR_NOT_SUPPORTED)
-       default :
-               return "WIFI_MANAGER_ERROR_UNKNOWN";
-       }
-}
-
-const char * ma_erro_to_string(ma_error_e err)
-{
-       switch (err) {
-       /* CHECK: List all enum values here */
-       CASE_TO_STR(MA_ERROR_NONE)
-       CASE_TO_STR(MA_ERROR_IO_ERROR)
-       CASE_TO_STR(MA_ERROR_INVALID_PARAMETER)
-       CASE_TO_STR(MA_ERROR_OUT_OF_MEMORY)
-       CASE_TO_STR(MA_ERROR_PERMISSION_DENIED)
-       CASE_TO_STR(MA_ERROR_NOT_SUPPORTED)
-       CASE_TO_STR(MA_ERROR_NO_DATA)
-       CASE_TO_STR(MA_ERROR_OPERATION_FAILED)
-       CASE_TO_STR(MA_ERROR_ALREADY_REGISTERED)
-       CASE_TO_STR(MA_ERROR_IN_PROGRESS)
-       CASE_TO_STR(MA_ERROR_COMM_ERROR)
-       CASE_TO_STR(MA_ERROR_RX)
-       CASE_TO_STR(MA_ERROR_TX)
-       CASE_TO_STR(MA_ERROR_PLUGIN_FAIL)
-       CASE_TO_STR(MA_ERROR_ALREADY_IN_PROGRESS)
-       CASE_TO_STR(MA_ERROR_NOT_STARTED)
-       CASE_TO_STR(MA_ERROR_ALREADY_INITIALIZED)
-       CASE_TO_STR(MA_ERROR_UNKNOWN)
-       default :
-               return "Unknown Error";
-       }
-}
-
-OicUuid_t* ma_convert_uuid(gchar *device_id)
-{
-       OicUuid_t *uuid;
-
-       if (NULL == device_id)
-               return NULL;
-
-       uuid = g_malloc0(sizeof(struct OicUuid));
-       if (NULL == uuid) {
-               MA_LOGE("g_malloc0() Fail(%d)", errno);
-               return NULL;
-       }
-
-       sscanf(&device_id[0], "%2hhx", &uuid->id[0]);
-       sscanf(&device_id[2], "%2hhx", &uuid->id[1]);
-       sscanf(&device_id[4], "%2hhx", &uuid->id[2]);
-       sscanf(&device_id[6], "%2hhx", &uuid->id[3]);
-       /* device_id[8] == '-' */
-       sscanf(&device_id[9], "%2hhx", &uuid->id[4]);
-       sscanf(&device_id[11], "%2hhx", &uuid->id[5]);
-       /* device_id[13] == '-' */
-       sscanf(&device_id[14], "%2hhx", &uuid->id[6]);
-       sscanf(&device_id[16], "%2hhx", &uuid->id[7]);
-       /* device_id[18] == '-' */
-       sscanf(&device_id[19], "%2hhx", &uuid->id[8]);
-       sscanf(&device_id[21], "%2hhx", &uuid->id[9]);
-       /* device_id[23] == '-' */
-       sscanf(&device_id[24], "%2hhx", &uuid->id[10]);
-       sscanf(&device_id[26], "%2hhx", &uuid->id[11]);
-       sscanf(&device_id[28], "%2hhx", &uuid->id[12]);
-       sscanf(&device_id[30], "%2hhx", &uuid->id[13]);
-       sscanf(&device_id[32], "%2hhx", &uuid->id[14]);
-       sscanf(&device_id[34], "%2hhx", &uuid->id[15]);
-
-       return uuid;
-}
-
-char g_uuid_str[256] = {0};
-char * ma_get_readable_uuid(const OicUuid_t* uuid)
-{
-       memset(g_uuid_str, 0, sizeof(g_uuid_str));
-       snprintf(g_uuid_str, sizeof(g_uuid_str),
-               "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-               (*uuid).id[0], (*uuid).id[1], (*uuid).id[2], (*uuid).id[3],
-               (*uuid).id[4], (*uuid).id[5],  (*uuid).id[6], (*uuid).id[7],
-               (*uuid).id[8], (*uuid).id[9],  (*uuid).id[10], (*uuid).id[11],
-               (*uuid).id[12], (*uuid).id[13], (*uuid).id[14], (*uuid).id[15]);
-       return g_uuid_str;
-}
-
-#ifdef TEST
-OCProvisionDev_t* ma_get_dev_by_id(const OCProvisionDev_t* dev_lst,
-       const int dev_num)
-{
-       if (!dev_lst || 0 >= dev_num) {
-               MA_LOGI("Device List is Empty..\n");
-               return NULL;
-       }
-
-       OCProvisionDev_t* lst = (OCProvisionDev_t*) dev_lst;
-       for (int i = 0; lst; ) {
-               if (dev_num == ++i)
-                       return lst;
-               lst = lst->next;
-       }
-       return NULL;
-}
-#endif
-
-OCProvisionDev_t* ma_get_dev_by_uuid(const OCProvisionDev_t* dev_lst,
-       const OicUuid_t* uuid)
-{
-       if (!dev_lst) {
-               MA_LOGI("dev_lst is empty");
-               return NULL;
-       }
-
-       if (!uuid) {
-               MA_LOGI("uuid is NULL");
-               return NULL;
-       }
-
-#ifdef DEBUG_UUID
-               MA_LOGD("[T] : %s", ma_get_readable_uuid(uuid));
-#endif
-       OCProvisionDev_t* lst = (OCProvisionDev_t*)dev_lst;
-       while (lst) {
-#ifdef DEBUG_UUID
-               MA_LOGD("[C] : %s", ma_get_readable_uuid(&lst->doxm->deviceID));
-#endif
-               if (!memcmp((const void *)&lst->doxm->deviceID, (const void *)uuid,
-                       sizeof(OicUuid_t))) {
-                       MA_LOGD("[M] : %s", ma_get_readable_uuid(&lst->doxm->deviceID));
-                       return lst;
-               }
-               lst = lst->next;
-       }
-
-       return NULL;
-}
-
-int ma_print_dev_list(const OCProvisionDev_t* dev_lst)
-{
-       if (!dev_lst) {
-               MA_LOGI("Device List is Empty..\n\n");
-               return 0;
-       }
-
-       OCProvisionDev_t* lst = (OCProvisionDev_t*) dev_lst;
-       int lst_cnt = 0;
-       for ( ; lst; ) {
-               MA_LOGI("[%d] %s", ++lst_cnt, ma_get_readable_uuid((const OicUuid_t*)
-                       &lst->doxm->deviceID));
-               lst = lst->next;
-       }
-
-       return lst_cnt;
-}
-
-int ma_print_result_list(const OCProvisionResult_t* rslt_lst, const int rslt_cnt)
-{
-       if (!rslt_lst || 0 >= rslt_cnt) {
-               MA_LOGI("     Device List is Empty..\n\n");
-               return 0;
-       }
-
-       int lst_cnt = 0;
-       for (; rslt_cnt > lst_cnt; ++lst_cnt) {
-               MA_LOGD("%s : [%d][%s]",
-                       ma_get_readable_uuid((const OicUuid_t*) &rslt_lst[lst_cnt].deviceId),
-                       rslt_lst[lst_cnt].res, ma_ocf_error_to_string(rslt_lst[lst_cnt].res));
-       }
-
-       return lst_cnt;
-}
-
-#if 0
-int ma_set_device_id_seed(void)
-{
-       int ret = WIFI_MANAGER_ERROR_NONE;
-       gchar *mac_addr = NULL;
-       gchar *test_mac = "00:12:36:11:22:33";
-
-       wifi_manager_h wifi_handle = NULL;
-       bool wifi_activated = false;
-
-       /* Initialize Wi-Fi driver */
-       ret = wifi_manager_initialize(&wifi_handle);
-       if (WIFI_MANAGER_ERROR_NONE != ret)
-               MA_LOGE("Failed to get wifi manager handle ! [%d][%s]",
-               ret, ma_wifi_error_to_string(ret));
-
-       wifi_manager_is_activated(wifi_handle, &wifi_activated);
-       if (false == wifi_activated) {
-               ret = wifi_manager_activate(wifi_handle, NULL, NULL);
-               if (WIFI_MANAGER_ERROR_NONE != ret)
-                       MA_LOGE("Failed to activate wifi ! [%d][%s]",
-                       ret, ma_wifi_error_to_string(ret));
-       }
-
-       ret = wifi_manager_get_mac_address(wifi_handle, &mac_addr);
-       if (WIFI_MANAGER_ERROR_NONE != ret) {
-               MA_LOGE("Fail to get MAC address  [%d][%s]", ret, ma_wifi_error_to_string(ret));
-               /* Make deviceID based on Fake MAC address */
-               ret = SetDeviceIdSeed((const guchar *)test_mac, WIFI_MAC_ADDR_LENGTH);
-       } else {
-               /* Make deviceID based on Wi-Fi MAC address */
-               ret = SetDeviceIdSeed((const guchar *)mac_addr, WIFI_MAC_ADDR_LENGTH);
-               g_free(mac_addr);
-       }
-       if (OC_STACK_OK != ret)
-               MA_LOGE("SetDeviceIdSeed() error = [%d][%s]", ret, ma_ocf_error_to_string(ret));
-
-       wifi_manager_deinitialize(wifi_handle);
-       return  ret;
-}
-#endif
-
-#if 0
-static OCProvisionDev_t* _clone_ocprovision_dev(const OCProvisionDev_t* src)
-{
-       MA_LOGD("");
-
-       if (!src) {
-               MA_LOGD("Invalid parameter");
-               return NULL;
-       }
-
-       OCProvisionDev_t* newDev = g_try_malloc0(sizeof(OCProvisionDev_t));
-
-       memcpy(&newDev->endpoint, &src->endpoint, sizeof(OCDevAddr));
-
-       if (src->pstat) {
-               newDev->pstat = g_try_malloc0(sizeof(OicSecPstat_t));
-
-               memcpy(newDev->pstat, src->pstat, sizeof(OicSecPstat_t));
-               // We have to assign NULL for not necessary information to prevent memory corruption.
-               newDev->pstat->sm = g_try_malloc0(sizeof(OicSecDpom_t));
-               memcpy(newDev->pstat->sm, src->pstat->sm, sizeof(OicSecDpom_t));
-       }
-
-       if (src->doxm) {
-               newDev->doxm = g_try_malloc0(sizeof(OicSecDoxm_t));
-
-               memcpy(newDev->doxm, src->doxm, sizeof(OicSecDoxm_t));
-
-               newDev->doxm->oxmType = g_try_malloc0(src->doxm->oxmTypeLen + 1);
-               memcpy(newDev->doxm->oxmType, src->doxm->oxmType,
-                          src->doxm->oxmTypeLen);
-
-               newDev->doxm->oxm = g_try_malloc0(sizeof(OicSecOxm_t));
-               memcpy(newDev->doxm->oxm, src->doxm->oxm, sizeof(OicSecOxm_t));
-
-               newDev->doxm->mom = g_try_malloc0(sizeof(OicSecMom_t));
-               memcpy(newDev->doxm->mom, src->doxm->mom, sizeof(OicSecMom_t));
-
-               if (src->doxm->subOwners) {
-                       int count = 0;
-                       OicSecSubOwner_t* subowner = NULL;
-                       OicSecSubOwner_t* temp = NULL;
-                       OicSecSubOwner_t* temp2 = NULL;
-                       OicSecSubOwner_t* temp3 = NULL;
-                       LL_FOREACH_SAFE(src->doxm->subOwners, subowner, temp) {
-                               temp2 = g_try_malloc0(sizeof(OicSecSubOwner_t));
-                               temp3 = subowner;
-                               temp3->next = NULL;
-                               memcpy(temp2, temp3, sizeof(OicSecSubOwner_t));
-                               LL_PREPEND(newDev->doxm->subOwners, temp2);
-                       }
-                       LL_COUNT(newDev->doxm->subOwners, subowner, count);
-                       MA_LOGD("newdev subowner count %d", count);
-               }
-       }
-
-       if (0 == strlen(src->secVer))
-               g_strlcpy(newDev->secVer, "0.0.0", OIC_SEC_MAX_VER_LEN);
-       else
-               g_strlcpy(newDev->secVer, src->secVer, OIC_SEC_MAX_VER_LEN);
-
-       newDev->securePort = src->securePort;
-       newDev->devStatus = src->devStatus;
-       newDev->connType = src->connType;
-       newDev->next = NULL;
-
-       return newDev;
-}
-#endif
-
-int ConvertUuidToStr(const OicUuid_t* uuid, char** strUuid)
-{
-       if (NULL == uuid || NULL == strUuid || NULL != *strUuid) {
-               MA_LOGE("ConvertUuidToStr : Invalid param");
-               return OC_STACK_INVALID_PARAM;
-       }
-
-       size_t uuidIdx = 0;
-       size_t urnIdx = 0;
-       const size_t urnBufSize = (UUID_LENGTH * 2) + 4 + 1;
-       char* convertedUrn = (char*)calloc(urnBufSize, sizeof(char));
-       if (NULL == convertedUrn) {
-               MA_LOGE("Memory Allocation Failed");
-               goto exit;
-       }
-
-       for (uuidIdx = 0, urnIdx = 0; uuidIdx < UUID_LENGTH && urnIdx < urnBufSize;
-               uuidIdx++, urnIdx += 2) {
-               // canonical format for UUID has '8-4-4-4-12'
-               if (uuidIdx == 4 || uuidIdx == 6 || uuidIdx == 8 || uuidIdx == 10) {
-                       snprintf(convertedUrn + urnIdx, 2, "%c", '-');
-                       urnIdx++;
-               }
-               snprintf(convertedUrn + urnIdx, 3, "%02x", (uint8_t)(uuid->id[uuidIdx]));
-       }
-       convertedUrn[urnBufSize - 1] = '\0';
-
-       *strUuid = convertedUrn;
-       return OC_STACK_OK;
-
-exit:
-       return OC_STACK_NO_MEMORY;
-}
diff --git a/src/mot-agent/ma-util.h b/src/mot-agent/ma-util.h
deleted file mode 100644 (file)
index 2ec8b81..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MA_UTIL_H__
-#define __MA_UTIL_H__
-
-#include <glib.h>
-#include <unistd.h>
-#include <gio/gio.h>
-
-#include <wifi-manager.h>
-
-#include <octypes.h>
-#include <pmtypes.h>
-#include <pmutility.h>
-#include <securevirtualresourcetypes.h>
-
-#include "ma-log.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define DEBUG_UUID /**< To print device uuid */
-
-#define WIFI_MAC_ADDR_LENGTH 17 /**< Wi-Fi MAC address size */
-
-#define NOTUSED(var) (var = var)
-
-#define ma_check_null_ret_error(name, value, error) do { \
-               if (G_UNLIKELY(NULL == (value))) { \
-                                       MA_LOGE("%s is NULL", name); \
-                                       return error; \
-                               } \
-} while (FALSE)
-
-#define ma_check_null_ret(name, value) do { \
-               if (G_UNLIKELY(NULL == (value))) { \
-                                       MA_LOGE("%s is NULL", name); \
-                                       return; \
-                               } \
-} while (FALSE)
-
-const char* ma_ocf_error_to_string(OCStackResult err);
-const char* ma_wifi_error_to_string(wifi_manager_error_e err);
-const char * ma_erro_to_string(ma_error_e err);
-OicUuid_t* ma_convert_uuid(gchar *device_id);
-char * ma_get_readable_uuid(const OicUuid_t* uuid);
-#ifdef TEST
-OCProvisionDev_t* ma_get_dev_by_id(const OCProvisionDev_t* dev_lst, const int dev_num);
-#endif
-OCProvisionDev_t* ma_get_dev_by_uuid(const OCProvisionDev_t* dev_lst,
-       const OicUuid_t* uuid);
-int ma_print_dev_list(const OCProvisionDev_t* dev_lst);
-int ma_print_result_list(const OCProvisionResult_t* rslt_lst, const int rslt_cnt);
-int ma_set_device_id_seed(void);
-
-#if 0
-static OCProvisionDev_t* _clone_ocprovision_dev(const OCProvisionDev_t* src);
-#endif
-int ConvertUuidToStr(const OicUuid_t* uuid, char** strUuid);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __MA_UTIL_H__ */
diff --git a/src/mot-agent/ma.c b/src/mot-agent/ma.c
deleted file mode 100644 (file)
index fcd6b41..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2018 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include "ma.h"
-#include "ma-log.h"
-#include "ma-util.h"
-#include "ma-service.h"
-#include "ma-service-interface.h"
-
-/**< d2d-subowner service */
-ma_service *d2dssvc;
-
-int main(int argc, char *argv[])
-{
-       ma_service *service = NULL;
-       int ret_code = 0;
-       gboolean ret;
-
-       __MA_LOG_FUNC_ENTER__;
-
-#if !GLIB_CHECK_VERSION(2, 32, 0)
-       if (!g_thread_supported())
-               g_thread_init(NULL);
-#endif
-
-#if !GLIB_CHECK_VERSION(2, 36, 0)
-       g_type_init();
-#endif
-       NOTUSED(argc);
-       NOTUSED(argv);
-
-       MA_LOGI("service mainloop start");
-
-       /* Create MOT agent */
-       d2dssvc = service = ma_service_new();
-
-       /* Initialize MOT agent service interface layer */
-       ret = ma_service_interface_init(service);
-       if (G_UNLIKELY(FALSE == ret)) {
-               MA_LOGE("Service interface init. failed!");
-               ret_code = EXIT_FAILURE;
-               goto END;
-       }
-       /* Run MOT agent service */
-       ret = ma_service_run(service);
-       if (G_UNLIKELY(FALSE == ret)) {
-               MA_LOGE("Run service failed!");
-               ret_code = EXIT_FAILURE;
-       }
-
-END:
-       /* Free MOT agent service */
-       ma_service_interface_deinit(service);
-       ma_service_free(service);
-       d2dssvc = NULL;
-
-       __MA_LOG_FUNC_EXIT__;
-       return ret_code;
-}
-
diff --git a/src/mot-agent/ma.h b/src/mot-agent/ma.h
deleted file mode 100644 (file)
index 9ab7227..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2018 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 __MA_AGENT_H__
-#define __MA_AGENT_H__
-
-#include <glib.h>
-#include <gio/gio.h>
-#include <tizen.h>
-
-#ifndef TIZEN_ERROR_MDG
-#define TIZEN_ERROR_MDG -0x02F50000 /**< Base error code */
-#endif
-
-/**< Internal error code with d2ds daemon. It should be matched with API side */
-typedef enum {
-       MA_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
-       MA_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
-       MA_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
-       MA_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
-       MA_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
-       MA_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
-       MA_ERROR_NO_DATA = TIZEN_ERROR_MDG | 0x01, /**< Data not exists */
-       MA_ERROR_OPERATION_FAILED = TIZEN_ERROR_MDG | 0x02, /**< operation failed */
-       MA_ERROR_ALREADY_REGISTERED = TIZEN_ERROR_MDG | 0x03, /**< Request already registered */
-       MA_ERROR_IN_PROGRESS = TIZEN_ERROR_MDG | 0x04,/**< operation is in progress */
-       MA_ERROR_COMM_ERROR = TIZEN_ERROR_MDG | 0x05, /**< communication error */
-       MA_ERROR_RX = TIZEN_ERROR_MDG | 0x06, /**< RX error */
-       MA_ERROR_TX = TIZEN_ERROR_MDG | 0x07, /**< TX error */
-       MA_ERROR_PLUGIN_FAIL = TIZEN_ERROR_MDG | 0x08, /**< Plugin failed */
-       MA_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_MDG | 0x09, /**< Already in progress */
-       MA_ERROR_NOT_STARTED = TIZEN_ERROR_MDG | 0x0A, /**< Not Started */
-       MA_ERROR_ALREADY_INITIALIZED = TIZEN_ERROR_MDG | 0x0B, /**< Already initilized */
-       MA_ERROR_UNKNOWN = -999,
-} ma_error_e;
-
-/**< d2d-subowner service structure */
-typedef struct _ma_service {
-       GMainLoop *main_loop; /**< Service main-loop */
-       guint dbus_id; /**< D-Bus id */
-       guint activation_dbus_id; /**< D-Bus id for activation */
-       gpointer connection; /**< Connection handle for D-Bus call to other process */
-       GCancellable *ca; /**< Cancellable object for D-Bus call (Daemon->other) */
-       GList *dbus_sub_ids; /**< The list of subscribed signals */
-       gboolean ma_activated; /**< Whether d2d-manager enabled or not */
-} ma_service;
-
-#endif /* __MA_AGENT_H__ */
-
diff --git a/src/mot-agent/oic_svr_db_ma.dat b/src/mot-agent/oic_svr_db_ma.dat
deleted file mode 100644 (file)
index 7b089cb..0000000
Binary files a/src/mot-agent/oic_svr_db_ma.dat and /dev/null differ
diff --git a/src/mot-agent/oic_svr_db_ma.json b/src/mot-agent/oic_svr_db_ma.json
deleted file mode 100644 (file)
index 7942689..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-{
-    "acl": {
-        "aclist": {
-            "aces": [
-                {
-                    "subjectuuid": "*",
-                    "resources": [
-                        {
-                            "href": "/oic/res",
-                            "rel": "",
-                            "rt": ["oic.wk.res"],
-                            "if": ["oic.if.ll"]
-                        },{
-                            "href": "/oic/d",
-                            "rel": "",
-                            "rt": ["oic.wk.d"],
-                            "if": ["oic.if.baseline", "oic.if.r"]
-                        },{
-                            "href": "/oic/p",
-                            "rel": "",
-                            "rt": ["oic.wk.p"],
-                            "if": ["oic.if.baseline", "oic.if.r"]
-                        }
-                    ],
-                    "permission": 2
-                },
-                {
-                    "subjectuuid": "*",
-                    "resources": [
-                        {
-                            "href": "/oic/sec/doxm",
-                            "rel": "",
-                            "rt": ["oic.r.doxm"],
-                            "if": ["oic.if.baseline"]
-                        },
-                        {
-                            "href": "/oic/sec/pstat",
-                            "rel": "",
-                            "rt": ["oic.r.pstat"],
-                            "if": ["oic.if.baseline"]
-                        },
-                        {
-                            "href": "/oic/sec/cred",
-                            "rel": "",
-                            "rt": ["oic.r.cred"],
-                            "if": ["oic.if.baseline"]
-                        }
-                    ],
-                    "permission": 6
-                }
-            ]
-        },
-        "rowneruuid": "00000000-0000-0000-0000-000000000000"
-    },
-    "pstat": {
-        "isop": false,
-        "deviceuuid": "00000000-0000-0000-0000-000000000000",
-        "rowneruuid": "00000000-0000-0000-0000-000000000000",
-        "cm": 2,
-        "tm": 0,
-        "om": 4,
-        "sm": 4
-     },
-    "doxm": {
-        "oxms": [0],
-        "oxmsel": 0,
-        "sct": 0,
-        "owned": false,
-        "deviceuuid": "00000000-0000-0000-0000-000000000000",
-        "devowneruuid": "",
-        "rowneruuid": "00000000-0000-0000-0000-000000000000"
-    }
-}
diff --git a/test.pcap b/test.pcap
deleted file mode 100644 (file)
index 8614349..0000000
Binary files a/test.pcap and /dev/null differ
similarity index 100%
rename from capi/test/CMakeLists.txt
rename to test/CMakeLists.txt
similarity index 100%
rename from capi/test/common.h
rename to test/common.h
similarity index 100%
rename from capi/test/main.c
rename to test/main.c
similarity index 99%
rename from capi/test/mdg-manager.c
rename to test/mdg-manager.c
index 281d7ff..46fd594 100644 (file)
@@ -36,8 +36,10 @@ static char groupid[MENU_DATA_SIZE + 1] = "mygroup";
 static char request_groupid[MENU_DATA_SIZE + 1] = "subgroup";
 static char timeout[MENU_DATA_SIZE + 1] = "2";
 static char group_idx[MENU_DATA_SIZE + 1] = "1";
+#if 0
 static char group_idx_a[MENU_DATA_SIZE + 1] = "1";
 static char group_idx_b[MENU_DATA_SIZE + 1] = "2";
+#endif
 static char device_idx[MENU_DATA_SIZE + 1] = "1";
 static char pin[MENU_DATA_SIZE + 1] = "12341234";
 static char message[MENU_DATA_SIZE + 1] = "Hello World!!";
@@ -355,7 +357,7 @@ static int run_group_get_members(MManager *mm, struct menu_data *menu)
        return RET_SUCCESS;
 }
 #endif
-
+#if 0
 static int run_group_merge(MManager *mm, struct menu_data *menu)
 {
        int ret;
@@ -407,6 +409,7 @@ static int run_group_merge(MManager *mm, struct menu_data *menu)
 
        return RET_SUCCESS;
 }
+#endif
 
 static int run_group_delete(MManager *mm, struct menu_data *menu)
 {
@@ -1255,7 +1258,7 @@ static struct menu_data menu_group_delete[] = {
        { "2", "Run", NULL, run_group_delete, NULL },
        { NULL, NULL, },
 };
-
+#if 0
 static struct menu_data menu_group_merge[] = {
        { "0", "Show Found Group(s)", NULL, run_group_show, NULL },
        { "1", "A Index", NULL, NULL, group_idx_a },
@@ -1263,7 +1266,7 @@ static struct menu_data menu_group_merge[] = {
        { "3", "Run", NULL, run_group_merge, NULL },
        { NULL, NULL, },
 };
-
+#endif
 static struct menu_data menu_devices_find[] = {
        { "0", "Timeout", NULL, NULL, timeout },
        { "1", "Run", NULL, run_devices_find, NULL },
similarity index 100%
rename from capi/test/mdg-test.c
rename to test/mdg-test.c
similarity index 100%
rename from capi/test/menu.c
rename to test/menu.c
similarity index 100%
rename from capi/test/menu.h
rename to test/menu.h