Add appcontrol create with parameters API 63/196063/13
authorhyunho <hhstark.kang@samsung.com>
Fri, 21 Dec 2018 06:03:23 +0000 (15:03 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 9 Jan 2019 10:04:28 +0000 (19:04 +0900)
Added:
 - app_control_create_with_parameters()

Change-Id: I371ceac2efc85bba19e4b8ab03063215efc79910
Signed-off-by: hyunho <hhstark.kang@samsung.com>
include/app_control.h
include/app_control_internal.h
src/app_control.c

index 174e7f7..4999a60 100755 (executable)
@@ -592,7 +592,8 @@ typedef enum {
 #define APP_CONTROL_DATA_INPUT_MAX_TEXT_LENGTH "http://tizen.org/appcontrol/data/input_max_text_length"
 
 
-/* @brief Definition for app_control data: Send value to set cursor position to entry in keyboard input type.
+/**
+ * @brief Definition for app_control data: Send value to set cursor position to entry in keyboard input type.
  * @since_tizen 4.0
  */
 #define APP_CONTROL_DATA_INPUT_CURSOR_POSITION_SET "http://tizen.org/appcontrol/data/input_cursor_position_set"
@@ -683,7 +684,7 @@ typedef bool (*app_control_extra_data_cb)(app_control_h app_control, const char
  *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @param[in] app_control The app_control handle
- * @param[in] package The package name of the application that can handle the launch request of the given app_control
+ * @param[in] appid The name of the application that can handle the launch request of the given app_control
  * @param[in] user_data The user data passed from the foreach function
  * @return @c true to continue with the next iteration of the loop,
  *         otherwise @c false to break out of the loop
@@ -711,8 +712,6 @@ typedef bool (*app_control_app_matched_cb)(app_control_h app_control, const char
 typedef void (*app_control_result_cb)(app_control_h request, app_control_error_e result, void *user_data);
 
 
-typedef int (*app_control_host_res_fn)(void *data);
-
 /**
  * @brief Creates an app_control handle.
  *
@@ -730,6 +729,50 @@ int app_control_create(app_control_h *app_control);
 
 
 /**
+ * @brief Creates an app_control handle and sets its attributes.
+ *
+ * @details Extra data of array type cannot be added with this function. If you need to add arrays to the app_control handle,
+ *          create the handle with app_control_create_with_parameters() and then add arrays with app_control_add_extra_data_array().
+ *          For details on key-value pairs that app_control_create_with_parameters() allows,
+ *          their types and constraints, see app_control_add_extra_data().
+ * @since_tizen 5.5
+ * @remarks The @a app_control must be released using app_control_destroy().
+ * @remarks Setting the type of key-value extra data that the value is an array of strings is not allowed.
+ * @param[out] app_control The app_control handle to be newly created on success
+ * @param[in] operation The operation to be performed
+ * @param[in] uri The URI of the data this app_control is operating on
+ * @param[in] mime The explicit MIME type of the data this app_control is operating on
+ * @param[in] category The explicit category
+ * @param[in] app_id The ID of the application to explicitly launch
+ * @param[in] mode The launch mode of the application
+ * @param[in] extra_data_count The count of a extra data
+ * @param[in] ... The key-value pair list of app control extra data
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #APP_CONTROL_ERROR_NONE Successful
+ * @retval #APP_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #APP_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #APP_CONTROL_ERROR_KEY_REJECTED Key not available
+ * @see app_control_destroy()
+ * @see app_control_add_extra_data()
+ * @code
+
+static int create_app_control()
+{
+       app_control_h control;
+       int ret = app_control_create_with_parameter(&control, NULL, NULL, NULL, NULL,
+               "org.tizen.test", APP_CONTROL_LAUNCH_MODE_SINGLE, 2, "key1", "value1", "key2", "value2");
+       return ret;
+}
+ * @endcode
+ */
+int app_control_create_with_parameters(app_control_h *app_control,
+               const char *operation, const char *uri, const char *mime,
+               const char *category, const char *app_id,
+               app_control_launch_mode_e mode, int extra_data_count, ...);
+
+
+/**
  * @brief Destroys the app_control handle and releases all its resources.
  *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
@@ -841,7 +884,7 @@ int app_control_set_mime(app_control_h app_control, const char *mime);
  * @brief Gets the explicit MIME type of the data.
  *
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
- * @remarks The @a uri must be released using free().
+ * @remarks The @a mime must be released using free().
  * @param[in] app_control The app_control handle
  * @param[out] mime The explicit MIME type of the data this app_control is operating on
  * @return @c 0 on success,
@@ -1099,7 +1142,7 @@ int app_control_foreach_app_matched(app_control_h app_control, app_control_app_m
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @privlevel public
  * @privilege %http://tizen.org/privilege/appmanager.launch
- * @remarks The function returns #APP_CONTROL_ERROR_LAUNCH_REJECTED if the operation value is #APP_CONTROL_OPERATION_LAUNCH_ON_EVENT which is only for handling the event from the platform or other application, refer to the @a Event module.
+ * @remarks The function returns #APP_CONTROL_ERROR_LAUNCH_REJECTED if the operation value is #APP_CONTROL_OPERATION_LAUNCH_ON_EVENT which is only for handling the event from the platform or other application, refer to the @ref Event module.
  * @remarks Since Tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, the launch request of the service application over out of packages is restricted by the platform. Also, implicit launch requests are NOT delivered to service applications since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif. To launch a service application, an explicit launch request with application ID given by the app_control_set_app_id() must be sent.
  * @param[in] app_control The app_control handle
  * @param[in] callback The callback function to be called when the reply is delivered
@@ -1186,7 +1229,7 @@ int app_control_clone(app_control_h *clone, app_control_h app_control);
  * @remarks The @a id must be released using free().
  * @param[in] app_control The app_control handle from app_control_cb()
  * @param[out] id The application ID of the caller
- * @return @a 0 on success,
+ * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #APP_CONTROL_ERROR_NONE Successful
  * @retval #APP_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
@@ -1257,7 +1300,7 @@ int app_control_get_launch_mode(app_control_h app_control,
  * @details The function allows to receive the #APP_CONTROL_RESULT_APP_STARTED event on\n
  *         application get launched by the app_control.
  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
- * @remarks app_control_reply_cb() will be called on the APP_CONTROL_RESULT_APP_STARTED event received.
+ * @remarks app_control_reply_cb() will be called on the #APP_CONTROL_RESULT_APP_STARTED event received.
  * @param[in] app_control The app_control handle
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -1278,7 +1321,7 @@ int app_control_enable_app_started_result_event(app_control_h app_control);
  * @since_tizen 5.0
  * @privlevel public
  * @privilege %http://tizen.org/privilege/appmanager.launch
- * @remarks The function returns #APP_CONTROL_ERROR_LAUNCH_REJECTED if the operation value is #APP_CONTROL_OPERATION_LAUNCH_ON_EVENT which is only for handling the event from the platform or other application, refer to the @a Event Module.
+ * @remarks The function returns #APP_CONTROL_ERROR_LAUNCH_REJECTED if the operation value is #APP_CONTROL_OPERATION_LAUNCH_ON_EVENT which is only for handling the event from the platform or other application, refer to the @ref Event Module.
  * @remarks The launch request of the service application over out of packages is restricted by the platform. Also, implicit launch requests are NOT delivered to service applications since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif. To launch a service application, an explicit launch request with application ID given by the app_control_set_app_id() must be sent.
  * @param[in] app_control The app_control handle
  * @param[in] result_cb The callback function to be called when the result is delivered
index bb6d8be..52262f7 100644 (file)
@@ -158,6 +158,8 @@ int app_control_set_window(app_control_h app_control, unsigned int id);
  */
 int app_control_get_window(app_control_h app_control, unsigned int *id);
 
+typedef int (*app_control_host_res_fn)(void *data);
+
 /**
  * @brief Requests the specified callee window to be transient for the caller window.
  *
index 99f0241..49bfa7c 100644 (file)
@@ -275,6 +275,85 @@ int app_control_create(app_control_h *app_control)
        return app_control_create_request(NULL, app_control);
 }
 
+int app_control_create_with_parameters(app_control_h *app_control,
+               const char *operation, const char *uri, const char *mime,
+               const char *category, const char *app_id,
+               app_control_launch_mode_e mode, int extra_data_count, ...)
+{
+       app_control_h tmp_control;
+       int ret;
+       va_list vl;
+       char *val;
+       char *key;
+
+       ret = app_control_create_request(NULL, &tmp_control);
+       if (ret != APP_CONTROL_ERROR_NONE)
+               return ret;
+
+       ret = app_control_set_operation(tmp_control, operation);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               app_control_destroy(tmp_control);
+               return ret;
+       }
+
+       ret = app_control_set_uri(tmp_control, uri);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               app_control_destroy(tmp_control);
+               return ret;
+       }
+
+       ret = app_control_set_mime(tmp_control, mime);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               app_control_destroy(tmp_control);
+               return ret;
+       }
+
+       ret = app_control_set_category(tmp_control, category);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               app_control_destroy(tmp_control);
+               return ret;
+       }
+
+       ret = app_control_set_app_id(tmp_control, app_id);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               app_control_destroy(tmp_control);
+               return ret;
+       }
+
+       ret = app_control_set_launch_mode(tmp_control, mode);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               app_control_destroy(tmp_control);
+               return ret;
+       }
+
+       va_start(vl, extra_data_count);
+       for (int i = 0; i < extra_data_count; i++) {
+               key = va_arg(vl, char *);
+               ret = app_control_validate_extra_data(key);
+               if (ret != APP_CONTROL_ERROR_NONE) {
+                       app_control_destroy(tmp_control);
+                       return ret;
+               }
+
+               val = va_arg(vl, char *);
+               ret = app_control_validate_extra_data(val);
+               if (ret != APP_CONTROL_ERROR_NONE) {
+                       app_control_destroy(tmp_control);
+                       return ret;
+               }
+
+               ret = app_control_add_extra_data(tmp_control, key, val);
+               if (ret != APP_CONTROL_ERROR_NONE) {
+                       app_control_destroy(tmp_control);
+                       return ret;
+               }
+       }
+       va_end(vl);
+       *app_control = tmp_control;
+
+       return ret;
+}
+
 int app_control_create_event(bundle *data, struct app_control_s **app_control)
 {
        struct app_control_s *app_control_event;
@@ -1083,7 +1162,6 @@ int app_control_reply_to_launch_request(app_control_h reply, app_control_h reque
        return APP_CONTROL_ERROR_NONE;
 }
 
-
 int app_control_add_extra_data(app_control_h app_control, const char *key, const char *value)
 {
        if (app_control_validate(app_control) || app_control_validate_extra_data(key) || app_control_validate_extra_data(value))
@@ -1103,7 +1181,6 @@ int app_control_add_extra_data(app_control_h app_control, const char *key, const
        return APP_CONTROL_ERROR_NONE;
 }
 
-
 int app_control_add_extra_data_array(app_control_h app_control, const char *key, const char* value[], int length)
 {
        if (app_control_validate(app_control) || app_control_validate_extra_data(key))