From: saerome.kim Date: Thu, 29 Mar 2018 02:26:19 +0000 (+0900) Subject: d2d-manager: add doc.h and change of copyright enforcement year X-Git-Tag: submit/tizen/20190131.065036~75 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0e52d2e79ef84bd54c3fa30ea9245f0e5097ab7;p=platform%2Fcore%2Fapi%2Fmulti-device-group.git d2d-manager: add doc.h and change of copyright enforcement year Signed-off-by: saerome.kim --- diff --git a/capi/demo/common.h b/capi/demo/common.h index a14df50..dd29976 100644 --- a/capi/demo/common.h +++ b/capi/demo/common.h @@ -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/demo/comp-manager.c b/capi/demo/comp-manager.c index fc40042..4263878 100644 --- a/capi/demo/comp-manager.c +++ b/capi/demo/comp-manager.c @@ -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/demo/companion_demo.c b/capi/demo/companion_demo.c index 9fd72a2..a0c878d 100644 --- a/capi/demo/companion_demo.c +++ b/capi/demo/companion_demo.c @@ -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/demo/main.c b/capi/demo/main.c index 41e5372..4dca2d6 100644 --- a/capi/demo/main.c +++ b/capi/demo/main.c @@ -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/demo/menu.c b/capi/demo/menu.c index e3a38d3..c217f6b 100644 --- a/capi/demo/menu.c +++ b/capi/demo/menu.c @@ -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/demo/menu.h b/capi/demo/menu.h index 5959d55..728d36c 100644 --- a/capi/demo/menu.h +++ b/capi/demo/menu.h @@ -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 index 0000000..5a8d097 --- /dev/null +++ b/capi/doc/companion_doc.h @@ -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 + * + * @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 Feature Element. + * + */ + +#endif /* __TIZEN_NETWORK_COMPANION_DOC_H__ */ diff --git a/capi/include/companion.h b/capi/include/companion.h index 9e7bb33..9bc2f1a 100644 --- a/capi/include/companion.h +++ b/capi/include/companion.h @@ -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 @@ -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 diff --git a/capi/src/companion.c b/capi/src/companion.c index 1455ade..2775ce0 100644 --- a/capi/src/companion.c +++ b/capi/src/companion.c @@ -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/src/companion_dbus.c b/capi/src/companion_dbus.c index 7a7a43f..e911c87 100644 --- a/capi/src/companion_dbus.c +++ b/capi/src/companion_dbus.c @@ -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/src/companion_dbus.h b/capi/src/companion_dbus.h index b77b296..fdc5f06 100644 --- a/capi/src/companion_dbus.h +++ b/capi/src/companion_dbus.h @@ -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,12 +15,12 @@ * */ -#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 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__ */ diff --git a/capi/src/companion_debug.h b/capi/src/companion_debug.h index 7ab8293..ec89586 100644 --- a/capi/src/companion_debug.h +++ b/capi/src/companion_debug.h @@ -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 @@ -106,4 +106,4 @@ #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__ */ diff --git a/capi/src/companion_private.h b/capi/src/companion_private.h index 44c8a8c..26f6463 100644 --- a/capi/src/companion_private.h +++ b/capi/src/companion_private.h @@ -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 -#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) { \ diff --git a/capi/src/companion_util.c b/capi/src/companion_util.c index 497735d..84a8e63 100644 --- a/capi/src/companion_util.c +++ b/capi/src/companion_util.c @@ -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/src/companion_util.h b/capi/src/companion_util.h index db7314e..6fbb635 100644 --- a/capi/src/companion_util.h +++ b/capi/src/companion_util.h @@ -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/unittest/companion_unit_test.cpp b/capi/unittest/companion_unit_test.cpp index 2bab208..2a5414a 100644 --- a/capi/unittest/companion_unit_test.cpp +++ b/capi/unittest/companion_unit_test.cpp @@ -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/src/companion-manager/include/comp_context.h b/src/companion-manager/include/comp_context.h index 573edbd..e1c9c5c 100644 --- a/src/companion-manager/include/comp_context.h +++ b/src/companion-manager/include/comp_context.h @@ -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/src/companion-manager/include/comp_enum.h b/src/companion-manager/include/comp_enum.h index 577766c..87dc9a2 100644 --- a/src/companion-manager/include/comp_enum.h +++ b/src/companion-manager/include/comp_enum.h @@ -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/src/companion-manager/include/comp_gdbus.h b/src/companion-manager/include/comp_gdbus.h index 77ac1ea..059e08e 100644 --- a/src/companion-manager/include/comp_gdbus.h +++ b/src/companion-manager/include/comp_gdbus.h @@ -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/src/companion-manager/include/comp_gdbus_group.h b/src/companion-manager/include/comp_gdbus_group.h index c12b1e6..ebb8fe0 100644 --- a/src/companion-manager/include/comp_gdbus_group.h +++ b/src/companion-manager/include/comp_gdbus_group.h @@ -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/src/companion-manager/include/comp_group.h b/src/companion-manager/include/comp_group.h index 22d86ac..468c337 100644 --- a/src/companion-manager/include/comp_group.h +++ b/src/companion-manager/include/comp_group.h @@ -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/src/companion-manager/include/comp_iot.h b/src/companion-manager/include/comp_iot.h index dfdccdf..cc31b3a 100644 --- a/src/companion-manager/include/comp_iot.h +++ b/src/companion-manager/include/comp_iot.h @@ -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/src/companion-manager/include/comp_log.h b/src/companion-manager/include/comp_log.h index 90f60b8..9aaf017 100644 --- a/src/companion-manager/include/comp_log.h +++ b/src/companion-manager/include/comp_log.h @@ -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/src/companion-manager/include/comp_manager.h b/src/companion-manager/include/comp_manager.h index 50ae748..b090179 100644 --- a/src/companion-manager/include/comp_manager.h +++ b/src/companion-manager/include/comp_manager.h @@ -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/src/companion-manager/include/comp_mot_agent.h b/src/companion-manager/include/comp_mot_agent.h index d647610..c4537a2 100644 --- a/src/companion-manager/include/comp_mot_agent.h +++ b/src/companion-manager/include/comp_mot_agent.h @@ -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/src/companion-manager/include/comp_resource.h b/src/companion-manager/include/comp_resource.h index e767838..f5d7885 100644 --- a/src/companion-manager/include/comp_resource.h +++ b/src/companion-manager/include/comp_resource.h @@ -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/src/companion-manager/src/comp_context.c b/src/companion-manager/src/comp_context.c index 6a5b3ec..7aeb82f 100644 --- a/src/companion-manager/src/comp_context.c +++ b/src/companion-manager/src/comp_context.c @@ -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/src/companion-manager/src/comp_gdbus.c b/src/companion-manager/src/comp_gdbus.c index 5ed0468..1c05cbb 100644 --- a/src/companion-manager/src/comp_gdbus.c +++ b/src/companion-manager/src/comp_gdbus.c @@ -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/src/companion-manager/src/comp_gdbus_group.c b/src/companion-manager/src/comp_gdbus_group.c index a66a5d8..21ab0c6 100644 --- a/src/companion-manager/src/comp_gdbus_group.c +++ b/src/companion-manager/src/comp_gdbus_group.c @@ -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/src/companion-manager/src/comp_group.c b/src/companion-manager/src/comp_group.c index accf31a..001829a 100644 --- a/src/companion-manager/src/comp_group.c +++ b/src/companion-manager/src/comp_group.c @@ -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/src/companion-manager/src/comp_iot.cpp b/src/companion-manager/src/comp_iot.cpp index cc8c281..9acbd68 100644 --- a/src/companion-manager/src/comp_iot.cpp +++ b/src/companion-manager/src/comp_iot.cpp @@ -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/src/companion-manager/src/comp_log.c b/src/companion-manager/src/comp_log.c index 23346d0..0e3238d 100644 --- a/src/companion-manager/src/comp_log.c +++ b/src/companion-manager/src/comp_log.c @@ -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/src/companion-manager/src/comp_manager.c b/src/companion-manager/src/comp_manager.c index e9eff6c..ddc8c67 100644 --- a/src/companion-manager/src/comp_manager.c +++ b/src/companion-manager/src/comp_manager.c @@ -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/src/companion-manager/src/comp_mot_agent.c b/src/companion-manager/src/comp_mot_agent.c index a43bda4..e2016f3 100644 --- a/src/companion-manager/src/comp_mot_agent.c +++ b/src/companion-manager/src/comp_mot_agent.c @@ -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/src/companion-manager/src/comp_resource.c b/src/companion-manager/src/comp_resource.c index 7502b0c..1c189fa 100644 --- a/src/companion-manager/src/comp_resource.c +++ b/src/companion-manager/src/comp_resource.c @@ -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/src/include/d2d-log.h b/src/include/d2d-log.h index 3898a24..acf6448 100644 --- a/src/include/d2d-log.h +++ b/src/include/d2d-log.h @@ -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. @@ -13,49 +13,49 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ - -#ifndef __D2D_LOG_H__ -#define __D2D_LOG_H__ - -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#ifdef USE_DLOG -#include - -#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__ */ + */ + +#ifndef __D2D_LOG_H__ +#define __D2D_LOG_H__ + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#ifdef USE_DLOG +#include + +#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__ */ diff --git a/src/mot-agent/ma-log.h b/src/mot-agent/ma-log.h index edc8713..ec20a24 100644 --- a/src/mot-agent/ma-log.h +++ b/src/mot-agent/ma-log.h @@ -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. @@ -13,58 +13,58 @@ * 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 - -#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__ */ + */ + +#ifndef __MA_LOG_H__ +#define __MA_LOG_H__ + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#ifdef USE_DLOG +#include + +#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 index 694daf9..d1b0266 100644 --- a/src/mot-agent/ma-service-interface.c +++ b/src/mot-agent/ma-service-interface.c @@ -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. @@ -13,601 +13,601 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ -#include - -#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); -} - + */ +#include + +#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); +} + diff --git a/src/mot-agent/ma-service-interface.h b/src/mot-agent/ma-service-interface.h index 79b332c..69decf3 100644 --- a/src/mot-agent/ma-service-interface.h +++ b/src/mot-agent/ma-service-interface.h @@ -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. @@ -13,45 +13,45 @@ * 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__ */ - + */ + +#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 index 749fe38..7b252c2 100644 --- a/src/mot-agent/ma-service.c +++ b/src/mot-agent/ma-service.c @@ -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. @@ -13,57 +13,57 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ -#include - -#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; -} + */ +#include + +#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 index 172b04c..fc6fe4e 100644 --- a/src/mot-agent/ma-service.h +++ b/src/mot-agent/ma-service.h @@ -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. @@ -13,23 +13,23 @@ * 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__ */ - + */ + +#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 index 097334a..8c2731d 100644 --- a/src/mot-agent/ma-subowner.c +++ b/src/mot-agent/ma-subowner.c @@ -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/src/mot-agent/ma-subowner.h b/src/mot-agent/ma-subowner.h index 6069278..e341507 100644 --- a/src/mot-agent/ma-subowner.h +++ b/src/mot-agent/ma-subowner.h @@ -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/src/mot-agent/ma-util.c b/src/mot-agent/ma-util.c index 4813748..7ace038 100644 --- a/src/mot-agent/ma-util.c +++ b/src/mot-agent/ma-util.c @@ -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/src/mot-agent/ma-util.h b/src/mot-agent/ma-util.h index c8de9ef..6a0af31 100644 --- a/src/mot-agent/ma-util.h +++ b/src/mot-agent/ma-util.h @@ -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/src/mot-agent/ma.c b/src/mot-agent/ma.c index d55f026..fcd6b41 100644 --- a/src/mot-agent/ma.c +++ b/src/mot-agent/ma.c @@ -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/src/mot-agent/ma.h b/src/mot-agent/ma.h index 94cd320..7d5cdb9 100644 --- a/src/mot-agent/ma.h +++ b/src/mot-agent/ma.h @@ -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. @@ -13,36 +13,36 @@ * See the License for the specific language governing permissions and * limitations under the License. * - */ -#ifndef __MA_AGENT_H__ -#define __MA_AGENT_H__ - -#include -#include -#include - -/**< 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__ */ - + */ +#ifndef __MA_AGENT_H__ +#define __MA_AGENT_H__ + +#include +#include +#include + +/**< 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__ */ +