Add minicontrol feature 38/144438/5 accepted/tizen/4.0/unified/20170904.143846 submit/tizen_4.0/20170904.030057
authorSeungha Son <seungha.son@samsung.com>
Thu, 17 Aug 2017 00:28:46 +0000 (09:28 +0900)
committerSeungha Son <seungha.son@samsung.com>
Thu, 31 Aug 2017 00:14:36 +0000 (09:14 +0900)
Signed-off-by: Seungha Son <seungha.son@samsung.com>
Change-Id: I4df3905b370a8e6b6d8476883306ab1cb8046158

CMakeLists.txt
doc/minicontrol_doc.h
include/minicontrol-private.h [new file with mode: 0644]
include/minicontrol-provider.h
include/minicontrol-viewer.h
packaging/minicontrol.spec
src/minicontrol-provider.c
src/minicontrol-viewer.c

index 46cc6e23d4627a44913bd072ad7fc89e5cbd633f..54279a9cb8ebd8b3b2ac7e970d06f402d7e1a6c7 100755 (executable)
@@ -38,6 +38,7 @@ pkg_check_modules(pkgs REQUIRED
        bundle
        glib-2.0
        gio-2.0
+       capi-system-info
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index 381791903723bf430bab921581c6ec559f0e67b4..15c8ecaa3056b8836d5c41ea81c89b8f2dec348f 100644 (file)
  * @section MINICONTROL_VIEWER_MODULE_OVERVIEW Overview
  * It provides functions for displaying EFL socket window.
  */
+
+/**
+ * @section CAPI_MINICONTROL_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/minicontrol\n
+ * It is recommended to design feature related codes in your application for reliability.\n
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>Feature Element</b>.</a>
+ */
diff --git a/include/minicontrol-private.h b/include/minicontrol-private.h
new file mode 100644 (file)
index 0000000..abf0579
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2017 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 __MINICONTROL_PRIVATE_H__
+#define __MINICONTROL_PRIVATE_H__
+
+#include <system_info.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define MINICONTROL_FEATURE "http://tizen.org/feature/minicontrol"
+#define CHECK_MINICONTROL_FEATURE() \
+       do { \
+               bool is_supported = false; \
+               if (!system_info_get_platform_bool(MINICONTROL_FEATURE, &is_supported)) { \
+                       if (is_supported == false) { \
+                               LOGE("[%s] feature is disabled", MINICONTROL_FEATURE); \
+                               return MINICONTROL_ERROR_NOT_SUPPORTED; \
+                       } \
+               } \
+       } while (0)
+
+#define CHECK_MINICONTROL_FEATURE_RET_NULL() \
+       do { \
+               bool is_supported = false; \
+               if (!system_info_get_platform_bool(MINICONTROL_FEATURE, &is_supported)) { \
+                       if (is_supported == false) { \
+                               LOGE("[%s] feature is disabled", MINICONTROL_FEATURE); \
+                               set_last_result(MINICONTROL_ERROR_NOT_SUPPORTED); \
+                               return NULL; \
+                       } \
+               } \
+       } while (0)
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __MINICONTROL_PRIVATE_H__ */
+
index dba4e3281057c8cf73df528d785c430f92ad9a31..2ee2e371f2a7b62209b9579e44713d23985807ef 100755 (executable)
@@ -53,12 +53,19 @@ typedef void (*minicontrol_event_cb)(minicontrol_viewer_event_e event_type, bund
 /**
  * @brief Creates a window for minicontrol.
  * @since_tizen 2.4
+ * @remarks The specific error code can be obtained using the gat_last_result() method. Error codes are described in Exception section.
  * @param[in] name Name of minicontrol socket window
  * @param[in] target_viewer Target viewer for minicontrol. You can select multiple viewers by using bitwise OR operator
  * @param[in] callback A callback function for events originated by minicontrol viewer
- * @return Evas object of socket window. @c NULL failed to create, get_last_result() will return reason of failure
+ * @return Evas object of minicontrol. NULL on error
+ * @exception #MINICONTROL_ERROR_NONE Success
+ * @exception #MINICONTROL_ERROR_INVALID_PARAMETER Invalid argument
+ * @exception #MINICONTROL_ERROR_ELM_FAILURE Some error occurred when creating a  minicontrol window
+ * @exception #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #MINICONTROL_ERROR_NOT_SUPPORTED Not supported
  * @see #minicontrol_target_viewer_e
  * @see #minicontrol_event_cb
+ * @see get_last_result()
  */
 Evas_Object *minicontrol_create_window(const char *name, minicontrol_target_viewer_e target_viewer, minicontrol_event_cb callback);
 
@@ -72,6 +79,7 @@ Evas_Object *minicontrol_create_window(const char *name, minicontrol_target_view
  * @return #MINICONTROL_ERROR_NONE on success,
  *         otherwise an error code on failure
  * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #MINICONTROL_ERROR_NOT_SUPPORTED Not supported
  * @see #minicontrol_provider_event_e
  * @see #minicontrol_create_window
  */
index 059979423e2822c3b146ea383ce54012917904a6..e8d10209922eb0c0b539c8a34953820f597ea653 100755 (executable)
@@ -41,9 +41,15 @@ extern "C" {
 /**
  * @brief Adds minicontrol named as "minicontrol_name" to a given parent evas object and returns it.
  * @since_tizen 2.4
+ * @remarks The specific error code can be obtained using the gat_last_result() method. Error codes are described in Exception section.
  * @param[in] parent Minicontrol object will be added to this parent evas object
  * @param[in] minicontrol_name Name of minicontrol
- * @return Evas object of minicontrol. @c NULL failed to add, get_last_result() will return reason of failure
+ * @return Evas object of minicontrol. NULL on error
+ * @exception #MINICONTROL_ERROR_NONE Success
+ * @exception #MINICONTROL_ERROR_INVALID_PARAMETER Invalid argument
+ * @exception #MINICONTROL_ERROR_ELM_FAILURE Some error occurred when creating a minicontrol window
+ * @exception #MINICONTROL_ERROR_NOT_SUPPORTED Not supported
+ * @see get_last_result()
  */
 Evas_Object *minicontrol_viewer_add(Evas_Object *parent, const char *minicontrol_name);
 
@@ -56,6 +62,7 @@ Evas_Object *minicontrol_viewer_add(Evas_Object *parent, const char *minicontrol
  * @return #MINICONTROL_ERROR_NONE on success,
  *         otherwise an error code on failure
  * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #MINICONTROL_ERROR_NOT_SUPPORTED Not supported
  * @see #minicontrol_viewer_event_e
  */
 int minicontrol_viewer_send_event(const char *minicontrol_name, minicontrol_viewer_event_e event, bundle *event_arg);
@@ -81,6 +88,7 @@ typedef void (*minicontrol_viewer_event_cb)(minicontrol_event_e event, const cha
  * @retval #MINICONTROL_ERROR_INVALID_PARAMETER Invalid argument
  * @retval #MINICONTROL_ERROR_IPC_FAILURE IPC failure
  * @retval #MINICONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MINICONTROL_ERROR_NOT_SUPPORTED Not supported
  * @see #minicontrol_viewer_unset_event_cb
  * @see #minicontrol_viewer_event_cb
  */
@@ -91,6 +99,7 @@ int minicontrol_viewer_set_event_cb(minicontrol_viewer_event_cb callback, void *
  * @since_tizen 2.4
  * @return #MINICONTROL_ERROR_NONE if success,
  *         other value if failure
+ * @retval #MINICONTROL_ERROR_NOT_SUPPORTED Not supported
  * @see #minicontrol_viewer_set_event_cb
  */
 int minicontrol_viewer_unset_event_cb(void);
index 71c8fd10a1dbe366223a011078ec970c5e1cf037..02f1e94918ed8293efd4d4adef551261baac8bd7 100644 (file)
@@ -12,6 +12,7 @@ BuildRequires: pkgconfig(evas)
 BuildRequires: pkgconfig(ecore-evas)
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(capi-system-info)
 BuildRequires: cmake
 Requires(post): /sbin/ldconfig
 requires(postun): /sbin/ldconfig
index bf3e793641a84b341734ff6bcf78acd7ff0b624f..c0c812078b3e833e9878f7162cf8569c7db4af98 100755 (executable)
@@ -23,6 +23,7 @@
 #include "minicontrol-provider.h"
 #include "minicontrol-provider-internal.h"
 #include "minicontrol-log.h"
+#include "minicontrol-private.h"
 
 #define MINICTRL_PRIORITY_SUFFIX_TOP "__minicontrol_top"
 #define MINICTRL_PRIORITY_SUFFIX_LOW "__minicontrol_low"
@@ -157,6 +158,8 @@ EXPORT_API Evas_Object *minicontrol_create_window(const char *name,
        char *name_inter;
        struct _minicontrol_provider *pd;
 
+       CHECK_MINICONTROL_FEATURE_RET_NULL();
+
        if (!name) {
                ERR("invalid parameter");
                set_last_result(MINICONTROL_ERROR_INVALID_PARAMETER);
@@ -230,6 +233,7 @@ EXPORT_API Evas_Object *minicontrol_create_window(const char *name,
        pd->event_callback = event_callback;
        INFO("new minicontrol created - %s", pd->name);
 
+       set_last_result(MINICONTROL_ERROR_NONE);
        return win;
 }
 
@@ -239,6 +243,8 @@ EXPORT_API int minicontrol_send_event(Evas_Object *minicontrol,
        struct _minicontrol_provider *pd;
        int ret = MINICONTROL_ERROR_NONE;
 
+       CHECK_MINICONTROL_FEATURE();
+
        if (!minicontrol) {
                ERR("minicontrol is NULL, invaild parameter");
                return MINICONTROL_ERROR_INVALID_PARAMETER;
@@ -393,6 +399,8 @@ EXPORT_API Evas_Object *minicontrol_win_add(const char *name)
        char *name_inter = NULL;
        struct _minicontrol_provider *pd;
 
+       CHECK_MINICONTROL_FEATURE_RET_NULL();
+
        INFO("minicontrol_win_add [%s]", name);
 
        if (!name) {
@@ -463,6 +471,8 @@ EXPORT_API int minicontrol_request(Evas_Object *minicontrol,
        struct _minicontrol_provider *pd;
        minicontrol_event_e event;
 
+       CHECK_MINICONTROL_FEATURE();
+
        if (!minicontrol) {
                ERR("minicontrol is NULL, invaild parameter");
                return MINICONTROL_ERROR_INVALID_PARAMETER;
index a3a5ed7de01e2755afad0a9c66bba2fc7c757016..8183372840757ce999f6549085429393a6992472 100755 (executable)
@@ -22,6 +22,7 @@
 #include "minicontrol-viewer.h"
 #include "minicontrol-viewer-internal.h"
 #include "minicontrol-log.h"
+#include "minicontrol-private.h"
 
 #define MINICTRL_PLUG_DATA_KEY "__minictrl_plug_name"
 
@@ -38,6 +39,8 @@ EXPORT_API int minicontrol_viewer_send_event(const char *minicontrol_name,
 {
        int ret = MINICONTROL_ERROR_NONE;
 
+       CHECK_MINICONTROL_FEATURE();
+
        if (minicontrol_name == NULL) {
                ERR("appid is NULL, invaild parameter");
                return MINICONTROL_ERROR_INVALID_PARAMETER;
@@ -87,6 +90,8 @@ EXPORT_API int minicontrol_viewer_set_event_cb(
        minictrl_sig_handle *event_sh;
        struct _minicontrol_viewer *minicontrol_viewer_h;
 
+       CHECK_MINICONTROL_FEATURE();
+
        if (!callback) {
                ERR("MINICONTROL_ERROR_INVALID_PARAMETER");
                return MINICONTROL_ERROR_INVALID_PARAMETER;
@@ -129,6 +134,8 @@ EXPORT_API int minicontrol_viewer_set_event_cb(
 
 EXPORT_API int minicontrol_viewer_unset_event_cb(void)
 {
+       CHECK_MINICONTROL_FEATURE();
+
        if (!g_minicontrol_viewer_h)
                return MINICONTROL_ERROR_NONE;
 
@@ -197,6 +204,8 @@ EXPORT_API Evas_Object *minicontrol_viewer_add(Evas_Object *parent,
        Evas_Object *plug_img = NULL;
        Ecore_Evas *ee = NULL;
 
+       CHECK_MINICONTROL_FEATURE_RET_NULL();
+
        if (parent == NULL || minicontrol_name == NULL) {
                ERR("invalid parameter");
                set_last_result(MINICONTROL_ERROR_INVALID_PARAMETER);
@@ -231,6 +240,7 @@ EXPORT_API Evas_Object *minicontrol_viewer_add(Evas_Object *parent,
        evas_object_event_callback_add(plug, EVAS_CALLBACK_DEL,
                        _minictrl_plug_del, ee);
 
+       set_last_result(MINICONTROL_ERROR_NONE);
        return plug;
 }
 
@@ -238,6 +248,8 @@ EXPORT_API Evas_Object *minicontrol_viewer_add(Evas_Object *parent,
 EXPORT_API Evas_Object *minicontrol_viewer_image_object_get(
                const Evas_Object *obj)
 {
+       CHECK_MINICONTROL_FEATURE_RET_NULL();
+
        return elm_plug_image_object_get(obj);
 }
 /* LCOV_EXCL_STOP */
@@ -250,6 +262,8 @@ EXPORT_API int minicontrol_viewer_request(const char *minicontrol_name,
        bundle *event_arg_bundle;
        char bundle_value_buffer[BUNDLE_BUFFER_LENGTH];
 
+       CHECK_MINICONTROL_FEATURE();
+
        if (minicontrol_name == NULL) {
                ERR("appid is NULL, invaild parameter");
                return MINICONTROL_ERROR_INVALID_PARAMETER;