Add new functions for setting/getting component ID 31/202531/4
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 29 Mar 2019 11:23:11 +0000 (20:23 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 8 Apr 2019 07:40:53 +0000 (16:40 +0900)
Adds:
 - app_control_set_component_id()
 - app_control_get_component_id()

Change-Id: Ife95817dcd6fe152a8ab5ddc111398844afcdf54
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/app_control_internal.h
src/app_control.c

index 59eb6b2..9adba53 100644 (file)
@@ -258,6 +258,37 @@ int app_control_get_instance_id(app_control_h app_control, char **instance_id);
 int app_control_set_caller_instance_id(app_control_h app_control, const char *instance_id);
 
 /**
+ * @brief Sets the ID of the component.
+ * @since_tizen 5.5
+ *
+ * @param[in]   app_control     The app_control handle
+ * @param[in]   component_id    The ID of the component
+ * @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
+ */
+int app_control_set_component_id(app_control_h app_control,
+                const char *component_id);
+
+/**
+ * @brief Gets the ID of the component.
+ * @since_tizen 5.5
+ * @remarks The @a component_id must be released using free().
+ *
+ * @param[in]   app_control     The app_control handle
+ * @param[out]  component_id    The ID of the component
+ * @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
+ */
+int app_control_get_component_id(app_control_h app_control,
+                char **component_id);
+
+/**
  * @}
  */
 
index e575de1..62b23e0 100644 (file)
@@ -1799,3 +1799,47 @@ int app_control_set_caller_instance_id(app_control_h app_control,
 
        return APP_CONTROL_ERROR_NONE;
 }
+
+int app_control_set_component_id(app_control_h app_control,
+               const char *component_id)
+{
+       int r;
+
+       if (app_control_validate(app_control)) {
+               return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER,
+                               __FUNCTION__, "Invalid parameter");
+       }
+
+       r = aul_svc_set_comp_id(app_control->data, component_id);
+       if (r != AUL_SVC_RET_OK && component_id != NULL) {
+               return app_control_error(APP_CONTROL_ERROR_OUT_OF_MEMORY,
+                               __FUNCTION__, "Out of memory");
+       }
+
+       return APP_CONTROL_ERROR_NONE;
+}
+
+int app_control_get_component_id(app_control_h app_control,
+               char **component_id)
+{
+       const char *comp_id;
+
+       if (app_control_validate(app_control) || !component_id) {
+               return app_control_error(APP_CONTROL_ERROR_INVALID_PARAMETER,
+                               __FUNCTION__, "Invalid parameter");
+       }
+
+       comp_id = aul_svc_get_comp_id(app_control->data);
+       if (comp_id) {
+               *component_id = strdup(comp_id);
+               if (*component_id == NULL) {
+                       return app_control_error(
+                                       APP_CONTROL_ERROR_OUT_OF_MEMORY,
+                                       __FUNCTION__, "Out of memory");
+               }
+       } else {
+               *component_id = NULL;
+       }
+
+       return APP_CONTROL_ERROR_NONE;
+}