Add a new internal API 26/287226/1
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 25 Jan 2023 05:19:22 +0000 (05:19 +0000)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 25 Jan 2023 05:19:22 +0000 (05:19 +0000)
To retrieves all default applications, the app_control_foreach_default_application()
is added.

Adds:
 - app_control_foreach_default_application()

Change-Id: I97e11566d4c0aed994a0c6f4bad7aee0ff86d3ef
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/app_control_internal.h
src/app-control/stub.cc

index 441eddc2e99cafc9233c3df59029ade648333da8..2e69dea8a19ffc4f9a476ecc02a7464aa849b13a 100644 (file)
@@ -380,6 +380,36 @@ int app_control_set_auto_restart(app_control_h app_control);
  */
 int app_control_send_launch_request_with_timeout(app_control_h app_control, unsigned int timeout, app_control_reply_cb callback, void *user_data);
 
+/**
+ * @brief Called when the default application information is delivered.
+ * @remarks The @a appid MUST NOT be released by the application.
+ * @since_tizen 7.5
+ *
+ * @param[in]   appid           The default application ID
+ * @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.
+ * @see app_control_foreach_default_application()
+ */
+typedef bool (*app_control_default_application_cb)(const char *appid, void *user_data);
+
+/**
+ * @brief Retrieves all default applications.
+ * @since_tizen 7.5
+ *
+ * @param[in]   callback        The iteration callback function
+ * @param[in]   user_data       The user data to be passed to the callback function
+ * @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_IO_ERROR I/O error
+ * @see app_control_default_application_cb()
+ * @see app_control_set_defapp()
+ * @see app_control_unset_defapp()
+ */
+int app_control_foreach_default_application(app_control_default_application_cb callback, void *user_data);
+
 /**
  * @}
  */
index 8bd93dc496aea71a17a13197ff1ca89df367cf58..e1ce2701a651bbe4fc28dd61277c437bf3f2d142 100644 (file)
@@ -1261,8 +1261,9 @@ EXPORT int app_control_set_auto_restart(app_control_h app_control) {
   return APP_CONTROL_ERROR_NONE;
 }
 
-int app_control_send_launch_request_with_timeout(app_control_h app_control,
-    unsigned int timeout, app_control_reply_cb callback, void* user_data) {
+EXPORT int app_control_send_launch_request_with_timeout(
+    app_control_h app_control, unsigned int timeout,
+    app_control_reply_cb callback, void* user_data) {
   if (app_control == nullptr) {
     _E("Invalid parameter");
     return APP_CONTROL_ERROR_INVALID_PARAMETER;
@@ -1283,3 +1284,27 @@ int app_control_send_launch_request_with_timeout(app_control_h app_control,
 
   return APP_CONTROL_ERROR_NONE;
 }
+
+EXPORT int app_control_foreach_default_application(
+    app_control_default_application_cb callback, void* user_data) {
+  if (callback == nullptr) {
+    _E("Invalid parameter");
+    return APP_CONTROL_ERROR_INVALID_PARAMETER;
+  }
+
+  std::pair<app_control_default_application_cb, void*> info(
+      callback, user_data);
+  int ret = aul_svc_get_all_defapps([](const char* appid, void* data) {
+        auto* callback_info =
+            static_cast<std::pair<app_control_default_application_cb, void*>*>(
+                data);
+        if (!callback_info->first(appid, callback_info->second))
+          return -1;
+
+        return 0;
+      }, &info);
+  if (ret != AUL_SVC_RES_OK)
+    return APP_CONTROL_ERROR_IO_ERROR;
+
+  return APP_CONTROL_ERROR_NONE;
+}