Add path getter API from tizen_2.3 07/33007/5
authorJiwoong Im <jiwoong.im@samsung.com>
Fri, 2 Jan 2015 06:22:52 +0000 (15:22 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Mon, 5 Jan 2015 08:14:18 +0000 (17:14 +0900)
Change-Id: Ib55e478337ad8e12cfa15f1620547bdcc7f7b173
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
include/app_manager.h
src/app_manager.c

index 1343a04..2b98188 100755 (executable)
@@ -39,14 +39,17 @@ extern "C" {
  */
 typedef enum
 {
-       APP_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE,      /**< Successful */
+       APP_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
        APP_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
        APP_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
        APP_MANAGER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */
-       APP_MANAGER_ERROR_NO_SUCH_APP = TIZEN_ERROR_APPLICATION_CLASS | 0x01, /**< No such application */
+       APP_MANAGER_ERROR_NO_SUCH_APP = TIZEN_ERROR_APPLICATION_MANAGER | 0x01, /**< No such application */
 
-       APP_MANAGER_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_CLASS | 0x03, /**< Database error  */
-       APP_MANAGER_ERROR_INVALID_PACKAGE = TIZEN_ERROR_APPLICATION_CLASS | 0x04, /**< Invalid package name */
+       APP_MANAGER_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x03, /**< Database error  */
+       APP_MANAGER_ERROR_INVALID_PACKAGE = TIZEN_ERROR_APPLICATION_MANAGER | 0x04, /**< Invalid package name */
+       APP_MANAGER_ERROR_APP_NO_RUNNING = TIZEN_ERROR_APPLICATION_MANAGER | 0x05, /**< App is not running */
+       APP_MANAGER_ERROR_REQUEST_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x06, /**< Internal aul request error */
+       APP_MANAGER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED /**< Permission denied */
 } app_manager_error_e;
 
 
@@ -272,6 +275,82 @@ int app_manager_foreach_app_info(app_manager_app_info_cb callback, void *user_da
 int app_manager_get_app_info(const char *app_id, app_info_h *app_info);
 
 
+/**
+ * @brief  Gets the absolute path to the shared data directory of the application specified
+ *         with an application ID.
+ * @details     An application can only read the files of other application's shared data directory.
+ * @since_tizen 2.3
+ * @remarks     The specified @a path should be released.
+ *
+ * @param[in]      app_id  The ID of the application
+ * @param[in,out]  path    The absolute path to the shared data directory of the application
+ *                         specified with the @a app_id
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ * @retval  #APP_MANAGER_ERROR_NONE               Successful
+ * @retval  #APP_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #APP_MANAGER_ERROR_NO_SUCH_APP        No such application
+ * @retval  #APP_MANAGER_ERROR_OUT_OF_MEMORY      Out of memory
+ */
+int app_manager_get_shared_data_path(const char *app_id, char **path);
+
+/**
+ * @brief  Gets the absolute path to the shared resource directory of the application specified
+ *         with an application ID.
+ * @details     An application can only read the files of other application's shared resource directory.
+ * @since_tizen 2.3
+ * @remarks     The specified @a path should be released.
+ *
+ * @param[in]      app_id  The ID of the application
+ * @param[in,out]  path    The absolute path to the shared resource directory of the application
+ *                         specified with the @a app_id
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ * @retval  #APP_MANAGER_ERROR_NONE               Successful
+ * @retval  #APP_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #APP_MANAGER_ERROR_NO_SUCH_APP        No such application
+ * @retval  #APP_MANAGER_ERROR_OUT_OF_MEMORY      Out of memory
+ */
+int app_manager_get_shared_resource_path(const char *app_id, char **path);
+
+/**
+ * @brief  Gets the absolute path to the shared trusted directory of the application specified
+ *         with an application ID.
+ * @details     An application signed with the same certificate can read and write the files of
+ *              other application's shared trusted directory.
+ * @since_tizen 2.3
+ * @remarks     The specified @a path should be released.
+ *
+ * @param[in]      app_id  The ID of the application
+ * @param[in,out]  path    The absolute path to the shared trusted directory of the application
+ *                         specified with the @a app_id
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ * @retval  #APP_MANAGER_ERROR_NONE               Successful
+ * @retval  #APP_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #APP_MANAGER_ERROR_NO_SUCH_APP        No such application
+ * @retval  #APP_MANAGER_ERROR_OUT_OF_MEMORY      Out of memory
+ */
+int app_manager_get_shared_trusted_path(const char *app_id, char **path);
+
+/**
+ * @brief  Gets the absolute path to the shared data directory of the application specified
+ *         with an application ID.
+ * @details     An application can only read the files of other application's shared data directory.
+ * @since_tizen 2.3
+ * @remarks     The specified @a path should be released.
+ *
+ * @param[in]      app_id  The ID of the application
+ * @param[in,out]  path    The absolute path to the shared data directory of the application
+ *                         specified with the @a app_id
+ * @return  @c 0 on success,
+ *          otherwise a negative error value
+ * @retval  #APP_MANAGER_ERROR_NONE               Successful
+ * @retval  #APP_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #APP_MANAGER_ERROR_NO_SUCH_APP        No such application
+ * @retval  #APP_MANAGER_ERROR_OUT_OF_MEMORY      Out of memory
+ */
+int app_manager_get_external_shared_data_path(const char *app_id, char **path);
 
 #define __START_OF_DEPRECATED_API
 typedef bool (*app_manager_ui_app_info_cb) (ui_app_info_h ui_app_info, void *user_data);
index ad34612..8639578 100755 (executable)
@@ -11,7 +11,7 @@
  * 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. 
+ * limitations under the License.
  */
 
 
@@ -58,6 +58,15 @@ static const char* app_manager_error_to_string(app_manager_error_e error)
        case APP_MANAGER_ERROR_INVALID_PACKAGE:
                return "INVALID_PACKAGE";
 
+       case APP_MANAGER_ERROR_APP_NO_RUNNING:
+               return "NO_RUNNING";
+
+       case APP_MANAGER_ERROR_REQUEST_FAILED:
+               return "AUL_REQUEST_FAILED";
+
+       case APP_MANAGER_ERROR_PERMISSION_DENIED:
+               return "PERMISSION_DENIED";
+
        default :
                return "UNKNOWN";
        }
@@ -67,11 +76,11 @@ int app_manager_error(app_manager_error_e error, const char* function, const cha
 {
        if (description)
        {
-               LOGE("[%s] %s(0x%08x) : %s", function, app_manager_error_to_string(error), error, description); 
+               LOGE("[%s] %s(0x%08x) : %s", function, app_manager_error_to_string(error), error, description);
        }
        else
        {
-               LOGE("[%s] %s(0x%08x)", function, app_manager_error_to_string(error), error);   
+               LOGE("[%s] %s(0x%08x)", function, app_manager_error_to_string(error), error);
        }
 
        return error;
@@ -306,3 +315,107 @@ int app_manager_is_running(const char *app_id, bool *running)
 
        return APP_MANAGER_ERROR_NONE;
 }
+
+int app_manager_get_shared_data_path(const char *app_id, char **path)
+{
+       int r;
+       int retval = aul_get_app_shared_data_path_by_appid(app_id, path);
+
+       switch (retval) {
+       case AUL_R_OK:
+               r = APP_MANAGER_ERROR_NONE;
+               break;
+       case AUL_R_ENOAPP:
+               r = app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL);
+               break;
+       case AUL_R_EINVAL:
+               r = app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+               break;
+       case AUL_R_ERROR:
+               r = app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+               break;
+       default:
+               r = app_manager_error(APP_MANAGER_ERROR_REQUEST_FAILED, __FUNCTION__, NULL);
+               break;
+       }
+
+       return r;
+}
+
+int app_manager_get_shared_resource_path(const char *app_id, char **path)
+{
+       int r;
+       int retval = aul_get_app_shared_resource_path_by_appid(app_id, path);
+
+       switch (retval) {
+       case AUL_R_OK:
+               r = APP_MANAGER_ERROR_NONE;
+               break;
+       case AUL_R_ENOAPP:
+               r = app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL);
+               break;
+       case AUL_R_EINVAL:
+               r = app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+               break;
+       case AUL_R_ERROR:
+               r = app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+               break;
+       default:
+               r = app_manager_error(APP_MANAGER_ERROR_REQUEST_FAILED, __FUNCTION__, NULL);
+               break;
+       }
+
+       return r;
+}
+
+int app_manager_get_shared_trusted_path(const char *app_id, char **path)
+{
+       int r;
+       int retval = aul_get_app_shared_trusted_path_by_appid(app_id, path);
+
+       switch (retval) {
+       case AUL_R_OK:
+               r = APP_MANAGER_ERROR_NONE;
+               break;
+       case AUL_R_ENOAPP:
+               r = app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL);
+               break;
+       case AUL_R_EINVAL:
+               r = app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+               break;
+       case AUL_R_ERROR:
+               r = app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+               break;
+       default:
+               r = app_manager_error(APP_MANAGER_ERROR_REQUEST_FAILED, __FUNCTION__, NULL);
+               break;
+       }
+
+       return r;
+}
+
+int app_manager_get_external_shared_data_path(const char *app_id, char **path)
+{
+       int r;
+       int retval = aul_get_app_external_shared_data_path_by_appid(app_id, path);
+
+       switch (retval) {
+       case AUL_R_OK:
+               r = APP_MANAGER_ERROR_NONE;
+               break;
+       case AUL_R_ENOAPP:
+               r = app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL);
+               break;
+       case AUL_R_EINVAL:
+               r = app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+               break;
+       case AUL_R_ERROR:
+               r = app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+               break;
+       default:
+               r = app_manager_error(APP_MANAGER_ERROR_REQUEST_FAILED, __FUNCTION__, NULL);
+               break;
+       }
+
+       return r;
+}