From 4a768f097381c8a138e0c2ab27cc1c7100f49086 Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Sun, 1 Feb 2015 13:04:12 +0900 Subject: [PATCH] tizen 2.3 release --- CMakeLists.txt | 4 + LICENSE | 278 ++++++++++++++---- TC/testcase/utc_minicontrol.c | 4 +- doc/doxygen.conf | 2 +- doc/minicontrol_doc.h | 76 +++-- include/minicontrol-error.h | 26 +- include/minicontrol-handler.h | 359 +++++++++++++++++++++++ include/minicontrol-internal-handler.h | 67 +++++ include/minicontrol-internal.h | 14 +- include/minicontrol-log.h | 8 +- include/minicontrol-monitor.h | 39 ++- include/minicontrol-provider.h | 48 +++- include/minicontrol-type.h | 56 ++-- include/minicontrol-viewer.h | 32 +-- include/minicontrol.h | 8 +- minicontrol-handler.pc.in | 11 + packaging/minicontrol.spec | 6 +- src/minicontrol-handler.c | 118 ++++++++ src/minicontrol-internal-handler.c | 508 +++++++++++++++++++++++++++++++++ src/minicontrol-internal.c | 43 ++- src/minicontrol-monitor.c | 321 ++++++++++++++++----- src/minicontrol-provider.c | 233 ++++++++++++++- src/minicontrol-viewer.c | 12 +- 23 files changed, 1992 insertions(+), 281 deletions(-) create mode 100755 include/minicontrol-handler.h create mode 100755 include/minicontrol-internal-handler.h create mode 100755 minicontrol-handler.pc.in create mode 100755 src/minicontrol-handler.c create mode 100755 src/minicontrol-internal-handler.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b74833..ff1e4f7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,14 @@ SET(INSTALL_HEADERS minicontrol-monitor.h minicontrol-provider.h minicontrol-viewer.h + minicontrol-handler.h ) SET(SUBMODULES minicontrol-provider minicontrol-viewer minicontrol-monitor + minicontrol-handler ) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) @@ -34,6 +36,7 @@ pkg_check_modules(pkgs REQUIRED ecore-evas dbus-1 dbus-glib-1 + bundle ) FOREACH(flag ${pkgs_CFLAGS}) @@ -49,6 +52,7 @@ ADD_DEFINITIONS("-DMINICTRL_USE_DLOG") ADD_LIBRARY(${PROJECT_NAME}-inter STATIC src/minicontrol-internal.c + src/minicontrol-internal-handler.c ) TARGET_LINK_LIBRARIES(${PROJECT_NAME}-inter ${pkgs_LDFLAGS}) diff --git a/LICENSE b/LICENSE index 7ccb5b5..8bc1c9e 100755 --- a/LICENSE +++ b/LICENSE @@ -1,75 +1,227 @@ -Flora License - -Version 1.0, May, 2012 - -http://www.tizenopensource.org/license - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. - -"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. - -"Tizen Certified Platform" shall mean a software platform that complies with the standards set forth in the Compatibility Definition Document and passes the Compatibility Test Suite as defined from time to time by the Tizen Technical Steering Group and certified by the Tizen Association or its designated agent. - -2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work solely as incorporated into a Tizen Certified Platform, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work solely as incorporated into a Tizen Certified Platform to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof pursuant to the copyright license above, in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: - - 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and - - 2. You must cause any modified files to carry prominent notices stating that You changed the files; and - - 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and - - 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Flora License to your work - -To apply the Flora License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. +Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. Copyright [yyyy] [name of copyright owner] - Licensed under the Flora License, Version 1.0 (the "License"); + 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.tizenopensource.org/license + 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. + +------------------------------------------------------------------------------- +Copyright (c) 2005-2010, Troy D. Hanson http://tpl.sourceforge.net +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + diff --git a/TC/testcase/utc_minicontrol.c b/TC/testcase/utc_minicontrol.c index 8c6c237..cf890d0 100755 --- a/TC/testcase/utc_minicontrol.c +++ b/TC/testcase/utc_minicontrol.c @@ -169,6 +169,7 @@ static void utc_minicontrol_win_add_p(void) int ret; Evas_Object *win = NULL; + elm_init(0, NULL); win = minicontrol_win_add("TETWARE-minicontrol"); dts_check_eq("minicontrol_win_add", win, NULL, "Must return NULL in case of invalid parameter"); @@ -195,6 +196,7 @@ static void utc_minicontrol_request_p(void) int ret; Evas_Object *win = NULL; + elm_init(0, NULL); win = minicontrol_win_add("TETWARE-minicontrol"); ret = minicontrol_request(win, MINICONTROL_REQ_HIDE_VIEWER); dts_check_eq("minicontrol_request", ret, MINICONTROL_ERROR_INVALID_PARAMETER, @@ -294,7 +296,7 @@ static void utc_minicontrol_viewer_request_p(void) { int ret; - ret = minicontrol_viewer_request("com.samsung.quickpanel", MINICONTROL_REQ_HIDE_VIEWER, 0); + ret = minicontrol_viewer_request("org.tizen.quickpanel", MINICONTROL_REQ_HIDE_VIEWER, 0); dts_check_eq("minicontrol_viewer_request", ret, MINICONTROL_ERROR_INVALID_PARAMETER, "Must return MINICONTROL_ERROR_NONE in case of invalid parameter"); diff --git a/doc/doxygen.conf b/doc/doxygen.conf index e071192..6931c0f 100755 --- a/doc/doxygen.conf +++ b/doc/doxygen.conf @@ -648,7 +648,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ./minicontrol_doc.h ../include/minicontrol-error.h ../include/minicontrol.h ../include/minicontrol-monitor.h ../include/minicontrol-provider.h ../include/minicontrol-type.h ../include/minicontrol-viewer.h +INPUT = ./minicontrol_doc.h ../include/minicontrol-error.h ../include/minicontrol.h ../include/minicontrol-monitor.h ../include/minicontrol-provider.h ../include/minicontrol-handler.h ../include/minicontrol-type.h ../include/minicontrol-viewer.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/doc/minicontrol_doc.h b/doc/minicontrol_doc.h index f5c4843..0535b1f 100755 --- a/doc/minicontrol_doc.h +++ b/doc/minicontrol_doc.h @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -16,49 +16,65 @@ /** * - * @ingroup MINICONTROL_LIBRARY - * @defgroup MINICONTROL_MONITOR_MODULE Minicontrol Monitor APIs + * @defgroup MINICONTROL_LIBRARY Minicontrol + * @ingroup CAPI_UI_FRAMEWORK + * + * @section MINICONTROL_LIBRARY_OVERVIEW Overview + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
APIDescription
@ref MINICONTROL_MONITOR_MODULE Provides functions for monitoring and viewing EFL socket window.
@ref MINICONTROL_PROVIDER_MODULE Provides functions for creating EFL socket window.
@ref MINICONTROL_VIEWER_MODULE Provides functions for displaying EFL socket window.
+ */ + + +/** + * @defgroup MINICONTROL_MONITOR_MODULE Monitor * @brief Minicontrol Monitor APIs + * @ingroup MINICONTROL_LIBRARY * * @section MINICONTROL_MONITOR_MODULE_HEADER Required Header * \#include * @section MINICONTROL_MONITOR_MODULE_OVERVIEW Overview - * It provides functions for monitoring and viewing EFL socket window + * It provides functions for monitoring and viewing EFL socket window. * - * @ingroup MINICONTROL_LIBRARY - * @defgroup MINICONTROL_PROVIDER_MODULE Minicontrol Provider APIs + */ + + +/** + * @defgroup MINICONTROL_PROVIDER_MODULE Provider * @brief Minicontrol Provider APIs + * @ingroup MINICONTROL_LIBRARY * * @section MINICONTROL_PROVIDER_MODULE_HEADER Required Header * \#include * @section MINICONTROL_PROVIDER_MODULE_OVERVIEW Overview - * It provides functions for creating EFL socket window + * It provides functions for creating EFL socket window. * - * @ingroup MINICONTROL_LIBRARY - * @defgroup MINICONTROL_VIEWER_MODULE Minicontrol Viewer APIs + */ + + +/** + * @defgroup MINICONTROL_VIEWER_MODULE Viewer * @brief Minicontrol Viewer APIs + * @ingroup MINICONTROL_LIBRARY * * @section MINICONTROL_VIEWER_MODULE_HEADER Required Header * \#include * @section MINICONTROL_VIEWER_MODULE_OVERVIEW Overview * It provides functions for displaying EFL socket window * - * @ingroup MINICONTROL_LIBRARY - * @defgroup MINICONTROL_TYPE Minicontrol type - * @brief Type for minicontrol APIs - * - * @section MINICONTROL_TYPE_MODULE_HEADER Required Header - * \#include - * @section MINICONTROL_TYPE_MODULE_OVERVIEW Overview - * Type defines and enumerations for Minicontrol APIs - * - * @ingroup MINICONTROL_LIBRARY - * @defgroup MINICONTROL_ERROR_TYPE Minicontrol error type - * @brief error type for minicontrol APIs - * - * @section MINICONTROL_ERROR_TYPE_MODULE_HEADER Required Header - * \#include - * @section MINICONTROL_ERROR_TYPE_MODULE_OVERVIEW Overview - * error types for Minicontrol APIs - * */ diff --git a/include/minicontrol-error.h b/include/minicontrol-error.h index 1c52f04..53d2909 100755 --- a/include/minicontrol-error.h +++ b/include/minicontrol-error.h @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -19,23 +19,25 @@ /** * @file minicontrol-error.h - * @brief minicontrol library error type + * @brief Minicontrol library error type. */ /** - * @addtogroup MINICONTROL_ERROR_TYPE + * @addtogroup MINICONTROL_MONITOR_MODULE * @{ */ /** - * @brief Enumeration describing error code of minicontrol library + * @brief Enumeration for describing error code of minicontrol library. */ typedef enum _minicontrol_error { - MINICONTROL_ERROR_NONE = 0, - MINICONTROL_ERROR_INVALID_PARAMETER = -1, - MINICONTROL_ERROR_OUT_OF_MEMORY = -2, - MINICONTROL_ERROR_DBUS = -3, - MINICONTROL_ERROR_UNKNOWN = -100, + MINICONTROL_ERROR_NONE = 0, /**< MiniControl error none */ + MINICONTROL_ERROR_INVALID_PARAMETER = -1, /**< Invalid parameter */ + MINICONTROL_ERROR_OUT_OF_MEMORY = -2, /**< Out of memory */ + MINICONTROL_ERROR_DBUS = -3, /**< Dbus error */ + MINICONTROL_ERROR_BUNDLE = -4, + MINICONTROL_ERROR_NO_DATA = -5, + MINICONTROL_ERROR_UNKNOWN = -100, /**< Unknown error */ }minicontrol_error_e; /** diff --git a/include/minicontrol-handler.h b/include/minicontrol-handler.h new file mode 100755 index 0000000..f42cfd0 --- /dev/null +++ b/include/minicontrol-handler.h @@ -0,0 +1,359 @@ +/* + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MINICTRL_HANDLER_H_ +#define _MINICTRL_HANDLER_H_ + +#include +#include "minicontrol-error.h" +#include "minicontrol-type.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file minicontrol-handler.h + * @brief This minicontrol handler library used to manage handler created with a minicontrol window + */ + +/** + * @addtogroup MINICONTROL_HANDLER_MODULE + * @{ + */ + +/** + * @brief minicontrol category : "UNKNOWN" is treated as "CLOCK" + */ +#define MINICONTROL_HDL_CATEGORY_UNKNOWN "UNKNOWN" +/** + * @brief minicontrol category : CLOCK + */ +#define MINICONTROL_HDL_CATEGORY_CLOCK "CLOCK" +/** + * @brief minicontrol category : NOTIFICATION + */ +#define MINICONTROL_HDL_CATEGORY_NOTIFICATION "NOTIFICATION" +/** + * @brief minicontrol category : DASHBOARD + */ +#define MINICONTROL_HDL_CATEGORY_DASHBOARD "DASHBOARD" + +/** + * @brief minicontrol operation : NONE(do nothing) + */ +#define MINICONTROL_HDL_OPERATION_NONE "NONE" +/** + * @brief minicontrol operation : add a minicontrol + */ +#define MINICONTROL_HDL_OPERATION_ADD "ADD" + /** + * @brief minicontrol operation : show a minicontrol + */ +#define MINICONTROL_HDL_OPERATION_SHOW "SHOW" +/** + * @brief minicontrol operation : remove a minicontrol + */ +#define MINICONTROL_HDL_OPERATION_REMOVE "REMOVE" +/** + * @brief minicontrol operation : reload(rearrange) a minicontrol on the viewer + */ +#define MINICONTROL_HDL_OPERATION_RELOAD "RELOAD" + +/** + * @brief minicontrol priority : LV1(TOP) + */ +#define MINICONTROL_HDL_PRIORITY_LV1 "LV1" +/** + * @brief minicontrol priority : LV2 + */ +#define MINICONTROL_HDL_PRIORITY_LV2 "LV2" +/** + * @brief minicontrol priority : LV3(BOTTOM) + */ +#define MINICONTROL_HDL_PRIORITY_LV3 "LV3" + +/** + * @addtogroup MINICONTROL_HANDLER_MODULE + * @{ + */ + +/** + * @brief Creates a minicontrol handle. + * + * @remarks The @a minicontrol handler must be released with minicontrol_handler_destroy() by you. + * @param [out] handler A minicontrol handle to be newly created on success + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory + * @see minicontrol_handler_destroy() + */ +minicontrol_error_e minicontrol_handler_create(minicontrol_h *handler); + +/** + * @brief Destroys the minicontrol handler and releases all its resources. + * + * @param [in] handler The minicontrol handler + * @return MINICONTROL_ERROR_NONE on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory + * @see minicontrol_handler_create() + */ +minicontrol_error_e minicontrol_handler_destroy(minicontrol_h handler); + +/** + * @brief clone a minicontrol handler + * + * @param [in] handler The minicontrol handler + * @param [in] handler_new The cloned minicontrol handler + * @return MINICONTROL_ERROR_NONE on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory + * @see minicontrol_handler_create() + */ +minicontrol_error_e minicontrol_handler_clone(minicontrol_h handler, minicontrol_h *handler_new); + +/** + * @brief Sets the service name + * + * @remarks service name should be unique. + * @param [in] handler The minicontrol handle + * @param [in] name the service name + * If the @a name is NULL, it clears the previous value. + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @see minicontrol_handler_get_service_name() + */ +minicontrol_error_e minicontrol_handler_set_service_name(minicontrol_h handler, const char *name); + +/** + * @brief Gets the service name + * + * @remarks The @a name must be released with free() by you. + * @param [in] handler The minicontrol handle + * @param [out] name The service name + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory + * @see minicontrol_handler_set_service_name() + */ +minicontrol_error_e minicontrol_handler_get_service_name(minicontrol_h handler, char **name); + +/** + * @brief Sets the category + * + * @param [in] handler The minicontrol handle + * @param [in] category the category + * If the @a category is NULL, it clears the previous value. + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @see minicontrol_handler_set_category() + * @see MINICONTROL_HDL_CATEGORY_UNKNOWN + * @see MINICONTROL_HDL_CATEGORY_CLOCK + * @see MINICONTROL_HDL_CATEGORY_NOTIFICATION + */ +minicontrol_error_e minicontrol_handler_set_category(minicontrol_h handler, const char *category); + +/** + * @brief Gets the category + * + * @remarks The @a category must be released with free() by you. + * @param [in] handler The minicontrol handle + * @param [out] category The category + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @see minicontrol_handler_set_service_name() + * @see MINICONTROL_HDL_CATEGORY_UNKNOWN + * @see MINICONTROL_HDL_CATEGORY_CLOCK + * @see MINICONTROL_HDL_CATEGORY_NOTIFICATION + */ +minicontrol_error_e minicontrol_handler_get_category(minicontrol_h handler, char **category); + +/** + * @brief Sets the operation + * + * @param [in] handler The minicontrol handle + * @param [in] operation the operation + * If the @a operation is NULL, it clears the previous value. + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @see minicontrol_handler_get_operation() + * @see MINICONTROL_HDL_OPERATION_NONE + * @see MINICONTROL_HDL_OPERATION_ADD + * @see MINICONTROL_HDL_OPERATION_REMOVE + * @see MINICONTROL_HDL_OPERATION_RELOAD + */ +minicontrol_error_e minicontrol_handler_set_operation(minicontrol_h handler, const char *operation); + +/** + * @brief Gets the operation + * + * @remarks The @a operation must be released with free() by you. + * @param [in] handler The minicontrol handle + * @param [out] operation The operation + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @see minicontrol_handler_set_operation() + */ +minicontrol_error_e minicontrol_handler_get_operation(minicontrol_h handler, char **operation); + +/** + * @brief Sets the operation + * + * @param [in] handler The minicontrol handle + * @param [in] priority the priority + * If the @a priority is NULL, it clears the previous value. + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @see minicontrol_handler_get_priority() + * @see MINICONTROL_HDL_PRIORITY_LV1 + * @see MINICONTROL_HDL_PRIORITY_LV1 + * @see MINICONTROL_HDL_PRIORITY_LV1 + */ +minicontrol_error_e minicontrol_handler_set_priority(minicontrol_h handler, const char *priority); + +/** + * @brief Gets the priority + * + * @remarks The @a priority must be released with free() by you. + * @param [in] handler The minicontrol handle + * @param [out] priority The priority + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @see MINICONTROL_HDL_PRIORITY_LV1 + * @see MINICONTROL_HDL_PRIORITY_LV1 + * @see MINICONTROL_HDL_PRIORITY_LV1 + * @see minicontrol_handler_set_priority() + */ +minicontrol_error_e minicontrol_handler_get_priority(minicontrol_h handler, char **priority); + +/** + * @brief Sets the timestamp + * + * @param [in] handler The minicontrol handle + * @param [in] timestamp the timestamp + * If the @a timestamp is NULL, it clears the previous value. + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @see minicontrol_handler_get_timestamp() + */ +minicontrol_error_e minicontrol_handler_set_timestamp(minicontrol_h handler, time_t timestamp); + +/** + * @brief Gets the timestamp + * + * @param [in] handler The minicontrol handle + * @param [out] timestamp The timestamp + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory + * @see minicontrol_handler_set_timestamp() + */ +minicontrol_error_e minicontrol_handler_get_timestamp(minicontrol_h handler, time_t *timestamp); + +/** + * @brief Gets the pid which create the minicontrol + * + * @param [in] handler The minicontrol handle + * @param [out] pid The pid + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + */ +minicontrol_error_e minicontrol_handler_get_pid(minicontrol_h handler, int *pid); + +/** + * @brief Gets the state which create the minicontrol + * + * @param [in] handler The minicontrol handle + * @param [out] state The state + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + */ +minicontrol_error_e minicontrol_handler_state_get(minicontrol_h handler, int *state); + +/** + * @brief Adds the extra data to the handler. + * + * @remarks The function replaces any existing value for the given key. + * @remarks The function returns #MINICONTROL_ERROR_INVALID_PARAMETER if key or value is zero-length string. + * @remarks The function returns #MINICONTROL_ERROR_INVALID_PARAMETER if the application tries to use same key with system-defined key + * @param [in] handler The minicontrol handle + * @param [in] key The name of the extra data + * @param [in] value The value associated with given key + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Not available key + * @see minicontrol_handler_get_data() + * @see minicontrol_handler_remove_data() + */ +minicontrol_error_e minicontrol_handler_add_data(minicontrol_h handler, const char *key, const char *value); + +/** + * @brief Gets the extra data from the handler. + * + * @remarks The @a value must be released with free() by you. + * @remarks The function returns #MINICONTROL_ERROR_INVALID_PARAMETER if the value is array data type. + * @param [in] handler The minicontrol handle + * @param [int] key The name of the extra data + * @param [out] value The value associated with given key + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Specified key not found + * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory + * @see minicontrol_handler_add_data() + * @see minicontrol_handler_remove_data() + */ +minicontrol_error_e minicontrol_handler_get_data(minicontrol_h handler, const char *key, char **value); + +/** + * @brief Removes the extra data from the handler. + * + * @param [in] handler The minicontrol handle + * @param [in] key The name of the extra data + * @return 0 on success, otherwise a negative error value. + * @retval #MINICONTROL_ERROR_NONE Successful + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Specified key not found + * @see minicontrol_handler_add_data() + * @see minicontrol_handler_get_data() + */ +minicontrol_error_e minicontrol_handler_remove_data(minicontrol_h handler, const char *key); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif +#endif /* _MINICTRL_HANDLER_H_ */ diff --git a/include/minicontrol-internal-handler.h b/include/minicontrol-internal-handler.h new file mode 100755 index 0000000..3a4e661 --- /dev/null +++ b/include/minicontrol-internal-handler.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _MINICTRL_HANDLER_INTERNAL_H_ +#define _MINICTRL_HANDLER_INTERNAL_H_ + +#include +#include +#include "minicontrol-type.h" +#include "minicontrol-handler.h" + +struct _minicontrol_h { + bundle *data; +}; + +/*! + * contructor/deconstructor + */ +minicontrol_error_e _minictrl_handler_create(minicontrol_h *handler); +minicontrol_error_e _minictrl_handler_destroy(minicontrol_h handler); +minicontrol_error_e _minictrl_handler_clone(minicontrol_h handler, minicontrol_h *handler_new); +minicontrol_error_e _minictrl_handler_check_validation(minicontrol_h handler); + +/*! + * pre-defined properties + */ +minicontrol_error_e _minictrl_handler_set_service_name(minicontrol_h handler, const char *name); +minicontrol_error_e _minictrl_handler_get_service_name(minicontrol_h handler, char **name); +minicontrol_error_e _minictrl_handler_set_category(minicontrol_h handler, const char *category); +minicontrol_error_e _minictrl_handler_get_category(minicontrol_h handler, char **category); +minicontrol_error_e _minictrl_handler_set_operation(minicontrol_h handler, const char *operation); +minicontrol_error_e _minictrl_handler_get_operation(minicontrol_h handler, char **operation); +minicontrol_error_e _minictrl_handler_set_priority(minicontrol_h handler, const char *priority); +minicontrol_error_e _minictrl_handler_get_priority(minicontrol_h handler, char **priority); +minicontrol_error_e _minictrl_handler_set_pid(minicontrol_h handler); +minicontrol_error_e _minictrl_handler_get_pid(minicontrol_h handler, int *pid); +minicontrol_error_e _minictrl_handler_set_timestamp(minicontrol_h handler, time_t timestamp); +minicontrol_error_e _minictrl_handler_get_timestamp(minicontrol_h handler, time_t *timestamp); + +/*! + * user-defined properties + */ +minicontrol_error_e _minictrl_handler_add_extradata(minicontrol_h handler, const char *key, const char *value); +minicontrol_error_e _minictrl_handler_remove_extradata(minicontrol_h handler, const char *key); +minicontrol_error_e _minictrl_handler_get_extradata(minicontrol_h handler, const char *key, char **value); + +/*! + * utility functions + */ +minicontrol_error_e _minictrl_handler_get_raw_data(minicontrol_h handler, char **raw_data, int *length); +minicontrol_error_e _minictrl_handler_get_handler_from_raw_data(minicontrol_h *handler, char *raw_data, int length); + +#endif /* _MINICTRL_INTERNAL_H_ */ + diff --git a/include/minicontrol-internal.h b/include/minicontrol-internal.h index 56c9519..1f3e9ea 100755 --- a/include/minicontrol-internal.h +++ b/include/minicontrol-internal.h @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -19,12 +19,15 @@ #include #include "minicontrol-type.h" +#include "minicontrol-internal-handler.h" +#include "minicontrol-handler.h" #ifndef EXPORT_API #define EXPORT_API __attribute__ ((visibility("default"))) #endif /* EXPORT_API */ #define MINICTRL_DBUS_SIG_START "minicontrol_start" +#define MINICTRL_DBUS_SIG_REALIZE "minicontrol_realize" #define MINICTRL_DBUS_SIG_STOP "minicontrol_stop" #define MINICTRL_DBUS_SIG_RESIZE "minicontrol_resize" #define MINICTRL_DBUS_SIG_RUNNING_REQ "minicontrol_running_request" @@ -34,7 +37,8 @@ typedef struct _minictrl_sig_handle minictrl_sig_handle; int _minictrl_provider_message_send(const char *sig_name, const char *svr_name, unsigned int witdh, unsigned int height, - minicontrol_priority_e priority); + minicontrol_priority_e priority, + minicontrol_h handler); int _minictrl_viewer_req_message_send(void); diff --git a/include/minicontrol-log.h b/include/minicontrol-log.h index 29e72e5..b11cf88 100755 --- a/include/minicontrol-log.h +++ b/include/minicontrol-log.h @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. diff --git a/include/minicontrol-monitor.h b/include/minicontrol-monitor.h index 5a41a71..fc86817 100755 --- a/include/minicontrol-monitor.h +++ b/include/minicontrol-monitor.h @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -19,6 +19,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -26,7 +27,7 @@ extern "C" { /** * @file minicontrol-monitor.h - * @brief This minicontrol monitor library used to manage events triggered by minicontrol provider + * @brief This minicontrol monitor library used to manage events triggered by minicontrol provider. */ /** @@ -35,14 +36,14 @@ extern "C" { */ /** - * @brief Called when event is triggered + * @brief Called when event is triggered. * @param[in] action The type of fired event * @param[in] name The name of provider * @param[in] width The width of provider * @param[in] height The height of provider * @param[in] priority The priority of provider - * @param[in] data user data - * @pre minicontrol_monitor_start() used to register this callback + * @param[in] data User data + * @pre minicontrol_monitor_start() used to register this callback. * @see #minicontrol_action_e * @see #minicontrol_priority_e */ @@ -52,17 +53,31 @@ typedef void (*minicontrol_monitor_cb) (minicontrol_action_e action, unsigned int height, minicontrol_priority_e priority, void *data); +typedef void (*minicontrol_monitor_with_handler_cb) (minicontrol_action_e action, + const char *name, + unsigned int width, + unsigned int height, + minicontrol_priority_e priority, + minicontrol_h handler, + void *data); /** - * @brief Register a callback for events originated by minicontrol provider - * @param[in] callback callback function - * @param[in] data user data + * @brief Registers a callback for events originated by minicontrol provider. + * @param[in] callback Callback function + * @param[in] data User data */ minicontrol_error_e minicontrol_monitor_start(minicontrol_monitor_cb callback, void *data); /** - * @brief Unregister a callback for events originated by minicontrol provider + * @brief Register a callback for events originated by minicontrol provider + * @param[in] callback callback function + * @param[in] data user data + */ +minicontrol_error_e minicontrol_monitor_start_with_handler( + minicontrol_monitor_with_handler_cb callback, void *data); +/** + * @brief Unregisters a callback for events originated by minicontrol provider. * @return #MINICONTROL_ERROR_NONE if success, other value if failure * @see #minicontrol_error_e */ diff --git a/include/minicontrol-provider.h b/include/minicontrol-provider.h index 62d49a2..71e65e8 100755 --- a/include/minicontrol-provider.h +++ b/include/minicontrol-provider.h @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -28,7 +28,7 @@ extern "C" { /** * @file minicontrol-provider.h - * @brief This minicontrol provider library used to create evas socket window + * @brief This minicontrol provider library used to create evas socket window. */ /** @@ -37,21 +37,47 @@ extern "C" { */ /** - * @brief This function create evas socket window - * @param[in] name name of socket window - * @return evas object of socket window + * @brief Creates evas socket window. + * @param[in] name Name of socket window + * @return Evas object of socket window */ Evas_Object *minicontrol_win_add(const char *name); /** - * @brief This function request various action to viewer - * @param[in] minicontrol evas object of socket window - * @param[in] action type of action + * @brief This function create evas socket window with a minicontrol handler + * + * @remarks minicontrol service name should be set before call this function + * @param[in] handler handler of socket window * @return evas object of socket window */ +Evas_Object *minicontrol_win_add_by_handler(minicontrol_h handler); + +/** + * @brief Requests various actions to the viewer. + * @param[in] minicontrol Evas object of socket window + * @param[in] action Type of action + * @return Evas object of socket window + */ minicontrol_error_e minicontrol_request(Evas_Object *mincontrol, minicontrol_request_e request); /** + * @remarks you don't have to destory handler, the handler will be referenced by minicontrol lib + * @brief This function gets a minicontrol handler from the minicontrol object + * @param[in] minicontrol evas object of socket window + * @param[in] handler handler of socket window + * @return minicontrol handler + */ +minicontrol_error_e minicontrol_win_handler_get(Evas_Object *mincontrol, minicontrol_h *handler); + +/** + * @brief This function send request for updating with the updaed minicontrol handler + * @param[in] minicontrol evas object of socket window + * @param[in] handler handler of socket window + * @return evas object of socket window + */ +minicontrol_error_e minicontrol_win_handler_update(Evas_Object *mincontrol, minicontrol_h handler); + +/** * @} */ diff --git a/include/minicontrol-type.h b/include/minicontrol-type.h index 1ded349..019a6b0 100755 --- a/include/minicontrol-type.h +++ b/include/minicontrol-type.h @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -19,58 +19,66 @@ /** * @file minicontrol-type.h - * @brief minicontrol library type + * @brief Minicontrol library type. */ /** - * @addtogroup MINICONTROL_TYPE + * @addtogroup MINICONTROL_MONITOR_MODULE * @{ */ +typedef struct _minicontrol_h *minicontrol_h; + /** - * @breief Enumeration describing type of events originated by minicontrol provider + * @brief Enumeration for describing type of events originated by a minicontrol provider. */ typedef enum _minicontrol_action { - MINICONTROL_ACTION_START = 0, - MINICONTROL_ACTION_STOP, - MINICONTROL_ACTION_RESIZE, - MINICONTROL_ACTION_REQUEST, + MINICONTROL_ACTION_START = 0, /**< A minicontrol object is created */ + MINICONTROL_ACTION_STOP, /**< A minicontrol object is deleted */ + MINICONTROL_ACTION_RESIZE, /**< A minicontrol object is resized */ + MINICONTROL_ACTION_REQUEST, /**< the viewer of the minicontrol object is asked to do something */ + MINICONTROL_ACTION_REALIZE, /**< the viewer of the minicontrol object is realized */ } minicontrol_action_e; /** - * @breief Enumeration describing priority of minicontrol provider + * @brief Enumeration for describing priority of a minicontrol provider. */ typedef enum { - MINICONTROL_PRIORITY_TOP = 1000, - MINICONTROL_PRIORITY_MIDDLE = 100, - MINICONTROL_PRIORITY_LOW = 1, + MINICONTROL_PRIORITY_TOP = 1000, /**< Top priority */ + MINICONTROL_PRIORITY_MIDDLE = 100, /**< Middle priority */ + MINICONTROL_PRIORITY_LOW = 1, /**< Low priority */ }minicontrol_priority_e; /** - * @breief Enumeration describing type of actions + * @brief Enumeration for describing type of actions. */ typedef enum { - MINICONTROL_REQ_NONE = 0, + MINICONTROL_REQ_NONE = 0,/**< Request to viewer */ /*! * request to viewer */ - MINICONTROL_REQ_HIDE_VIEWER = 100, - MINICONTROL_REQ_FREEZE_SCROLL_VIEWER, - MINICONTROL_REQ_UNFREEZE_SCROLL_VIEWER, - MINICONTROL_REQ_REPORT_VIEWER_ANGLE, + MINICONTROL_REQ_HIDE_VIEWER = 100, /**< Request to hide the minicontrol viewer */ + MINICONTROL_REQ_FREEZE_SCROLL_VIEWER, /**< Request to freeze scroll of the minicontrol viewer */ + MINICONTROL_REQ_UNFREEZE_SCROLL_VIEWER, /**< Request to unfreeze scroll of the minicontrol viewer */ + MINICONTROL_REQ_REPORT_VIEWER_ANGLE, /**< Request to report the current angle of the minicontrol viewer */ + MINICONTROL_REQ_UPDATE_HANDLER, /*! * request to provider */ - MINICONTROL_REQ_ROTATE_PROVIDER = 200, + MINICONTROL_REQ_ROTATE_PROVIDER = 200, /**< Request to provider */ MINICONTROL_REQ_PROVIDER_PAUSE = 201, MINICONTROL_REQ_PROVIDER_RESUME = 202, }minicontrol_request_e; +/** + * @brief Enumeration for describing type of dbus. + */ + enum _minictrl_PROC_DBUS_TYPE { - MINICONTROL_DBUS_PROC_EXCLUDE, - MINICONTROL_DBUS_PROC_INCLUDE, + MINICONTROL_DBUS_PROC_EXCLUDE, /**< Request to exclude from the unfreezing process list */ + MINICONTROL_DBUS_PROC_INCLUDE, /**< Request to include to the unfreezing process list */ }; /** diff --git a/include/minicontrol-viewer.h b/include/minicontrol-viewer.h index 2416641..755b992 100755 --- a/include/minicontrol-viewer.h +++ b/include/minicontrol-viewer.h @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -27,7 +27,7 @@ extern "C" { /** * @file minicontrol-viewer.h - * @brief This minicontrol viewer library used to display minicontrol which created by minicontrol provider + * @brief This minicontrol viewer library used to display minicontrol which created by minicontrol provider. */ /** @@ -36,25 +36,25 @@ extern "C" { */ /** - * @brief This function add minicontrol named as "svr_name" to given parent evas object then return it - * @param[in] parent minicontrol object will be added to this parent evas object - * @param[in] svr_name name of minicontrol - * @return evas object of minicontrol + * @brief Adds minicontrol named as "svr_name" to a given parent evas object and returns it. + * @param[in] parent Minicontrol object will be added to this parent evas object + * @param[in] svr_name Name of minicontrol + * @return Evas object of minicontrol */ Evas_Object *minicontrol_viewer_add(Evas_Object *parent, const char *svr_name); /** - * @brief Get the basic evas image object from given minicontrol object - * @param[in] obj minicontrol object - * @return basic evas image object of minicontrol object + * @brief Gets the basic evas image object from given minicontrol object. + * @param[in] obj Minicontrol object + * @return Basic evas image object of minicontrol object */ Evas_Object *minicontrol_viewer_image_object_get(const Evas_Object *obj); /** - * @brief This function request various action to provider - * @param[in] minicontrol evas object of socket window - * @param[in] action type of action - * @return evas object of socket window + * @brief Requests various actions to the provider. + * @param[in] minicontrol Evas object of socket window + * @param[in] action Type of action + * @return Evas object of socket window */ minicontrol_error_e minicontrol_viewer_request(const char *appid, minicontrol_request_e request, int value); diff --git a/include/minicontrol.h b/include/minicontrol.h index a898c7f..4eb3d41 100755 --- a/include/minicontrol.h +++ b/include/minicontrol.h @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. diff --git a/minicontrol-handler.pc.in b/minicontrol-handler.pc.in new file mode 100755 index 0000000..7e0ea32 --- /dev/null +++ b/minicontrol-handler.pc.in @@ -0,0 +1,11 @@ +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: minicontrol-handler +Description: minicontrol handler supporting library +Version: @VERSION@ +Requires: evas +Libs: -L${libdir} -lminicontrol-handler +Cflags: -I${includedir} diff --git a/packaging/minicontrol.spec b/packaging/minicontrol.spec index 095db15..dfbd7a0 100755 --- a/packaging/minicontrol.spec +++ b/packaging/minicontrol.spec @@ -2,9 +2,8 @@ Name: minicontrol Summary: minicontrol library Version: 0.0.16 Release: 1 -VCS: magnolia/apps/home/minicontrol#minicontrol_0.0.5-3-12-g9f2120dd83e9a1f726a621f2ac36bb6ddcce6e95 Group: TBD -License: TBD +License: Apache Source0: %{name}-%{version}.tar.gz BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dbus-glib-1) @@ -12,6 +11,7 @@ BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(ecore-evas) BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(bundle) BuildRequires: cmake Requires(post): /sbin/ldconfig requires(postun): /sbin/ldconfig @@ -62,6 +62,7 @@ cp -f LICENSE %{buildroot}/usr/share/license/%{name} %{_libdir}/libminicontrol-provider.so* %{_libdir}/libminicontrol-viewer.so* %{_libdir}/libminicontrol-monitor.so* +%{_libdir}/libminicontrol-handler.so* /usr/share/license/%{name} %files devel @@ -70,4 +71,5 @@ cp -f LICENSE %{buildroot}/usr/share/license/%{name} %{_libdir}/pkgconfig/minicontrol-provider.pc %{_libdir}/pkgconfig/minicontrol-monitor.pc %{_libdir}/pkgconfig/minicontrol-viewer.pc +%{_libdir}/pkgconfig/minicontrol-handler.pc diff --git a/src/minicontrol-handler.c b/src/minicontrol-handler.c new file mode 100755 index 0000000..a20dfb0 --- /dev/null +++ b/src/minicontrol-handler.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include "minicontrol-error.h" +#include "minicontrol-internal.h" +#include "minicontrol-monitor.h" +#include "minicontrol-log.h" +#include "minicontrol-handler.h" + +/*! + * handler APIs + */ +EXPORT_API minicontrol_error_e minicontrol_handler_create(minicontrol_h *handler) +{ + return _minictrl_handler_create(handler); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_destroy(minicontrol_h handler) +{ + return _minictrl_handler_destroy(handler); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_clone(minicontrol_h handler, minicontrol_h *handler_new) +{ + return _minictrl_handler_clone(handler, handler_new); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_set_service_name(minicontrol_h handler, const char *name) +{ + return _minictrl_handler_set_service_name(handler, name); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_get_service_name(minicontrol_h handler, char **name) +{ + return _minictrl_handler_get_service_name(handler, name); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_set_category(minicontrol_h handler, const char *category) +{ + return _minictrl_handler_set_category(handler, category); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_get_category(minicontrol_h handler, char **category) +{ + return _minictrl_handler_get_category(handler, category); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_set_operation(minicontrol_h handler, const char *operation) +{ + return _minictrl_handler_set_operation(handler, operation); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_get_operation(minicontrol_h handler, char **operation) +{ + return _minictrl_handler_get_operation(handler, operation); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_set_priority(minicontrol_h handler, const char *priority) +{ + return _minictrl_handler_set_priority(handler, priority); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_get_priority(minicontrol_h handler, char **priority) +{ + return _minictrl_handler_get_priority(handler, priority); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_set_timestamp(minicontrol_h handler, time_t timestamp) +{ + return _minictrl_handler_set_timestamp(handler, timestamp); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_get_timestamp(minicontrol_h handler, time_t *timestamp) +{ + return _minictrl_handler_get_timestamp(handler, timestamp); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_get_pid(minicontrol_h handler, int *pid) +{ + return _minictrl_handler_get_pid(handler, pid); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_get_state(minicontrol_h handler, int *state) +{ + return _minictrl_handler_get_state(handler, state); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_add_extradata(minicontrol_h handler, const char *key, const char *value) +{ + return _minictrl_handler_add_extradata(handler, key, value); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_remove_extradata(minicontrol_h handler, const char *key) +{ + return _minictrl_handler_remove_extradata(handler, key); +} + +EXPORT_API minicontrol_error_e minicontrol_handler_get_extradata(minicontrol_h handler, const char *key, char **value) +{ + return _minictrl_handler_get_extradata(handler, key, value); +} diff --git a/src/minicontrol-internal-handler.c b/src/minicontrol-internal-handler.c new file mode 100755 index 0000000..800049f --- /dev/null +++ b/src/minicontrol-internal-handler.c @@ -0,0 +1,508 @@ +/* + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +#include "minicontrol-error.h" +#include "minicontrol-type.h" +#include "minicontrol-internal.h" +#include "minicontrol-monitor.h" +#include "minicontrol-log.h" +#include "minicontrol-handler.h" + +#define BUNDLE_KEY_PID "__KEY_PID__" +#define BUNDLE_KEY_STATE "__KEY_STATE__" +#define BUNDLE_KEY_SERVICE_NAME "__KEY_SERVICE_NAME__" +#define BUNDLE_KEY_CATEGORY "__KEY_CATEGORY__" +#define BUNDLE_KEY_OPERATION "__KEY_OPERATION__" +#define BUNDLE_KEY_PRIORITY "__KEY_PRIORITY__" +#define BUNDLE_KEY_TIMESTAMP "__KEY_TIMESTAMP__" + +/*! + * bundle utility + */ +static int _bundle_set_byte(bundle *b, const char *key, void *value, int length) +{ + int ret = 0; + size_t ret_size = 0; + void *ret_byte = NULL; + + ret = bundle_get_byte(b, key, &ret_byte, &ret_size); + if (ret == 0 && ret_byte != NULL) { + if(bundle_del(b, key) != 0) { + ERR("Failed to del a previous value(key):%s", key); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + } + + if (value == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + if (bundle_add_byte(b, key, value, length) != 0) { + ERR("Failed to set a new value(key):%s", key); + return MINICONTROL_ERROR_BUNDLE; + } + + return MINICONTROL_ERROR_NONE; +} + +static int _bundle_set_str(bundle *b, const char *key, const char *value) +{ + const char *val = NULL; + + val = bundle_get_val(b, key); + if(val != NULL){ + if(bundle_del(b, key) != 0) { + ERR("Failed to del a previous value(key):%s", key); + return MINICONTROL_ERROR_BUNDLE; + } + } + + if(value == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + if(bundle_add(b, key, value) != 0){ + ERR("Failed to set a new value(key):%s", key); + return MINICONTROL_ERROR_BUNDLE; + } + + return MINICONTROL_ERROR_NONE; +} + +/*! + * handler utility + */ +static int _handler_validation_check(minicontrol_h handler) { + if (handler != NULL) { + if (handler->data != NULL) { + return MINICONTROL_ERROR_NONE; + } + } + return MINICONTROL_ERROR_INVALID_PARAMETER; +} + +static int _handler_extradata_key_validation_check(const char *key) { + if (key != NULL) { + if (strcmp(key, BUNDLE_KEY_PID) == 0) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + + } else if (strcmp(key, BUNDLE_KEY_SERVICE_NAME) == 0) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + + } else if (strcmp(key, BUNDLE_KEY_SERVICE_NAME) == 0) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + + } else if (strcmp(key, BUNDLE_KEY_OPERATION) == 0) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + + } else if (strcmp(key, BUNDLE_KEY_PRIORITY) == 0) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + + } else if (strcmp(key, BUNDLE_KEY_TIMESTAMP) == 0) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + return MINICONTROL_ERROR_INVALID_PARAMETER; +} + +/*! + * handler bundle utility + */ +static minicontrol_error_e __set_str_to_handler(minicontrol_h handler, const char *key, const char *value) +{ + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE + || key == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + if (value != NULL) { + return _bundle_set_str(handler->data, key, value); + } else { + bundle_del(handler->data, key); + } + + return MINICONTROL_ERROR_NONE; +} + +static minicontrol_error_e __get_str_from_handler(minicontrol_h handler, const char *key, char **value) +{ + const char *data_value; + + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE + || key == NULL + || value == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER;; + } + + data_value = bundle_get_val(handler->data, key); + if (data_value == NULL) { + if (errno == ENOTSUP) { + return MINICONTROL_ERROR_BUNDLE; + } else { + return MINICONTROL_ERROR_NO_DATA; + } + } + + *value = strdup(data_value); + + return MINICONTROL_ERROR_NONE; +} + +/*! + * handler APIs + */ +minicontrol_error_e _minictrl_handler_create(minicontrol_h *handler) +{ + minicontrol_h handler_new = NULL; + if (handler == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + handler_new = calloc(1, sizeof(struct _minicontrol_h)); + if (handler_new == NULL) { + ERR("Failed to create a handler"); + return MINICONTROL_ERROR_OUT_OF_MEMORY; + } + + handler_new->data = bundle_create(); + if (handler_new->data == NULL) + { + free(handler_new); + ERR("Failed to create a bundle"); + return MINICONTROL_ERROR_OUT_OF_MEMORY; + } + + if (_minictrl_handler_set_pid(handler_new) != MINICONTROL_ERROR_NONE) { + ERR("Failed to set PID to handler"); + } + if (_minictrl_handler_set_state(handler_new, 0) != MINICONTROL_ERROR_NONE) { + ERR("Failed to set state to handler"); + } + if (_minictrl_handler_set_category(handler_new, MINICONTROL_HDL_CATEGORY_UNKNOWN) != MINICONTROL_ERROR_NONE) { + ERR("Failed to set category to handler"); + } + + *handler = handler_new; + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_destroy(minicontrol_h handler) +{ + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + bundle_free(handler->data); + handler->data = NULL; + free(handler); + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_clone(minicontrol_h handler, minicontrol_h *handler_new) +{ + int ret = 0; + + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE || handler_new == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + if ((ret = _minictrl_handler_create(handler_new)) == MINICONTROL_ERROR_NONE) { + (*handler_new)->data = bundle_dup(handler->data); + if ((*handler_new)->data == NULL) { + _minictrl_handler_destroy(*handler_new); + return MINICONTROL_ERROR_OUT_OF_MEMORY; + } + } else { + return ret; + } + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_check_validation(minicontrol_h handler) +{ + return _handler_validation_check(handler); +} + +minicontrol_error_e _minictrl_handler_set_service_name(minicontrol_h handler, const char *name) +{ + return __set_str_to_handler(handler, BUNDLE_KEY_SERVICE_NAME, name); +} + +minicontrol_error_e _minictrl_handler_get_service_name(minicontrol_h handler, char **name) +{ + return __get_str_from_handler(handler, BUNDLE_KEY_SERVICE_NAME, name); +} + +minicontrol_error_e _minictrl_handler_set_category(minicontrol_h handler, const char *category) +{ + return __set_str_to_handler(handler, BUNDLE_KEY_CATEGORY, category); +} + +minicontrol_error_e _minictrl_handler_get_category(minicontrol_h handler, char **category) +{ + return __get_str_from_handler(handler, BUNDLE_KEY_CATEGORY, category); +} + +minicontrol_error_e _minictrl_handler_set_operation(minicontrol_h handler, const char *operation) +{ + return __set_str_to_handler(handler, BUNDLE_KEY_OPERATION, operation); +} + +minicontrol_error_e _minictrl_handler_get_operation(minicontrol_h handler, char **operation) +{ + return __get_str_from_handler(handler, BUNDLE_KEY_OPERATION, operation); +} + +minicontrol_error_e _minictrl_handler_set_priority(minicontrol_h handler, const char *priority) +{ + return __set_str_to_handler(handler, BUNDLE_KEY_PRIORITY, priority); +} + +minicontrol_error_e _minictrl_handler_get_priority(minicontrol_h handler, char **priority) +{ + return __get_str_from_handler(handler, BUNDLE_KEY_PRIORITY, priority); +} + +minicontrol_error_e _minictrl_handler_set_timestamp(minicontrol_h handler, time_t timestamp) +{ + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + if (timestamp > 0) { + return _bundle_set_byte(handler->data, BUNDLE_KEY_TIMESTAMP, (void *)×tamp, sizeof(time_t)); + } else { + bundle_del(handler->data, BUNDLE_KEY_TIMESTAMP); + } + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_get_timestamp(minicontrol_h handler, time_t *timestamp) +{ + int ret = 0; + size_t ret_size = 0; + void *ret_value = NULL; + + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE || timestamp == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + ret = bundle_get_byte(handler->data, BUNDLE_KEY_TIMESTAMP, &ret_value, &ret_size); + if (ret == 0 && ret_value != NULL && ret_size == sizeof(time_t)) { + *timestamp = *((time_t *)ret_value); + } else { + *timestamp = 0; + } + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_set_pid(minicontrol_h handler) +{ + int pid = 0; + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + pid = getpid(); + if (pid > 0) { + return _bundle_set_byte(handler->data, BUNDLE_KEY_PID, (void *)&pid, sizeof(int)); + } else { + bundle_del(handler->data, BUNDLE_KEY_PID); + } + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_get_pid(minicontrol_h handler, int *pid) +{ + int ret = 0; + size_t ret_size = 0; + void *ret_value = NULL; + + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE || pid == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + ret = bundle_get_byte(handler->data, BUNDLE_KEY_PID, &ret_value, &ret_size); + if (ret == 0 && ret_value != NULL && ret_size == sizeof(int)) { + *pid = *((int *)ret_value); + } else { + *pid = 0; + } + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_set_state(minicontrol_h handler, int state) +{ + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + if (state >= 0) { + return _bundle_set_byte(handler->data, BUNDLE_KEY_STATE, (void *)&state, sizeof(int)); + } else { + bundle_del(handler->data, BUNDLE_KEY_STATE); + } + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_get_state(minicontrol_h handler, int *state) +{ + int ret = 0; + size_t ret_size = 0; + void *ret_value = NULL; + + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE || state == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + ret = bundle_get_byte(handler->data, BUNDLE_KEY_STATE, &ret_value, &ret_size); + if (ret == 0 && ret_value != NULL && ret_size == sizeof(int)) { + *state = *((int *)ret_value); + } else { + *state = 0; + } + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_add_extradata(minicontrol_h handler, const char *key, const char *value) +{ + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE + || _handler_extradata_key_validation_check(key) != MINICONTROL_ERROR_NONE + || value == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER;; + } + + return _bundle_set_str(handler->data, key, value); +} + +minicontrol_error_e _minictrl_handler_remove_extradata(minicontrol_h handler, const char *key) +{ + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE + || _handler_extradata_key_validation_check(key) != MINICONTROL_ERROR_NONE) { + return MINICONTROL_ERROR_INVALID_PARAMETER;; + } + + if (bundle_del(handler->data, key)) { + return MINICONTROL_ERROR_NO_DATA; + } + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_get_extradata(minicontrol_h handler, const char *key, char **value) +{ + const char *data_value; + + if (_handler_validation_check(handler) != MINICONTROL_ERROR_NONE + || _handler_extradata_key_validation_check(key) != MINICONTROL_ERROR_NONE + || value == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER;; + } + + data_value = bundle_get_val(handler->data, key); + if (data_value == NULL) { + if (errno == ENOTSUP) { + return MINICONTROL_ERROR_BUNDLE; + } else { + return MINICONTROL_ERROR_NO_DATA; + } + } + + *value = strdup(data_value); + + return MINICONTROL_ERROR_NONE; +} + +minicontrol_error_e _minictrl_handler_get_raw_data(minicontrol_h handler, char **raw_data, int *length) +{ + if (handler == NULL || raw_data == NULL || length == NULL) { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + if (handler->data != NULL) { + bundle_encode(handler->data, + (bundle_raw **) raw_data, length); + } else { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + return MINICONTROL_ERROR_NONE; +} + +static void iterate_bundleforeach(const char *key,const int type, bundle_keyval_t *kv, void *data) +{ + switch(type) + { + case BUNDLE_TYPE_STR: + { + size_t size; + char *basic_val = NULL; + + if (basic_val != NULL) { + bundle_keyval_get_basic_val(kv,(void *)&basic_val,&size); + ERR("Key: %s ---- Val: %s\n",key,basic_val); + } + break; + } + case BUNDLE_TYPE_BYTE: + { + size_t size; + char *basic_val = NULL; + + if (basic_val != NULL) { + bundle_keyval_get_basic_val(kv,(void *)&basic_val,&size); + ERR("Key: %s ---- Val: %d\n",key, *((int *)basic_val)); + } + break; + } + default: + { + DBG("\n no match found"); + DBG("Key: %s is of type %d\n",key, type); + break; + } + } +} + +minicontrol_error_e _minictrl_handler_get_handler_from_raw_data(minicontrol_h *handler, char *raw_data, int length) +{ + if (_minictrl_handler_create(handler) == MINICONTROL_ERROR_NONE) { + (*handler)->data = bundle_decode((bundle_raw *)raw_data, length); + bundle_foreach((*handler)->data,(void *)iterate_bundleforeach,NULL); + } else { + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + return MINICONTROL_ERROR_NONE; +} diff --git a/src/minicontrol-internal.c b/src/minicontrol-internal.c index 8838d64..9b0d1a6 100755 --- a/src/minicontrol-internal.c +++ b/src/minicontrol-internal.c @@ -1,20 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include +#include #include #include @@ -22,6 +23,7 @@ #include "minicontrol-type.h" #include "minicontrol-internal.h" #include "minicontrol-log.h" +#include "minicontrol-handler.h" #define MINICTRL_DBUS_PATH "/org/tizen/minicontrol" #define MINICTRL_DBUS_INTERFACE "org.tizen.minicontrol.signal" @@ -139,13 +141,16 @@ release_n_return: int _minictrl_provider_message_send(const char *sig_name, const char *svr_name, unsigned int witdh, unsigned int height, - minicontrol_priority_e priority) + minicontrol_priority_e priority, + minicontrol_h handler) { DBusConnection *connection = NULL; DBusMessage *message = NULL; DBusError err; dbus_bool_t dbus_ret; int ret = MINICONTROL_ERROR_NONE; + int handler_raw_data_len = 0; + char *handler_raw_data = NULL; if (!sig_name) { ERR("sig_name is NULL, invaild parameter"); @@ -157,6 +162,10 @@ int _minictrl_provider_message_send(const char *sig_name, const char *svr_name, return MINICONTROL_ERROR_INVALID_PARAMETER; } + if (handler != NULL) { + _minictrl_handler_get_raw_data(handler, &handler_raw_data, &handler_raw_data_len); + } + dbus_error_init(&err); connection = dbus_bus_get(DBUS_BUS_SYSTEM, &err); if (!connection) { @@ -175,12 +184,24 @@ int _minictrl_provider_message_send(const char *sig_name, const char *svr_name, goto release_n_return; } - dbus_ret = dbus_message_append_args(message, - DBUS_TYPE_STRING, &svr_name, - DBUS_TYPE_UINT32, &witdh, - DBUS_TYPE_UINT32, &height, - DBUS_TYPE_UINT32, &priority, - DBUS_TYPE_INVALID); + + if (handler_raw_data != NULL && handler_raw_data_len > 0) { + dbus_ret = dbus_message_append_args(message, + DBUS_TYPE_STRING, &svr_name, + DBUS_TYPE_UINT32, &witdh, + DBUS_TYPE_UINT32, &height, + DBUS_TYPE_UINT32, &priority, + DBUS_TYPE_STRING, &handler_raw_data, + DBUS_TYPE_UINT32, &handler_raw_data_len, + DBUS_TYPE_INVALID); + } else { + dbus_ret = dbus_message_append_args(message, + DBUS_TYPE_STRING, &svr_name, + DBUS_TYPE_UINT32, &witdh, + DBUS_TYPE_UINT32, &height, + DBUS_TYPE_UINT32, &priority, + DBUS_TYPE_INVALID); + } if (!dbus_ret) { ERR("fail to append name to dbus message : %s", svr_name); ret = MINICONTROL_ERROR_OUT_OF_MEMORY; diff --git a/src/minicontrol-monitor.c b/src/minicontrol-monitor.c index 1217ae8..50f9609 100755 --- a/src/minicontrol-monitor.c +++ b/src/minicontrol-monitor.c @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -24,10 +24,12 @@ struct _minicontrol_monitor { minictrl_sig_handle *start_sh; + minictrl_sig_handle *realize_sh; minictrl_sig_handle *stop_sh; minictrl_sig_handle *resize_sh; minictrl_sig_handle *request_sh; minicontrol_monitor_cb callback; + minicontrol_monitor_with_handler_cb callback_with_handler; void *user_data; }; @@ -51,131 +53,212 @@ static minicontrol_priority_e _int_to_priority(unsigned int value) return priority; } -static void _provider_start_cb(void *data, DBusMessage *msg) +static int _provider_get_data_from_dbus_message( + DBusMessage *msg, char **name, + unsigned int *w, unsigned int *h, unsigned int *pri, + minicontrol_h *handler) { + DBusError err; + dbus_bool_t dbus_ret; + char *raw_data = NULL; + int raw_data_len = 0; + + if (msg != NULL && name != NULL && + w != NULL && h != NULL && pri != NULL && + handler != NULL) { + dbus_error_init(&err); + dbus_ret = dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, name, + DBUS_TYPE_UINT32, w, + DBUS_TYPE_UINT32, h, + DBUS_TYPE_UINT32, pri, + DBUS_TYPE_STRING, &raw_data, + DBUS_TYPE_UINT32, &raw_data_len, + DBUS_TYPE_INVALID); + if (!dbus_ret) { + ERR("fail to get args : %s", err.message); + if (*name == NULL) { + ERR("Failed to get a service name, give up"); + dbus_error_free(&err); + return MINICONTROL_ERROR_DBUS; + } + } + + if (raw_data != NULL && raw_data_len > 0) { + _minictrl_handler_get_handler_from_raw_data(handler, raw_data, raw_data_len); + } else { + ERR("failed to get handler from DBUS message"); + } + dbus_error_free(&err); + } + + return MINICONTROL_ERROR_NONE; +} + +static void _provider_start_cb(void *data, DBusMessage *msg) +{ char *svr_name = NULL; unsigned int w = 0; unsigned int h = 0; unsigned int pri = 0; + minicontrol_h handler = NULL; minicontrol_priority_e priority; - dbus_bool_t dbus_ret; - dbus_error_init(&err); - - dbus_ret = dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &svr_name, - DBUS_TYPE_UINT32, &w, - DBUS_TYPE_UINT32, &h, - DBUS_TYPE_UINT32, &pri, - DBUS_TYPE_INVALID); - if (!dbus_ret) { - ERR("fail to get args : %s", err.message); - dbus_error_free(&err); - return; + if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { + ERR("fail to data from DBUS message"); + return ; } priority = _int_to_priority(pri); - if (g_monitor_h->callback) + if (g_monitor_h->callback) { g_monitor_h->callback(MINICONTROL_ACTION_START, svr_name, w, h, priority, g_monitor_h->user_data); + } + if (g_monitor_h->callback_with_handler) { + g_monitor_h->callback_with_handler(MINICONTROL_ACTION_START, + svr_name, w, h, priority, + handler, + g_monitor_h->user_data); + } - dbus_error_free(&err); + if (handler != NULL) { + _minictrl_handler_destroy(handler); + } } -static void _provider_stop_cb(void *data, DBusMessage *msg) +static void _provider_realized_cb(void *data, DBusMessage *msg) { - DBusError err; char *svr_name = NULL; - dbus_bool_t dbus_ret; + unsigned int w = 0; + unsigned int h = 0; + unsigned int pri = 0; + minicontrol_h handler = NULL; + minicontrol_priority_e priority; - dbus_error_init(&err); + if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { + ERR("fail to data from DBUS message"); + return ; + } - dbus_ret = dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &svr_name, - DBUS_TYPE_INVALID); - if (!dbus_ret) { - ERR("fail to get args : %s", err.message); - dbus_error_free(&err); - return; + priority = _int_to_priority(pri); + + if (g_monitor_h->callback) { + g_monitor_h->callback(MINICONTROL_ACTION_REALIZE, + svr_name, w, h, priority, + g_monitor_h->user_data); + } + if (g_monitor_h->callback_with_handler) { + g_monitor_h->callback_with_handler(MINICONTROL_ACTION_REALIZE, + svr_name, w, h, priority, + handler, + g_monitor_h->user_data); + } + + if (handler != NULL) { + _minictrl_handler_destroy(handler); + } +} + +static void _provider_stop_cb(void *data, DBusMessage *msg) +{ + char *svr_name = NULL; + unsigned int w = 0; + unsigned int h = 0; + unsigned int pri = 0; + minicontrol_h handler = NULL; + minicontrol_priority_e priority; + + if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { + ERR("fail to data from DBUS message"); + return ; } - if (g_monitor_h->callback) + priority = _int_to_priority(pri); + + if (g_monitor_h->callback) { g_monitor_h->callback(MINICONTROL_ACTION_STOP, - svr_name, 0, 0, MINICONTROL_PRIORITY_LOW, + svr_name, w, h, priority, g_monitor_h->user_data); + } + if (g_monitor_h->callback_with_handler) { + g_monitor_h->callback_with_handler(MINICONTROL_ACTION_STOP, + svr_name, w, h, priority, + handler, + g_monitor_h->user_data); + } - dbus_error_free(&err); + if (handler != NULL) { + _minictrl_handler_destroy(handler); + } } static void _provider_resize_cb(void *data, DBusMessage *msg) { - DBusError err; char *svr_name = NULL; unsigned int w = 0; unsigned int h = 0; unsigned int pri = 0; + minicontrol_h handler = NULL; minicontrol_priority_e priority; - dbus_bool_t dbus_ret; - - dbus_error_init(&err); - dbus_ret = dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &svr_name, - DBUS_TYPE_UINT32, &w, - DBUS_TYPE_UINT32, &h, - DBUS_TYPE_UINT32, &pri, - DBUS_TYPE_INVALID); - if (!dbus_ret) { - ERR("fail to get args : %s", err.message); - dbus_error_free(&err); - return; + if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { + ERR("fail to data from DBUS message"); + return ; } priority = _int_to_priority(pri); - if (g_monitor_h->callback) + if (g_monitor_h->callback) { g_monitor_h->callback(MINICONTROL_ACTION_RESIZE, svr_name, w, h, priority, g_monitor_h->user_data); + } + if (g_monitor_h->callback_with_handler) { + g_monitor_h->callback_with_handler(MINICONTROL_ACTION_RESIZE, + svr_name, w, h, priority, + handler, + g_monitor_h->user_data); + } - dbus_error_free(&err); + if (handler != NULL) { + _minictrl_handler_destroy(handler); + } } static void _provider_request_cb(void *data, DBusMessage *msg) { - DBusError err; char *svr_name = NULL; unsigned int w = 0; unsigned int h = 0; unsigned int pri = 0; + minicontrol_h handler = NULL; minicontrol_priority_e priority; - dbus_bool_t dbus_ret; - - dbus_error_init(&err); - dbus_ret = dbus_message_get_args(msg, &err, - DBUS_TYPE_STRING, &svr_name, - DBUS_TYPE_UINT32, &w, - DBUS_TYPE_UINT32, &h, - DBUS_TYPE_UINT32, &pri, - DBUS_TYPE_INVALID); - if (!dbus_ret) { - ERR("fail to get args : %s", err.message); - dbus_error_free(&err); - return; + if (_provider_get_data_from_dbus_message(msg, &svr_name, &w, &h, &pri, &handler) != MINICONTROL_ERROR_NONE) { + ERR("fail to data from DBUS message"); + return ; } priority = _int_to_priority(pri); - if (g_monitor_h->callback) + if (g_monitor_h->callback) { g_monitor_h->callback(MINICONTROL_ACTION_REQUEST, svr_name, w, h, priority, g_monitor_h->user_data); + } + if (g_monitor_h->callback_with_handler) { + g_monitor_h->callback_with_handler(MINICONTROL_ACTION_REQUEST, + svr_name, w, h, priority, + handler, + g_monitor_h->user_data); + } - dbus_error_free(&err); + if (handler != NULL) { + _minictrl_handler_destroy(handler); + } } EXPORT_API minicontrol_error_e minicontrol_monitor_start( @@ -186,6 +269,7 @@ EXPORT_API minicontrol_error_e minicontrol_monitor_start( if (!g_monitor_h) { minictrl_sig_handle *start_sh; + minictrl_sig_handle *realize_sh; minictrl_sig_handle *stop_sh; minictrl_sig_handle *resize_sh; minictrl_sig_handle *request_sh; @@ -200,6 +284,15 @@ EXPORT_API minicontrol_error_e minicontrol_monitor_start( return MINICONTROL_ERROR_DBUS; } + realize_sh = _minictrl_dbus_sig_handle_attach( + MINICTRL_DBUS_SIG_REALIZE, + _provider_realized_cb, NULL); + if (!realize_sh) { + ERR("fail to _minictrl_dbus_sig_handle_attach - %s", + MINICTRL_DBUS_SIG_REALIZE); + return MINICONTROL_ERROR_DBUS; + } + stop_sh = _minictrl_dbus_sig_handle_attach( MINICTRL_DBUS_SIG_STOP, _provider_stop_cb, NULL); @@ -227,10 +320,11 @@ EXPORT_API minicontrol_error_e minicontrol_monitor_start( return MINICONTROL_ERROR_DBUS; } - monitor_h = malloc(sizeof(struct _minicontrol_monitor)); + monitor_h = calloc(1, sizeof(struct _minicontrol_monitor)); if (!monitor_h) { ERR("fail to alloc monitor_h"); _minictrl_dbus_sig_handle_dettach(start_sh); + _minictrl_dbus_sig_handle_dettach(realize_sh); _minictrl_dbus_sig_handle_dettach(stop_sh); _minictrl_dbus_sig_handle_dettach(resize_sh); _minictrl_dbus_sig_handle_dettach(request_sh); @@ -238,9 +332,12 @@ EXPORT_API minicontrol_error_e minicontrol_monitor_start( } monitor_h->start_sh = start_sh; + monitor_h->realize_sh = realize_sh; monitor_h->stop_sh = stop_sh; monitor_h->resize_sh = resize_sh; monitor_h->request_sh = request_sh; + monitor_h->callback = NULL; + monitor_h->callback_with_handler = NULL; g_monitor_h = monitor_h; } @@ -251,6 +348,93 @@ EXPORT_API minicontrol_error_e minicontrol_monitor_start( return _minictrl_viewer_req_message_send(); } +EXPORT_API minicontrol_error_e minicontrol_monitor_start_with_handler( + minicontrol_monitor_with_handler_cb callback, void *data) +{ + if (!callback) + return MINICONTROL_ERROR_INVALID_PARAMETER; + + if (!g_monitor_h) { + minictrl_sig_handle *start_sh; + minictrl_sig_handle *realize_sh; + minictrl_sig_handle *stop_sh; + minictrl_sig_handle *resize_sh; + minictrl_sig_handle *request_sh; + struct _minicontrol_monitor *monitor_h; + + start_sh = _minictrl_dbus_sig_handle_attach( + MINICTRL_DBUS_SIG_START, + _provider_start_cb, NULL); + if (!start_sh) { + ERR("fail to _minictrl_dbus_sig_handle_attach - %s", + MINICTRL_DBUS_SIG_START); + return MINICONTROL_ERROR_DBUS; + } + + realize_sh = _minictrl_dbus_sig_handle_attach( + MINICTRL_DBUS_SIG_REALIZE, + _provider_realized_cb, NULL); + if (!realize_sh) { + ERR("fail to _minictrl_dbus_sig_handle_attach - %s", + MINICTRL_DBUS_SIG_REALIZE); + return MINICONTROL_ERROR_DBUS; + } + + stop_sh = _minictrl_dbus_sig_handle_attach( + MINICTRL_DBUS_SIG_STOP, + _provider_stop_cb, NULL); + if (!stop_sh) { + ERR("fail to _minictrl_dbus_sig_handle_attach - %s", + MINICTRL_DBUS_SIG_STOP); + return MINICONTROL_ERROR_DBUS; + } + + resize_sh = _minictrl_dbus_sig_handle_attach( + MINICTRL_DBUS_SIG_RESIZE, + _provider_resize_cb, NULL); + if (!resize_sh) { + ERR("fail to _minictrl_dbus_sig_handle_attach - %s", + MINICTRL_DBUS_SIG_RESIZE); + return MINICONTROL_ERROR_DBUS; + } + + request_sh = _minictrl_dbus_sig_handle_attach( + MINICTRL_DBUS_SIG_REQUEST, + _provider_request_cb, NULL); + if (!request_sh) { + ERR("fail to _minictrl_dbus_sig_handle_attach - %s", + MINICTRL_DBUS_SIG_REQUEST); + return MINICONTROL_ERROR_DBUS; + } + + monitor_h = calloc(1, sizeof(struct _minicontrol_monitor)); + if (!monitor_h) { + ERR("fail to alloc monitor_h"); + _minictrl_dbus_sig_handle_dettach(start_sh); + _minictrl_dbus_sig_handle_dettach(realize_sh); + _minictrl_dbus_sig_handle_dettach(stop_sh); + _minictrl_dbus_sig_handle_dettach(resize_sh); + _minictrl_dbus_sig_handle_dettach(request_sh); + return MINICONTROL_ERROR_OUT_OF_MEMORY; + } + + monitor_h->start_sh = start_sh; + monitor_h->realize_sh = realize_sh; + monitor_h->stop_sh = stop_sh; + monitor_h->resize_sh = resize_sh; + monitor_h->request_sh = request_sh; + monitor_h->callback = NULL; + monitor_h->callback_with_handler = NULL; + g_monitor_h = monitor_h; + } + + g_monitor_h->callback_with_handler = callback; + g_monitor_h->user_data = data; + INFO("callback[%p], data[%p]", callback, data); + + return _minictrl_viewer_req_message_send(); +} + EXPORT_API minicontrol_error_e minicontrol_monitor_stop(void) { if (!g_monitor_h) @@ -259,6 +443,9 @@ EXPORT_API minicontrol_error_e minicontrol_monitor_stop(void) if (g_monitor_h->start_sh) _minictrl_dbus_sig_handle_dettach(g_monitor_h->start_sh); + if (g_monitor_h->realize_sh) + _minictrl_dbus_sig_handle_dettach(g_monitor_h->realize_sh); + if (g_monitor_h->stop_sh) _minictrl_dbus_sig_handle_dettach(g_monitor_h->stop_sh); diff --git a/src/minicontrol-provider.c b/src/minicontrol-provider.c index dab9c18..bda4b06 100755 --- a/src/minicontrol-provider.c +++ b/src/minicontrol-provider.c @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -21,6 +21,7 @@ #include "minicontrol-internal.h" #include "minicontrol-provider.h" #include "minicontrol-log.h" +#include "minicontrol-handler.h" #define MINICTRL_PRIORITY_SUFFIX_TOP "__minicontrol_top" #define MINICTRL_PRIORITY_SUFFIX_LOW "__minicontrol_low" @@ -37,6 +38,7 @@ struct _provider_data { minicontrol_priority_e priority; Evas_Object *obj; minictrl_sig_handle *sh; + minicontrol_h handler; }; static void __provider_data_free(struct _provider_data *pd) @@ -48,6 +50,9 @@ static void __provider_data_free(struct _provider_data *pd) if (pd->sh) _minictrl_dbus_sig_handle_dettach(pd->sh); + if (pd->handler) + _minictrl_handler_destroy(pd->handler); + free(pd); } } @@ -87,7 +92,7 @@ static void _running_req_cb(void *data, DBusMessage *msg) Evas_Coord h = 0; evas_object_geometry_get(pd->obj, NULL, NULL, &w, &h); _minictrl_provider_message_send(MINICTRL_DBUS_SIG_START, - pd->name, w, h, pd->priority); + pd->name, w, h, pd->priority, pd->handler); } } @@ -120,9 +125,43 @@ static int minicontrol_win_start(Evas_Object *mincontrol) evas_object_geometry_get(mincontrol, NULL, NULL, &w, &h); _minictrl_provider_proc_send(MINICONTROL_DBUS_PROC_EXCLUDE); ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_START, - pd->name, w, h, pd->priority); + pd->name, w, h, pd->priority, pd->handler); + } + + return ret; +} + +static int minicontrol_win_realize(Evas_Object *mincontrol) +{ + struct _provider_data *pd; + int ret = MINICONTROL_ERROR_NONE; + + if (!mincontrol) { + ERR("mincontrol is NULL, invaild parameter"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + pd = evas_object_data_get(mincontrol, MINICTRL_DATA_KEY); + if (!pd) { + ERR("pd is NULL, invaild parameter"); + return MINICONTROL_ERROR_INVALID_PARAMETER; } + if (!pd->name) { + ERR("pd name is NULL, invaild parameter"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + Evas_Coord w = 0; + Evas_Coord h = 0; + if (pd->state != MINICTRL_STATE_RUNNING) { + pd->state = MINICTRL_STATE_RUNNING; + } + + evas_object_geometry_get(mincontrol, NULL, NULL, &w, &h); + ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_REALIZE, + pd->name, w, h, pd->priority, pd->handler); + return ret; } @@ -150,7 +189,7 @@ static int minicontrol_win_stop(Evas_Object *mincontrol) pd->state = MINICTRL_STATE_READY; _minictrl_provider_proc_send(MINICONTROL_DBUS_PROC_INCLUDE); ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_STOP, - pd->name, 0, 0, pd->priority); + pd->name, 0, 0, pd->priority, pd->handler); } return ret; @@ -181,6 +220,35 @@ static void _minictrl_win_show(void *data, Evas *e, minicontrol_win_start(obj); } +static void _minictrl_win_realize(void *data, Evas *e, + Evas_Object *obj, void *event_info) +{ + struct _provider_data *pd; + + if (!data) { + ERR("data is NULL, invaild parameter"); + return; + } + pd = data; + + if (!pd->obj) { + ERR("minicontrol object is NULL, invalid parameter"); + return; + } + + Evas *win_e = evas_object_evas_get(pd->obj); + if (win_e != NULL) { + evas_event_callback_del(win_e, EVAS_CALLBACK_RENDER_POST, + _minictrl_win_realize); + } + + minicontrol_win_realize(pd->obj); + + if (pd->handler != NULL) { + _minictrl_handler_set_state(pd->handler, 1); + } +} + static void _minictrl_win_resize(void *data, Evas *e, Evas_Object *obj, void *event_info) { @@ -198,7 +266,7 @@ static void _minictrl_win_resize(void *data, Evas *e, evas_object_geometry_get(obj, NULL, NULL, &w, &h); _minictrl_provider_message_send(MINICTRL_DBUS_SIG_RESIZE, - pd->name, w, h, pd->priority); + pd->name, w, h, pd->priority, pd->handler); } } @@ -238,27 +306,83 @@ static minicontrol_priority_e _minictrl_get_priroty_by_name(const char *name) EXPORT_API Evas_Object *minicontrol_win_add(const char *name) { + minicontrol_h handler = NULL; + Evas_Object *win = NULL; + + if (_minictrl_handler_create(&handler) == MINICONTROL_ERROR_NONE) { + if (_minictrl_handler_set_service_name(handler, name) != MINICONTROL_ERROR_NONE) { + ERR("failed to service name"); + _minictrl_handler_destroy(handler); + return NULL; + } + if (_minictrl_handler_set_timestamp(handler, time(NULL)) != MINICONTROL_ERROR_NONE) { + ERR("failed to set timestamp"); + } + if (_minictrl_handler_set_priority(handler, MINICONTROL_HDL_PRIORITY_LV3) != MINICONTROL_ERROR_NONE) { + ERR("failed to set priority"); + } + } else { + ERR("Failed to create minicontrol handler"); + return NULL; + } + + win = minicontrol_win_add_by_handler(handler); + _minictrl_handler_destroy(handler); + + return win; +} + +EXPORT_API Evas_Object *minicontrol_win_add_by_handler(minicontrol_h handler) +{ Evas_Object *win = NULL; + char *name = NULL; char *name_inter = NULL; + char *priority = NULL; struct _provider_data *pd; + time_t timestamp_value = 0; - if (!name) + if (_minictrl_handler_check_validation(handler) != MINICONTROL_ERROR_NONE) { + ERR("handler is invalid, invaild parameter"); return NULL; + } + + _minictrl_handler_get_service_name(handler, &name); + if (name == NULL) { + ERR("service name cannot be NULL"); + return NULL; + } + _minictrl_handler_get_timestamp(handler, ×tamp_value); + if (timestamp_value == 0) { + if (_minictrl_handler_set_timestamp(handler, time(NULL)) != MINICONTROL_ERROR_NONE) { + ERR("failed to set timestamp"); + } + } + _minictrl_handler_get_priority(handler, &priority); + if (priority == NULL) { + if (_minictrl_handler_set_priority(handler, MINICONTROL_HDL_PRIORITY_LV3) != MINICONTROL_ERROR_NONE) { + ERR("failed to set priority"); + } + } else { + free(priority); + } win = elm_win_add(NULL, "minicontrol", ELM_WIN_SOCKET_IMAGE); - if (!win) + if (!win) { + free(name); return NULL; + } name_inter = _minictrl_create_name(name); if (!name_inter) { - ERR("Fail to create name_inter for : %s", name); + free(name); evas_object_del(win); return NULL; } if (!elm_win_socket_listen(win, name_inter, 0, EINA_TRUE)) { ERR("Fail to elm win socket listen"); + free(name); evas_object_del(win); free(name_inter); return NULL; @@ -267,6 +391,7 @@ EXPORT_API Evas_Object *minicontrol_win_add(const char *name) pd = malloc(sizeof(struct _provider_data)); if (!pd) { ERR("Fail to alloc memory"); + free(name); evas_object_del(win); free(name_inter); return NULL; @@ -278,6 +403,15 @@ EXPORT_API Evas_Object *minicontrol_win_add(const char *name) pd->obj = win; pd->priority = _minictrl_get_priroty_by_name(name); + if (_minictrl_handler_clone(handler, &(pd->handler)) != MINICONTROL_ERROR_NONE) { + ERR("Fail to clone handler"); + free(name); + evas_object_del(win); + free(name_inter); + free(pd); + return NULL; + } + evas_object_data_set(win ,MINICTRL_DATA_KEY,pd); elm_win_autodel_set(win, EINA_TRUE); @@ -294,13 +428,88 @@ EXPORT_API Evas_Object *minicontrol_win_add(const char *name) evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _minictrl_win_resize, pd); + Evas *win_e = evas_object_evas_get(win); + if (win_e != NULL) { + evas_event_callback_add(win_e, EVAS_CALLBACK_RENDER_POST, + _minictrl_win_realize, pd); + } + pd->sh = _minictrl_dbus_sig_handle_attach(MINICTRL_DBUS_SIG_RUNNING_REQ, _running_req_cb, pd); INFO("new minicontrol created - %s", pd->name); + + free(name); + return win; } +EXPORT_API minicontrol_error_e minicontrol_win_handler_get(Evas_Object *mincontrol, minicontrol_h *handler) +{ + if (!mincontrol) { + ERR("invaild mincontrol object"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + if (!handler) { + ERR("invaild mincontrol handler"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + struct _provider_data *pd = evas_object_data_get(mincontrol, MINICTRL_DATA_KEY); + if (pd != NULL) { + *handler = pd->handler; + } else { + return MINICONTROL_ERROR_NO_DATA; + } + + return MINICONTROL_ERROR_NONE; +} + +EXPORT_API minicontrol_error_e minicontrol_win_handler_update(Evas_Object *mincontrol, minicontrol_h handler) +{ + struct _provider_data *pd; + int ret = MINICONTROL_ERROR_NONE; + + if (!mincontrol) { + ERR("mincontrol is NULL, invaild parameter"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + if (_minictrl_handler_check_validation(handler) != MINICONTROL_ERROR_NONE) { + ERR("handler is invalid, invaild parameter"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + pd = evas_object_data_get(mincontrol, MINICTRL_DATA_KEY); + if (!pd) { + ERR("pd is NULL, invaild parameter"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + if (!pd->name) { + ERR("pd name is NULL, invaild parameter"); + return MINICONTROL_ERROR_INVALID_PARAMETER; + } + + if (pd->handler != handler) { + if (pd->handler != NULL) { + _minictrl_handler_destroy(pd->handler); + pd->handler = NULL; + } + if (_minictrl_handler_clone(handler, &(pd->handler)) != MINICONTROL_ERROR_NONE) { + ERR("failed to clone a minicontrol handler"); + return MINICONTROL_ERROR_OUT_OF_MEMORY; + } + } + + if (pd->state == MINICTRL_STATE_RUNNING) { + ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_REQUEST, + pd->name, MINICONTROL_REQ_UPDATE_HANDLER, MINICONTROL_REQ_UPDATE_HANDLER + , pd->priority, pd->handler); + } + + return ret; +} + EXPORT_API minicontrol_error_e minicontrol_request(Evas_Object *mincontrol, minicontrol_request_e request) { struct _provider_data *pd; @@ -324,7 +533,7 @@ EXPORT_API minicontrol_error_e minicontrol_request(Evas_Object *mincontrol, mini if (pd->state == MINICTRL_STATE_RUNNING) { ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_REQUEST, - pd->name, request, request, pd->priority); + pd->name, request, request, pd->priority, pd->handler); } return ret; diff --git a/src/minicontrol-viewer.c b/src/minicontrol-viewer.c index 681cd4d..5e6e5dd 100755 --- a/src/minicontrol-viewer.c +++ b/src/minicontrol-viewer.c @@ -1,14 +1,14 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd + * Copyright (c) 2013-2015 Samsung Electronics Co., Ltd All Rights Reserved * - * Licensed under the Flora License, Version 1.0 (the "License"); + * 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.tizenopensource.org/license + * 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, + * 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. @@ -39,7 +39,7 @@ static void _minictrl_plug_server_del(Ecore_Evas *ee) /* send message to remve plug */ _minictrl_provider_message_send(MINICTRL_DBUS_SIG_STOP, svr_name, 0, 0, - MINICONTROL_PRIORITY_LOW); + MINICONTROL_PRIORITY_LOW, NULL); _minictrl_provider_proc_send(MINICONTROL_DBUS_PROC_INCLUDE); } @@ -112,7 +112,7 @@ EXPORT_API minicontrol_error_e minicontrol_viewer_request(const char *appid, min } ret = _minictrl_provider_message_send(MINICTRL_DBUS_SIG_REQUEST, - appid, request, value, MINICONTROL_PRIORITY_MIDDLE); + appid, request, value, MINICONTROL_PRIORITY_MIDDLE, NULL); return ret; } -- 2.7.4