Fix functions related to attach/detach window 39/238439/2
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 14 Jul 2020 03:38:19 +0000 (12:38 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 14 Jul 2020 03:51:28 +0000 (12:51 +0900)
- Separates errors
- Adds descriptions about errors

Change-Id: I019b236699c579450d8673a8fa0eb347840dbb57
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/app_manager_extension.h
src/app_manager.c

index 4f244ac..5b24761 100644 (file)
@@ -148,7 +148,11 @@ int app_manager_get_focused_app_context(app_context_h *app_context);
  *              otherwise a negative error value
  * @retval  #APP_MANAGER_ERROR_NONE               Successful
  * @retval  #APP_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval  #APP_MANAGER_ERROR_IO_ERROR           Internal I/O error
+ * @retval  #APP_MANAGER_ERROR_IO_ERROR           I/O error
+ * @retval  #APP_MANAGER_ERROR_OUT_OF_MEMORY      Out of memory
+ * @retval  #APP_MANAGER_ERROR_NO_SUCH_APP        No such application
+ * @retval  #APP_MANAGER_ERROR_PERMISSION_DENIED  Permission denied
+ *
  */
 int app_manager_attach_window(const char *parent_app_id, const char *child_app_id);
 
@@ -161,7 +165,10 @@ int app_manager_attach_window(const char *parent_app_id, const char *child_app_i
  *              otherwise a negative error value
  * @retval  #APP_MANAGER_ERROR_NONE               Successful
  * @retval  #APP_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
- * @retval  #APP_MANAGER_ERROR_IO_ERROR           Internal I/O error
+ * @retval  #APP_MANAGER_ERROR_IO_ERROR           I/O error
+ * @retval  #APP_MANAGER_ERROR_OUT_OF_MEMORY      Out of memory
+ * @retval  #APP_MANAGER_ERROR_NO_SUCH_APP        No such application
+ * @retval  #APP_MANAGER_ERROR_PERMISSION_DENIED  Permission denied
  */
 int app_manager_detach_window(const char *app_id);
 
index f6cdb7c..cd0cd25 100644 (file)
@@ -64,6 +64,22 @@ static const char *app_manager_error_to_string(app_manager_error_e error)
        }
 }
 
+static int __aul_error_convert(int error)
+{
+       switch (error) {
+       case AUL_R_EINVAL:
+               return APP_MANAGER_ERROR_INVALID_PARAMETER;
+       case AUL_R_EILLACC:
+               return APP_MANAGER_ERROR_PERMISSION_DENIED;
+       case AUL_R_ENOENT:
+               return APP_MANAGER_ERROR_NO_SUCH_APP;
+       case AUL_R_ENOMEM:
+               return APP_MANAGER_ERROR_OUT_OF_MEMORY;
+       default:
+               return APP_MANAGER_ERROR_IO_ERROR;
+       }
+}
+
 int app_manager_error(app_manager_error_e error, const char *function, const char *description)
 {
        if (description)
@@ -651,8 +667,8 @@ API int app_manager_attach_window(const char *parent_app_id, const char *child_a
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        ret = aul_window_attach(parent_app_id, child_app_id);
-       if (ret != 0)
-               return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL);
+       if (ret != AUL_R_OK)
+               return app_manager_error(__aul_error_convert(ret), __FUNCTION__, NULL);
 
        return APP_MANAGER_ERROR_NONE;
 }
@@ -665,8 +681,8 @@ API int app_manager_detach_window(const char *app_id)
                return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
 
        ret = aul_window_detach(app_id);
-       if (ret != 0)
-               return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL);
+       if (ret != AUL_R_OK)
+               return app_manager_error(__aul_error_convert(ret), __FUNCTION__, NULL);
 
        return APP_MANAGER_ERROR_NONE;
 }