d2d-manager: add doc.h and change of copyright enforcement year
authorsaerome.kim <saerome.kim@samsung.com>
Thu, 29 Mar 2018 02:26:19 +0000 (11:26 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:49 +0000 (19:38 +0900)
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
47 files changed:
capi/demo/common.h
capi/demo/comp-manager.c
capi/demo/companion_demo.c
capi/demo/main.c
capi/demo/menu.c
capi/demo/menu.h
capi/doc/companion_doc.h [new file with mode: 0644]
capi/include/companion.h
capi/src/companion.c
capi/src/companion_dbus.c
capi/src/companion_dbus.h
capi/src/companion_debug.h
capi/src/companion_private.h
capi/src/companion_util.c
capi/src/companion_util.h
capi/unittest/companion_unit_test.cpp
src/companion-manager/include/comp_context.h
src/companion-manager/include/comp_enum.h
src/companion-manager/include/comp_gdbus.h
src/companion-manager/include/comp_gdbus_group.h
src/companion-manager/include/comp_group.h
src/companion-manager/include/comp_iot.h
src/companion-manager/include/comp_log.h
src/companion-manager/include/comp_manager.h
src/companion-manager/include/comp_mot_agent.h
src/companion-manager/include/comp_resource.h
src/companion-manager/src/comp_context.c
src/companion-manager/src/comp_gdbus.c
src/companion-manager/src/comp_gdbus_group.c
src/companion-manager/src/comp_group.c
src/companion-manager/src/comp_iot.cpp
src/companion-manager/src/comp_log.c
src/companion-manager/src/comp_manager.c
src/companion-manager/src/comp_mot_agent.c
src/companion-manager/src/comp_resource.c
src/include/d2d-log.h
src/mot-agent/ma-log.h
src/mot-agent/ma-service-interface.c
src/mot-agent/ma-service-interface.h
src/mot-agent/ma-service.c
src/mot-agent/ma-service.h
src/mot-agent/ma-subowner.c
src/mot-agent/ma-subowner.h
src/mot-agent/ma-util.c
src/mot-agent/ma-util.h
src/mot-agent/ma.c
src/mot-agent/ma.h

index a14df50..dd29976 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index fc40042..4263878 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 9fd72a2..a0c878d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 41e5372..4dca2d6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index e3a38d3..c217f6b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 5959d55..728d36c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
diff --git a/capi/doc/companion_doc.h b/capi/doc/companion_doc.h
new file mode 100644 (file)
index 0000000..5a8d097
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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 __TIZEN_NETWORK_COMPANION_DOC_H__
+#define __TIZEN_NETWORK_COMPANION_DOC_H__
+
+/**
+ * @ingroup CAPI_NETWORK_FRAMEWORK
+ * @defgroup CAPI_NETWORK_COMPANION_MODULE Companion Manager
+ * @brief The Companion API provides functions for group management of devices.
+ *
+ * @section CAPI_NETWORK_COMPANION_MODULE_HEADER Required Header
+ *   \#include <companion.h>
+ *
+ * @section CAPI_NETWORK_COMPANION_MODULE_OVERVIEW Overview
+ * Companion Device Management(CDM) is a term for the group managenet of smart devices, such as smartphones, wearable devices, televisions, spakers and home appliances in a local network.
+ * The CDM is implemented with the use of an open souce project 'IoTivity' that has D2D management features for various vendors of smart devices.
+ * The CDM functionality can provide groupe management of devices, sending data securely and configuraion settings for all types of smart devices baseed on 'OCF', including smartphones, wearable devices, TVs, home appliances, speakers, IoT things, etc.
+ *
+ * @section CAPI_NETWORK_COMPANION_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.d2d.companion\n
+ *
+ * It is recommended to design applications with regard to features, for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>Feature Element</b>.</a>
+ *
+ */
+
+#endif /* __TIZEN_NETWORK_COMPANION_DOC_H__ */
index 9e7bb33..9bc2f1a 100644 (file)
@@ -16,8 +16,8 @@
  * limitations under the License.
  *
  */
-#ifndef __TIZEN_NETWORK_COMMON_COMPANION_H__
-#define __TIZEN_NETWORK_COMMON_COMPANION_H__
+#ifndef __TIZEN_NETWORK_COMPANION_H__
+#define __TIZEN_NETWORK_COMPANION_H__
 
 #include <tizen.h>
 
@@ -30,7 +30,7 @@ extern "C" {
  */
 
 /**
- * @addtogroup CAPI_NETWORK_COMMON_COMPANION_MODULE
+ * @addtogroup CAPI_NETWORK_COMPANION_MODULE
  * @{
  */
 
@@ -1065,8 +1065,9 @@ int companion_request_create_group(companion_h handle,
 
 /**
  * @brief Requests to invite a device to the group.
- * @details This function invites a remote device to a specific group. At the time of invitation,
- * user can enter the authentication information (i.e., PIN) or use the certificate.
+ * @details This function invites a remote device to a specific group. At the time of
+ * invitation, user can enter the authentication information (i.e., PIN) or use the
+ * certificate.
  *
  * @since_tizen 5.0
  *
@@ -1172,4 +1173,4 @@ int companion_request_result_callback(companion_h handle,
 }
 #endif
 
-#endif /* __TIZEN_NETWORK_COMMON_COMPANION_H__ */
\ No newline at end of file
+#endif /* __TIZEN_NETWORK_COMPANION_H__ */
\ No newline at end of file
index 1455ade..2775ce0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 7a7a43f..e911c87 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index b77b296..fdc5f06 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
  *
  */
 
-#ifndef __TIZEN_NETWORK_COMMON_COMPANION_DBUS_INTERNAL_H__
-#define __TIZEN_NETWORK_COMMON_COMPANION_DBUS_INTERNAL_H__
+#ifndef __TIZEN_NETWORK_COMPANION_DBUS_INTERNAL_H__
+#define __TIZEN_NETWORK_COMPANION_DBUS_INTERNAL_H__
 
 #include <companion_private.h>
 
 int gdbus_initialize(comp_manager_s *handle);
 int gdbus_deinitialize(comp_manager_s *handle);
 
-#endif /* __TIZEN_NETWORK_COMMON_COMPANION_DBUS_INTERNAL_H__ */
+#endif /* __TIZEN_NETWORK_COMPANION_DBUS_INTERNAL_H__ */
index 7ab8293..ec89586 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
@@ -15,8 +15,8 @@
  *
  */
 
-#ifndef __TIZEN_NETWORK_COMMON_COMPANION_DEBUG_H__
-#define __TIZEN_NETWORK_COMMON_COMPANION_DEBUG_H__
+#ifndef __TIZEN_NETWORK_COMPANION_DEBUG_H__
+#define __TIZEN_NETWORK_COMPANION_DEBUG_H__
 
 #include <dlog.h>
 
 #define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
 #define TC_PRT(format, args...) PRT(format"\n", ##args)
 
-#endif /* __TIZEN_NETWORK_COMMON_COMPANION_DEBUG_H__ */
+#endif /* __TIZEN_NETWORK_COMPANION_DEBUG_H__ */
index 44c8a8c..26f6463 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
@@ -26,7 +26,7 @@
 
 #include <system_info.h>
 
-#define COMPANION_FEATURE "http://tizen.org/feature/network.companion"
+#define COMPANION_FEATURE "http://tizen.org/feature/network.d2d.companion"
 
 #define CHECK_INPUT_PARAMETER(arg) \
        if (arg == NULL) { \
index 497735d..84a8e63 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index db7314e..6fbb635 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 2bab208..2a5414a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 573edbd..e1c9c5c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 577766c..87dc9a2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 77ac1ea..059e08e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index c12b1e6..ebb8fe0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 22d86ac..468c337 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index dfdccdf..cc31b3a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 90f60b8..9aaf017 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 50ae748..b090179 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index d647610..c4537a2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index e767838..f5d7885 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 6a5b3ec..7aeb82f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 5ed0468..1c05cbb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index a66a5d8..21ab0c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index accf31a..001829a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index cc8c281..9acbd68 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 23346d0..0e3238d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index e9eff6c..ddc8c67 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index a43bda4..e2016f3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 7502b0c..1c189fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 3898a24..acf6448 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- */\r
-\r
-#ifndef __D2D_LOG_H__\r
-#define __D2D_LOG_H__\r
-\r
-#ifdef LOG_TAG\r
-#undef LOG_TAG\r
-#endif\r
-\r
-#ifdef USE_DLOG\r
-#include <dlog.h>\r
-\r
-#undef LOG_TAG\r
-#define LOG_TAG "D2D_COMMON"\r
-\r
-#define D2D_LOGV(format, args...) LOGV(format, ##args)\r
-#define D2D_LOGD(format, args...) LOGD(format, ##args)\r
-#define D2D_LOGI(format, args...) LOGI(format, ##args)\r
-#define D2D_LOGW(format, args...) LOGW(format, ##args)\r
-#define D2D_LOGE(format, args...) LOGE(format, ##args)\r
-#define D2D_LOGF(format, args...) LOGF(format, ##args)\r
-\r
-#define __D2D_LOG_FUNC_ENTER__ LOGD("Enter")\r
-#define __D2D_LOG_FUNC_EXIT__ LOGD("Quit")\r
-\r
-#define D2D_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)\r
-#define D2D_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)\r
-\r
-#else /* USE_DLOG */\r
-\r
-#define D2D_LOGV(format, args...)\r
-#define D2D_LOGD(format, args...)\r
-#define D2D_LOGI(format, args...)\r
-#define D2D_LOGW(format, args...)\r
-#define D2D_LOGE(format, args...)\r
-#define D2D_LOGF(format, args...)\r
-\r
-#define __D2D_LOG_FUNC_ENTER__\r
-#define __D2D_LOG_FUNC_EXIT__\r
-\r
-#define D2D_SECLOGI(format, args...)\r
-#define D2D_SECLOGD(format, args...)\r
-\r
-#endif /* USE_DLOG */\r
-\r
-#endif /* __D2D_LOG_H__ */\r
+ */
+
+#ifndef __D2D_LOG_H__
+#define __D2D_LOG_H__
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#ifdef USE_DLOG
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "D2D_COMMON"
+
+#define D2D_LOGV(format, args...) LOGV(format, ##args)
+#define D2D_LOGD(format, args...) LOGD(format, ##args)
+#define D2D_LOGI(format, args...) LOGI(format, ##args)
+#define D2D_LOGW(format, args...) LOGW(format, ##args)
+#define D2D_LOGE(format, args...) LOGE(format, ##args)
+#define D2D_LOGF(format, args...) LOGF(format, ##args)
+
+#define __D2D_LOG_FUNC_ENTER__ LOGD("Enter")
+#define __D2D_LOG_FUNC_EXIT__ LOGD("Quit")
+
+#define D2D_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args)
+#define D2D_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args)
+
+#else /* USE_DLOG */
+
+#define D2D_LOGV(format, args...)
+#define D2D_LOGD(format, args...)
+#define D2D_LOGI(format, args...)
+#define D2D_LOGW(format, args...)
+#define D2D_LOGE(format, args...)
+#define D2D_LOGF(format, args...)
+
+#define __D2D_LOG_FUNC_ENTER__
+#define __D2D_LOG_FUNC_EXIT__
+
+#define D2D_SECLOGI(format, args...)
+#define D2D_SECLOGD(format, args...)
+
+#endif /* USE_DLOG */
+
+#endif /* __D2D_LOG_H__ */
index edc8713..ec20a24 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- */\r
-\r
-#ifndef __MA_LOG_H__\r
-#define __MA_LOG_H__\r
-\r
-#ifdef LOG_TAG\r
-#undef LOG_TAG\r
-#endif\r
-\r
-#ifdef USE_DLOG\r
-#include <dlog.h>\r
-\r
-#undef LOG_TAG\r
-#define LOG_TAG "MOT_AGENT"\r
-\r
-#define COLOR_RED "\033[0;31m"\r
-#define COLOR_GREEN "\033[0;32m"\r
-#define COLOR_BROWN "\033[0;33m"\r
-#define COLOR_BLUE "\033[0;34m"\r
-#define COLOR_PURPLE "\033[0;35m"\r
-#define COLOR_CYAN "\033[0;36m"\r
-#define COLOR_LIGHTBLUE "\033[0;37m"\r
-#define COLOR_END "\033[0;m"\r
-\r
-#define MA_LOGV(format, args...) LOGV(format, ##args)\r
-#define MA_LOGD(format, args...) LOGD(COLOR_LIGHTBLUE" "format COLOR_END, ##args)\r
-#define MA_LOGI(format, args...) LOGI(COLOR_GREEN" "format COLOR_END, ##args)\r
-#define MA_LOGW(format, args...) LOGW(COLOR_CYAN" "format COLOR_END, ##args)\r
-#define MA_LOGE(format, args...) LOGE(COLOR_RED" "format COLOR_END, ##args)\r
-#define MA_LOGF(format, args...) LOGF(format, ##args)\r
-\r
-#define __MA_LOG_FUNC_ENTER__ LOGD("Enter")\r
-#define __MA_LOG_FUNC_EXIT__ LOGD("Quit")\r
-\r
-#define MA_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, MA_LOG_TAG, format, ##args)\r
-#define MA_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, MA_LOG_TAG, format, ##args)\r
-\r
-#else /* USE_DLOG */\r
-\r
-#define MA_LOGV(format, args...)\r
-#define MA_LOGD(format, args...)\r
-#define MA_LOGI(format, args...)\r
-#define MA_LOGW(format, args...)\r
-#define MA_LOGE(format, args...)\r
-#define MA_LOGF(format, args...)\r
-\r
-#define __MA_LOG_FUNC_ENTER__\r
-#define __MA_LOG_FUNC_EXIT__\r
-\r
-#define MA_SECLOGI(format, args...)\r
-#define MA_SECLOGD(format, args...)\r
-\r
-#endif /* USE_DLOG */\r
-\r
-#endif /* __MA_LOG_H__ */\r
+ */
+
+#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__ */
index 694daf9..d1b0266 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- */\r
-#include <glib.h>\r
-\r
-#include "ma.h"\r
-#include "ma-log.h"\r
-#include "ma-util.h"\r
-#include "ma-service.h"\r
-#include "ma-subowner.h"\r
-#include "ma-service-interface.h"\r
-#include "ma-generated-code.h"\r
-\r
-static NetMa *ma_dbus_object;\r
-static Enabler *ma_activator_dbus_object;\r
-\r
-/* global list to care resource handle for each client */\r
-static GList *ma_dbus_client_list;\r
-static GMutex ma_dbus_client_list_mutex;\r
-\r
-typedef struct _ma_dbus_client_s {\r
-       gchar *bus_name;\r
-} ma_dbus_client_s;\r
-\r
-NetMa* ma_dbus_get_object()\r
-{\r
-       return ma_dbus_object;\r
-}\r
-\r
-static int _ma_dbus_client_list_cleanup(GList *client_list)\r
-{\r
-       ma_dbus_client_s *client;\r
-\r
-       ma_check_null_ret_error("client_list", client_list, FALSE);\r
-\r
-       client = client_list->data;\r
-\r
-       g_free(client->bus_name);\r
-       client->bus_name = NULL;\r
-       g_free(client);\r
-       g_list_free(client_list);\r
-\r
-       return MA_ERROR_NONE;\r
-}\r
-\r
-static int _ma_dbus_client_list_compare_bus_name(const void *a, const void *b)\r
-{\r
-       const ma_dbus_client_s *client = a;\r
-       return g_strcmp0(client->bus_name, b);\r
-}\r
-\r
-static inline GList* _ma_dbus_client_list_find_client(const gchar *owner)\r
-{\r
-       return g_list_find_custom(ma_dbus_client_list, owner,\r
-                       _ma_dbus_client_list_compare_bus_name);\r
-}\r
-\r
-static void _ma_dbus_name_owner_changed_cb(GDBusConnection *conn,\r
-               const gchar *sender_name,\r
-               const gchar *object_path,\r
-               const gchar *interface_name,\r
-               const gchar *signal_name,\r
-               GVariant *parameters,\r
-               gpointer user_data)\r
-{\r
-       int ret;\r
-       GList *client = NULL;\r
-       gchar *name, *old_owner, *new_owner;\r
-\r
-       NOTUSED(conn);\r
-       NOTUSED(sender_name);\r
-       NOTUSED(object_path);\r
-       NOTUSED(interface_name);\r
-       NOTUSED(signal_name);\r
-       NOTUSED(user_data);\r
-\r
-       g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);\r
-\r
-       if (0 == strlen(new_owner)) {\r
-               g_mutex_lock(&ma_dbus_client_list_mutex);\r
-               client = _ma_dbus_client_list_find_client(old_owner);\r
-               if (client) { /* found bus name in our bus list */\r
-                       MA_LOGD("bus(%s) stopped", old_owner);\r
-                       ma_dbus_client_list = g_list_remove_link(ma_dbus_client_list, client);\r
-               }\r
-               g_mutex_unlock(&ma_dbus_client_list_mutex);\r
-\r
-               if (client) {\r
-                       ret = _ma_dbus_client_list_cleanup(client);\r
-                       if (MA_ERROR_NONE != ret)\r
-                               MA_LOGE("_ma_dbus_client_list_cleanup() Fail(%d)", ret);\r
-               }\r
-       }\r
-}\r
-\r
-static int _ma_dbus_subscribe_name_owner_changed(GDBusConnection *conn)\r
-{\r
-       unsigned int id;\r
-\r
-       id = g_dbus_connection_signal_subscribe(conn,\r
-                       "org.freedesktop.DBus", /* bus name */\r
-                       "org.freedesktop.DBus", /* interface */\r
-                       "NameOwnerChanged", /* member */\r
-                       "/org/freedesktop/DBus", /* path */\r
-                       NULL, /* arg0 */\r
-                       G_DBUS_SIGNAL_FLAGS_NONE,\r
-                       _ma_dbus_name_owner_changed_cb,\r
-                       NULL,\r
-                       NULL);\r
-       if (0 == id) {\r
-               MA_LOGE("g_dbus_connection_signal_subscribe() Fail");\r
-               return MA_ERROR_IO_ERROR;\r
-       }\r
-\r
-       return MA_ERROR_NONE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_get_ownerid(NetMa *object,\r
-               GDBusMethodInvocation *invocation,\r
-               gpointer user_data)\r
-{\r
-       gchar *uuid_str = NULL;\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-       ret = ma_request_get_ownerid(service, &uuid_str);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_get_ownerid = %d", ret);\r
-\r
-       net_ma_complete_get_ownerid(object, invocation, uuid_str, ret);\r
-\r
-       if (uuid_str)\r
-               g_free(uuid_str);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_disc_mot_enb_devs(NetMa *object,\r
-               GDBusMethodInvocation *invocation,\r
-               gint timeout,\r
-               gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-       ret = ma_request_disc_mot_enb_devs(service, timeout);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_disc_mot_enb_devs !");\r
-\r
-       net_ma_complete_disc_mot_enb_devs(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_disc_mowned_devs(NetMa *object,\r
-               GDBusMethodInvocation *invocation,\r
-               gint timeout,\r
-               gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-\r
-       ret = ma_request_disc_owned_devs(service, timeout);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_disc_owned_devs !");\r
-\r
-       net_ma_complete_disc_mowned_devs(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_mot(NetMa *object,\r
-               GDBusMethodInvocation *invocation,  gchar *arg_target, gchar *arg_pin,\r
-               gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-\r
-       ret = ma_request_mot(service, arg_target, arg_pin);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_disc_moted_devs !");\r
-\r
-       net_ma_complete_mot(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_acl(NetMa *object,\r
-               GDBusMethodInvocation *invocation, gchar *arg_target, gchar *arg_subject,\r
-               gchar *arg_uri, gchar *arg_rt, gchar *arg_interface, gint arg_permission,\r
-               gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-\r
-       ret = ma_request_prov_acl(service, arg_target, arg_subject, arg_uri, arg_rt,\r
-               arg_interface, arg_permission);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_prov_acl !");\r
-\r
-       net_ma_complete_acl(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_cred(NetMa *object,\r
-               GDBusMethodInvocation *invocation, gchar *arg_dev1, gchar *arg_dev2,\r
-               gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-\r
-       ret = ma_request_prov_cred(service, arg_dev1, arg_dev2);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_prov_cred !");\r
-\r
-       net_ma_complete_cred(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_pairwise(NetMa *object,\r
-                                         GDBusMethodInvocation *invocation, gchar *target_1,\r
-                                         gchar *subject_1, gchar *uri_1, gchar *rt_1,\r
-                                         gchar *interface_1, int permission_1, gchar *target_2,\r
-                                         gchar *subject_2, gchar *uri_2, gchar *rt_2,\r
-                                         gchar *interface_2, int permission_2, gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-\r
-       ret = ma_request_rsrc_pairwise(service, target_1, subject_1, uri_1, rt_1,\r
-                                       interface_1, permission_1, target_2, subject_2, uri_2,\r
-                                       rt_2, interface_2, permission_2);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_pairwise = %d", ret);\r
-\r
-       net_ma_complete_pairwise(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_unlink(NetMa *object,\r
-               GDBusMethodInvocation *invocation, gchar *uuid_dev1, gchar *uuid_dev2,\r
-               gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-       ret = ma_request_unlink_rsrc(service, uuid_dev1, uuid_dev2);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_unpair = %d", ret);\r
-\r
-       net_ma_complete_unpair(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_remove_subowner(NetMa *object,\r
-               GDBusMethodInvocation *invocation,  gchar *arg_target, gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-\r
-       ret = ma_request_remove_subowner(service, arg_target);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_remove_subowner !");\r
-\r
-       net_ma_complete_remove_subowner(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_remove_device(NetMa *object,\r
-               GDBusMethodInvocation *invocation,  gchar *arg_target, gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-\r
-       ret = ma_request_remove_device(service, arg_target);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_remove_subowner !");\r
-\r
-       net_ma_complete_remove_device(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_pair(NetMa *object,\r
-         GDBusMethodInvocation *invocation, gchar *pin,\r
-         gchar *target_1, gchar *subject_1, gchar *uri_1,\r
-         gchar *rt_1, gchar *interface_1, int permission_1,\r
-         gchar *target_2, gchar *subject_2, gchar *uri_2,\r
-         gchar *rt_2, gchar *interface_2, int permission_2,\r
-         gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-\r
-       ret = ma_request_pair(service, pin, target_1, subject_1, uri_1, rt_1,\r
-                                       interface_1, permission_1, target_2, subject_2, uri_2,\r
-                                       rt_2, interface_2, permission_2);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_pair = %d", ret);\r
-\r
-       net_ma_complete_pair(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_unpair(NetMa *object,\r
-               GDBusMethodInvocation *invocation, gchar *uuid_owner, gchar *uuid_owned,\r
-               gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-       ret = ma_request_unpair(service, uuid_owner, uuid_owned);\r
-       if (MA_ERROR_NONE != ret)\r
-               MA_LOGE("Failed to ma_request_unpair = %d", ret);\r
-\r
-       net_ma_complete_unpair(object, invocation, ret);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static void _ma_dbus_on_bus_acquired(GDBusConnection *conn, const gchar *name,\r
-               gpointer user_data)\r
-{\r
-       gboolean ret;\r
-       GError *error = NULL;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       NOTUSED(name);\r
-\r
-       ma_dbus_object = net_ma_skeleton_new();\r
-       if (NULL == ma_dbus_object) {\r
-               MA_LOGE("net_ma_skeleton_new() Fail");\r
-               return;\r
-       }\r
-       g_signal_connect(ma_dbus_object, "handle-get-ownerid",\r
-                       G_CALLBACK(_ma_dbus_handle_get_ownerid), service);\r
-       g_signal_connect(ma_dbus_object, "handle-disc-mot-enb-devs",\r
-                       G_CALLBACK(_ma_dbus_handle_disc_mot_enb_devs), service);\r
-       g_signal_connect(ma_dbus_object, "handle-disc-mowned-devs",\r
-                       G_CALLBACK(_ma_dbus_handle_disc_mowned_devs), service);\r
-       g_signal_connect(ma_dbus_object, "handle-mot",\r
-                       G_CALLBACK(_ma_dbus_handle_mot), service);\r
-       g_signal_connect(ma_dbus_object, "handle-pairwise",\r
-                       G_CALLBACK(_ma_dbus_handle_pairwise), service);\r
-       g_signal_connect(ma_dbus_object, "handle-unlink",\r
-                       G_CALLBACK(_ma_dbus_handle_unlink), service);\r
-       g_signal_connect(ma_dbus_object, "handle-remove-subowner",\r
-                       G_CALLBACK(_ma_dbus_handle_remove_subowner), service);\r
-       g_signal_connect(ma_dbus_object, "handle-remove-device",\r
-                       G_CALLBACK(_ma_dbus_handle_remove_device), service);\r
-       g_signal_connect(ma_dbus_object, "handle-acl",\r
-                       G_CALLBACK(_ma_dbus_handle_acl), service);\r
-       g_signal_connect(ma_dbus_object, "handle-cred",\r
-                       G_CALLBACK(_ma_dbus_handle_cred), service);\r
-       g_signal_connect(ma_dbus_object, "handle-pair",\r
-                       G_CALLBACK(_ma_dbus_handle_pair), service);\r
-       g_signal_connect(ma_dbus_object, "handle-unpair",\r
-                       G_CALLBACK(_ma_dbus_handle_unpair), service);\r
-\r
-       ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(ma_dbus_object),\r
-                       conn, MA_DBUS_OBJPATH, &error);\r
-       if (FALSE == ret) {\r
-               MA_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);\r
-               g_error_free(error);\r
-       }\r
-\r
-       ret = _ma_dbus_subscribe_name_owner_changed(conn);\r
-       if (MA_ERROR_NONE != ret) {\r
-               MA_LOGE("_ma_dbus_subscribe_name_owner_changed() Fail(%d)", ret);\r
-               return;\r
-       }\r
-}\r
-\r
-static void _ma_dbus_on_name_lost(GDBusConnection *conn, const gchar *name,\r
-               gpointer user_data)\r
-{\r
-       NOTUSED(conn);\r
-       NOTUSED(user_data);\r
-\r
-       MA_LOGD("Lost the name %s", name);\r
-}\r
-\r
-static void _ma_dbus_on_name_acquired(GDBusConnection *conn, const gchar *name,\r
-               gpointer user_data)\r
-{\r
-       NOTUSED(conn);\r
-       NOTUSED(user_data);\r
-\r
-       MA_LOGD("Acquired the name %s", name);\r
-}\r
-\r
-static gboolean _ma_dbus_handle_enable(Enabler *object,\r
-               GDBusMethodInvocation *invocation,\r
-               gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       __MA_LOG_FUNC_ENTER__;\r
-\r
-       /* Do API response first */\r
-       enabler_complete_enable(object, invocation, ret);\r
-       service->ma_activated = TRUE;\r
-\r
-       /* Intialize subowner client */\r
-       ret = ma_request_enable(service);\r
-       if (MA_ERROR_NONE != ret) {\r
-               MA_LOGE("ma_request_enable() Fail(%d)", ret);\r
-               return FALSE;\r
-       }\r
-\r
-       /* Notify d2ds enabled */\r
-       net_ma_emit_subowner_enabled(ma_dbus_get_object(), ret);\r
-\r
-       __MA_LOG_FUNC_EXIT__;\r
-\r
-       return TRUE;\r
-}\r
-\r
-static gboolean _ma_dbus_handle_disable(Enabler *object,\r
-               GDBusMethodInvocation *invocation,\r
-               gpointer user_data)\r
-{\r
-       int ret = MA_ERROR_NONE;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       __MA_LOG_FUNC_ENTER__;\r
-\r
-       /* Make response first */\r
-       enabler_complete_disable(object, invocation, ret);\r
-\r
-       /* De-Intialize subowner client */\r
-       ret = ma_request_disable(service);\r
-       if (MA_ERROR_NONE != ret) {\r
-               MA_LOGE("ma_request_disable() Fail(%d)", ret);\r
-               return FALSE;\r
-       }\r
-\r
-       /* Terminate daemon */\r
-       ma_service_exit(service);\r
-\r
-       return TRUE;\r
-}\r
-\r
-static void _ma_dbus_on_activator_bus_acquired(GDBusConnection *conn,\r
-               const gchar *name, gpointer user_data)\r
-{\r
-       gboolean ret;\r
-       GError *error = NULL;\r
-       ma_service *service = (ma_service *)user_data;\r
-\r
-       NOTUSED(name);\r
-\r
-       __MA_LOG_FUNC_ENTER__;\r
-\r
-       ma_activator_dbus_object = enabler_skeleton_new();\r
-       if (NULL == ma_activator_dbus_object) {\r
-               MA_LOGE("enabler_skeleton_new() Fail");\r
-               return;\r
-       }\r
-\r
-       g_signal_connect(ma_activator_dbus_object, "handle-enable",\r
-                       G_CALLBACK(_ma_dbus_handle_enable), service);\r
-       g_signal_connect(ma_activator_dbus_object, "handle-disable",\r
-                       G_CALLBACK(_ma_dbus_handle_disable), service);\r
-\r
-       ret = g_dbus_interface_skeleton_export(\r
-                               G_DBUS_INTERFACE_SKELETON(ma_activator_dbus_object),\r
-                               conn, MA_DBUS_ENABLER_OBJPATH, &error);\r
-       if (FALSE == ret) {\r
-               MA_LOGE("g_dbus_interface_skeleton_export() Fail(%s)", error->message);\r
-               g_error_free(error);\r
-       }\r
-\r
-       __MA_LOG_FUNC_EXIT__;\r
-\r
-}\r
-\r
-static gboolean _ma_dbus_interface_init(ma_service *service)\r
-{\r
-       guint id;\r
-       guint activation_dbus_id;\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-       id = g_bus_own_name(G_BUS_TYPE_SYSTEM,\r
-                       MA_DBUS_INTERFACE,\r
-                       G_BUS_NAME_OWNER_FLAGS_REPLACE,\r
-                       _ma_dbus_on_bus_acquired,\r
-                       _ma_dbus_on_name_acquired,\r
-                       _ma_dbus_on_name_lost,\r
-                       service,\r
-                       NULL);\r
-       if (0 == id) {\r
-               MA_LOGE("g_bus_own_name() Fail");\r
-               return FALSE;\r
-       }\r
-\r
-       /* Get D-Bus owner to activate subowner service daemon */\r
-       activation_dbus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,\r
-                       MA_DBUS_INTERFACE".enabler",\r
-                       G_BUS_NAME_OWNER_FLAGS_REPLACE,\r
-                       _ma_dbus_on_activator_bus_acquired,\r
-                       NULL,\r
-                       NULL,\r
-                       service,\r
-                       NULL);\r
-\r
-       service->dbus_id = id;\r
-       service->activation_dbus_id = activation_dbus_id;\r
-\r
-       return TRUE;\r
-}\r
-\r
-void ma_notify_mot_env_devs(GVariant *devices)\r
-{\r
-       /* Notify d2ds enabled */\r
-       net_ma_emit_disc_mot_enb_devs_done(ma_dbus_get_object(), devices);\r
-}\r
-\r
-void ma_notify_mowned_devs(GVariant *devices)\r
-{\r
-       /* Notify d2ds enabled */\r
-       net_ma_emit_disc_mowned_devs_done(ma_dbus_get_object(), devices);\r
-}\r
-\r
-static void _ma_dbus_deinit(ma_service *service)\r
-{\r
-       ma_check_null_ret("service", service);\r
-\r
-       g_bus_unown_name(service->dbus_id);\r
-       g_bus_unown_name(service->activation_dbus_id);\r
-}\r
-\r
-gboolean ma_service_interface_init(ma_service *service)\r
-{\r
-       guint ret;\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-\r
-       __MA_LOG_FUNC_ENTER__;\r
-\r
-       /* Initialize dbus interface */\r
-       ret = _ma_dbus_interface_init(service);\r
-       if (FALSE == ret) {\r
-               MA_LOGE("%s failed!!!", __func__);\r
-               return FALSE;\r
-       }\r
-\r
-       __MA_LOG_FUNC_EXIT__;\r
-\r
-       return TRUE;\r
-}\r
-\r
-void ma_service_interface_deinit(ma_service *service)\r
-{\r
-       ma_check_null_ret("service", service);\r
-\r
-       /* De-initialize dbus interface */\r
-       _ma_dbus_deinit(service);\r
-       /* De-initialize mot-agent instance */\r
-       ma_delete_mot_agent(service);\r
-}\r
-\r
+ */
+#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", 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 !");
+
+       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 !");
+
+       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 !");
+
+       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 !");
+
+       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 !");
+
+       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", 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", 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 !");
+
+       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 !");
+
+       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", 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", 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);
+}
+
index 79b332c..69decf3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- */\r
-\r
-#ifndef __MA_SERVICE_INTERFACE_H__\r
-#define __MA_SERVICE_INTERFACE_H__\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-/**< Mesh D-BUS service*/\r
-#define MA_DBUS_SERVICE "net.ma"\r
-\r
-/**< Mesh D-BUS service path */\r
-#define MA_DBUS_PATH "/net/ma"\r
-\r
-#ifndef MA_DBUS_INTERFACE\r
-#define MA_DBUS_INTERFACE "net.ma"\r
-#endif\r
-\r
-#ifndef MA_DBUS_OBJPATH\r
-#define MA_DBUS_OBJPATH "/net/ma"\r
-#endif\r
-\r
-#ifndef MA_DBUS_ENABLER_OBJPATH\r
-#define MA_DBUS_ENABLER_OBJPATH "/net/ma/enabler"\r
-#endif\r
-\r
-struct _NetMa;\r
-typedef struct _NetMa NetMa;\r
-\r
-NetMa* ma_dbus_get_object();\r
-gboolean ma_service_interface_init(ma_service *service);\r
-void ma_service_interface_deinit(ma_service *service);\r
-void ma_notify_mot_env_devs(GVariant *devices);\r
-void ma_notify_mowned_devs(GVariant *devices);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif /* __MA_SERVICE_INTERFACE_H__ */\r
-\r
+ */
+
+#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__ */
+
index 749fe38..7b252c2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- */\r
-#include <glib.h>\r
-\r
-#include "ma.h"\r
-#include "ma-log.h"\r
-#include "ma-util.h"\r
-\r
-ma_service *ma_service_new()\r
-{\r
-       ma_service *service;\r
-\r
-       service = g_malloc0(sizeof(struct _ma_service));\r
-\r
-       /* Create g-main loop */\r
-       service->main_loop = g_main_loop_new(NULL, FALSE);\r
-       if (G_UNLIKELY(NULL == service->main_loop)) {\r
-               MA_LOGE("g-main loop creation failed!!!");\r
-               g_free(service);\r
-               return NULL;\r
-       }\r
-\r
-       return service;\r
-}\r
-\r
-void ma_service_free(ma_service *service)\r
-{\r
-       ma_check_null_ret("service", service);\r
-\r
-       /* Unref 'g-main loop' */\r
-       if (service->main_loop)\r
-               g_main_loop_unref(service->main_loop);\r
-\r
-       g_free(service);\r
-}\r
-\r
-gboolean ma_service_run(ma_service *service)\r
-{\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-       ma_check_null_ret_error("service->main_loop", service->main_loop, FALSE);\r
-\r
-       g_main_loop_run(service->main_loop);\r
-\r
-       return TRUE;\r
-}\r
-\r
-gboolean ma_service_exit(ma_service *service)\r
-{\r
-       ma_check_null_ret_error("service", service, FALSE);\r
-       ma_check_null_ret_error("service->main_loop", service->main_loop, FALSE);\r
-\r
-       g_main_loop_quit(service->main_loop);\r
-\r
-       return TRUE;\r
-}\r
+ */
+#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;
+}
index 172b04c..fc6fe4e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- */\r
-\r
-#ifndef __MA_SERVICE_H__\r
-#define __MA_SERVICE_H__\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-ma_service* ma_service_new();\r
-void ma_service_free(ma_service *service);\r
-gboolean ma_service_run(ma_service *service);\r
-gboolean ma_service_exit(ma_service *service);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif /* __MA_SERVICE_H__ */\r
-\r
+ */
+
+#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__ */
+
index 097334a..8c2731d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 6069278..e341507 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 4813748..7ace038 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index c8de9ef..6a0af31 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index d55f026..fcd6b41 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
index 94cd320..7d5cdb9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ * 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.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
- */\r
-#ifndef __MA_AGENT_H__\r
-#define __MA_AGENT_H__\r
-\r
-#include <glib.h>\r
-#include <gio/gio.h>\r
-#include <tizen.h>\r
-\r
-/**< Internal error code with d2ds daemon. It should be matched with API side */\r
-typedef enum {\r
-       MA_ERROR_NONE = 0, /**< Successful */\r
-       MA_ERROR_IO_ERROR, /**< I/O error */\r
-       MA_ERROR_NO_DATA, /**< Data not exists */\r
-       MA_ERROR_OUT_OF_MEMORY, /**< out of memory */\r
-       MA_ERROR_OPERATION_FAILED, /**< operation failed */\r
-       MA_ERROR_INVALID_PARAMETER, /**< Invalid parameter */\r
-       MA_ERROR_ALREADY_REGISTERED, /**< Request already registered */\r
-       MA_ERROR_IN_PROGRESS /**< operation is in progress */\r
-} ma_error_e;\r
-\r
-/**< d2d-subowner service structure */\r
-typedef struct _ma_service {\r
-       GMainLoop *main_loop; /**< Service main-loop */\r
-       guint dbus_id; /**< D-Bus id */\r
-       guint activation_dbus_id; /**< D-Bus id for activation */\r
-       gpointer connection; /**< Connection handle for D-Bus call to other process */\r
-       GCancellable *ca; /**< Cancellable object for D-Bus call (Daemon->other) */\r
-       GList *dbus_sub_ids; /**< The list of subscribed signals */\r
-       gboolean ma_activated; /**< Whether d2d-manager enabled or not */\r
-} ma_service;\r
-\r
-#endif /* __MA_AGENT_H__ */\r
-\r
+ */
+#ifndef __MA_AGENT_H__
+#define __MA_AGENT_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <tizen.h>
+
+/**< Internal error code with d2ds daemon. It should be matched with API side */
+typedef enum {
+       MA_ERROR_NONE = 0, /**< Successful */
+       MA_ERROR_IO_ERROR, /**< I/O error */
+       MA_ERROR_NO_DATA, /**< Data not exists */
+       MA_ERROR_OUT_OF_MEMORY, /**< out of memory */
+       MA_ERROR_OPERATION_FAILED, /**< operation failed */
+       MA_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+       MA_ERROR_ALREADY_REGISTERED, /**< Request already registered */
+       MA_ERROR_IN_PROGRESS /**< operation is in progress */
+} 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__ */
+