remove ail dependency
authorJiwoong Im <jiwoong.im@samsung.com>
Fri, 3 Jul 2015 07:20:29 +0000 (16:20 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Fri, 3 Jul 2015 08:10:27 +0000 (17:10 +0900)
- replace ail api to pkgmgr-info api.

Change-Id: I014aa13dcc3f962838f68a4396663ea5a2ef80f8
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
CMakeLists.txt
app_common/CMakeLists.txt
app_common/app_package.c
packaging/capi-appfw-application.spec
src/app_resource.c

index 1dd56d9a142916218b55b55794f97bdad0bc0fa1..ac3e14cdfed1747f65784300cf9bd25d5a770e82 100644 (file)
@@ -9,7 +9,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
-SET(requires "dlog bundle appcore-common appcore-efl aul ail appsvc elementary capi-base-common alarm-service sqlite3 libtzplatform-config pkgmgr-info glib-2.0 capi-system-info capi-system-system-settings")
+SET(requires "dlog bundle appcore-common appcore-efl aul appsvc elementary capi-base-common alarm-service sqlite3 libtzplatform-config pkgmgr-info glib-2.0 capi-system-info capi-system-system-settings")
 SET(pc_requires "capi-base-common vconf-internal-keys capi-appfw-alarm capi-appfw-app-control capi-appfw-app-common capi-appfw-preference capi-appfw-event")
 
 INCLUDE(FindPkgConfig)
index 3f65c0dd8f1da2841e9b2ca86c4282ae3c2dead2..e731efa1cadbd3191fe767d687288367bccf7bba 100644 (file)
@@ -9,7 +9,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(INC_DIR ${CMAKE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
-SET(requires "dlog aul ail capi-base-common appcore-common libtzplatform-config")
+SET(requires "dlog aul pkgmgr-info capi-base-common appcore-common libtzplatform-config")
 SET(pc_requires "capi-base-common")
 
 INCLUDE(FindPkgConfig)
index 56893a115c5dc3f972d34bdffc6f9396721fc240..0c7562db188b7d37b1444d98b644e20e8816e033 100644 (file)
  * 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.
  */
 
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
 
-#include <bundle.h>
-#include <appcore-common.h>
 #include <aul.h>
-#include <ail.h>
+#include <pkgmgr-info.h>
 #include <dlog.h>
 
 #include <app_private.h>
@@ -43,26 +37,20 @@ int app_get_package_app_name(const char *appid, char **name)
        char *name_token = NULL;
 
        if (appid == NULL)
-       {
                return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-       }
 
        // com.vendor.name -> name
        name_token = strrchr(appid, '.');
 
        if (name_token == NULL)
-       {
                return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, NULL);
-       }
 
        name_token++;
 
        *name = strdup(name_token);
 
        if (*name == NULL)
-       {
                return app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
-       }
 
        return APP_ERROR_NONE;
 }
@@ -78,111 +66,113 @@ int app_get_id(char **id)
        int ret = -1;
 
        if (id == NULL)
-       {
                return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-       }
 
-       if (id_buf[0] == '\0')
-       {
+       if (id_buf[0] == '\0') {
                ret = aul_app_get_appid_bypid(getpid(), id_buf, sizeof(id_buf));
-               if (ret < 0) {
+               if (ret < 0)
                        return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the application ID");
-               }
        }
 
        if (id_buf[0] == '\0')
-       {
                return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the application ID");
-       }
 
        *id = strdup(id_buf);
 
        if (*id == NULL)
-       {
                return app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
-       }
 
        return APP_ERROR_NONE;
 }
 
-static int app_get_appinfo(const char *package, const char *property, char **value)
+int app_get_name(char **name)
 {
-       ail_appinfo_h appinfo;
-       char *appinfo_value;
-       char *appinfo_value_dup;
+       int retval = 0;
+       char *appid = NULL;
+       char *label = NULL;
+       pkgmgrinfo_appinfo_h appinfo = NULL;
 
-       if (ail_get_appinfo(package, &appinfo) != 0)
-       {
-               return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get app-info");
-       }
-       
-       if (ail_appinfo_get_str(appinfo, property, &appinfo_value) != 0)
-       {
-               ail_destroy_appinfo(appinfo);
-               return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get app-property");
+       if(name == NULL)
+               return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
+       if (app_get_id(&appid) != 0)
+               return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the package");
+
+       retval = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &appinfo);
+       if (retval != 0) {
+               free(appid);
+               return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
        }
 
-       appinfo_value_dup = strdup(appinfo_value);
+       retval = pkgmgrinfo_appinfo_get_label(appinfo, &label);
+       if (retval != 0) {
+               free(appid);
+               pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
+               return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+       }
 
-       ail_destroy_appinfo(appinfo);
+       *name = strdup(label);
+       pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
+       free(appid);
 
-       if (appinfo_value_dup == NULL)
-       {
+       if (*name == NULL)
                return app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
-       }
 
-       *value = appinfo_value_dup;
-       
        return APP_ERROR_NONE;
 }
 
-int app_get_name(char **name)
+int app_get_version(char **version)
 {
-       char *package = NULL;
-       int retval;
+       int retval = 0;
+       char *appid = NULL;
+       char *pkgid = NULL;
+       char *pkg_version = NULL;
+       pkgmgrinfo_pkginfo_h pkginfo = NULL;
+       pkgmgrinfo_appinfo_h appinfo = NULL;
 
-       if(name == NULL)
-       {
+       if(version == NULL)
                return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-       }
 
-       if (app_get_id(&package) != 0)
-       {
+       if (app_get_id(&appid) != 0)
                return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the package");
-       }
 
-       retval = app_get_appinfo(package, AIL_PROP_NAME_STR, name);
-
-       if (package != NULL)
-       {
-               free(package);
+       retval = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &appinfo);
+       if (retval != 0) {
+               free(appid);
+               return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
        }
 
-       return retval;
-}
-
-int app_get_version(char **version)
-{
-       char *package;
-       int retval;
+       retval = pkgmgrinfo_appinfo_get_pkgid(appinfo, &pkgid);
+       if (retval != 0) {
+               free(appid);
+               pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
+               return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+       }
 
-       if(version == NULL)
-       {
+       retval = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &pkginfo);
+       if (retval != 0) {
+               free(appid);
+               pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
                return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
        }
 
-       if (app_get_id(&package) != 0)
-       {
-               return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the package");
+       retval = pkgmgrinfo_pkginfo_get_version(pkginfo, &pkg_version);
+       if (retval != 0) {
+               free(appid);
+               pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
+               pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
+               return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
        }
 
-       retval = app_get_appinfo(package, AIL_PROP_VERSION_STR, version);
+       *version = strdup(pkg_version);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
+       pkgmgrinfo_appinfo_destroy_appinfo(appinfo);
+       free(appid);
 
-       if (package != NULL)
-       {
-               free(package);
-       }
+       if (*version == NULL)
+               return app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
 
-       return retval;  
+       return APP_ERROR_NONE;
 }
 
+
index 2db39e7ac375a81b3092ac7173c4de7ee4cf659b..139dbbc02f5b909d25d2be439e2843d04f9e0c6d 100644 (file)
@@ -12,7 +12,6 @@ BuildRequires:  pkgconfig(bundle)
 BuildRequires:  pkgconfig(appcore-common)
 BuildRequires:  pkgconfig(appcore-efl)
 BuildRequires:  pkgconfig(aul)
-BuildRequires:  pkgconfig(ail)
 BuildRequires:  pkgconfig(appsvc)
 BuildRequires:  pkgconfig(elementary)
 BuildRequires:  pkgconfig(alarm-service)
index cadcee82c0231b1fd09222fe76ee97da6b4cd6d7..d6a180b33d3f5234637403157022f4182aef321a 100644 (file)
  * 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.
  */
 
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <bundle.h>
 #include <appcore-common.h>
 #include <appcore-efl.h>
-#include <aul.h>
-#include <dlog.h>
-#include <ail.h>
-
-#include <app_private.h>
-#include <app_service_private.h>
-
-#include <tzplatform_config.h>
 
 #ifdef LOG_TAG
 #undef LOG_TAG
 
 #define LOG_TAG "CAPI_APPFW_APPLICATION"
 
-#define INSTALLED_PATH tzplatform_getenv(TZ_USER_APP)
-#define RO_INSTALLED_PATH tzplatform_getenv(TZ_SYS_RO_APP)
-
-static const char *RES_DIRECTORY_NAME = "res";
-static const char *DATA_DIRECTORY_NAME = "data";
-
-static char * app_get_root_directory(char *buffer, int size)
-{
-       char *appid = NULL;
-       char root_directory[TIZEN_PATH_MAX] = {0, };
-       char bin_directory[TIZEN_PATH_MAX] = {0, };
-       ail_appinfo_h ail_app_info;
-       char *pkgid;
-
-       if (app_get_id(&appid) != APP_ERROR_NONE)
-       {
-               app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the appid");
-               return NULL;
-       }
-
-       if (ail_get_appinfo(appid, &ail_app_info) != AIL_ERROR_OK)
-       {
-               app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the appinfo");
-               free(appid);
-               return NULL;
-       }
-
-       if (ail_appinfo_get_str(ail_app_info, AIL_PROP_X_SLP_PKGID_STR, &pkgid) != AIL_ERROR_OK)
-       {
-               app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the pkgid");
-               free(appid);
-               ail_destroy_appinfo(ail_app_info);
-               return NULL;
-       }
-
-       if(pkgid)
-       {
-               free(appid);
-               appid = strdup(pkgid);
-       }
-
-       ail_destroy_appinfo(ail_app_info);
-
-       snprintf(root_directory, sizeof(root_directory), "%s/%s", INSTALLED_PATH, appid);
-       snprintf(bin_directory, sizeof(bin_directory), "%s/bin", root_directory);
-
-       if (access(bin_directory, R_OK) != 0) {
-               snprintf(root_directory, sizeof(root_directory), "%s/%s", RO_INSTALLED_PATH, appid);
-       }
-
-       free(appid);
-
-       if (size < strlen(root_directory)+1)
-       {
-               app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "the buffer is not big enough");
-               return NULL;
-       }
-
-       snprintf(buffer, size, "%s", root_directory);
-
-       return buffer;
-}
-
-static char* app_get_resource_directory(char *buffer, int size)
-{
-       char root_directory[TIZEN_PATH_MAX] = {0, };
-       char resource_directory[TIZEN_PATH_MAX] = {0, };
-
-       if (app_get_root_directory(root_directory, sizeof(root_directory)) == NULL)
-       {
-               app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the root directory of the application");
-               return NULL;
-       }
-
-       snprintf(resource_directory, sizeof(resource_directory), "%s/%s", root_directory, RES_DIRECTORY_NAME);
-
-       if (size < strlen(resource_directory) +1)
-       {
-               app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "the buffer is not big enough");
-               return NULL;
-       }
-
-       snprintf(buffer, size, "%s", resource_directory);
-
-       return buffer;
-}
-
-char* app_get_data_directory(char *buffer, int size)
-{
-       static char data_directory[TIZEN_PATH_MAX] = {0, };
-       static int data_directory_length = 0;
-       ail_appinfo_h ail_app_info;
-       char *pkgid;
-
-       if (data_directory[0] == '\0')
-       {
-               char *root_directory = NULL;
-               char *appid = NULL;
-
-               root_directory = calloc(1, TIZEN_PATH_MAX);
-
-               if (root_directory == NULL)
-               {
-                       app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
-                       return NULL;
-               }
-
-               if (app_get_id(&appid) != APP_ERROR_NONE)
-               {
-                       app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the package");
-                       free(root_directory);
-                       return NULL;
-               }
-
-               if (ail_get_appinfo(appid, &ail_app_info) != AIL_ERROR_OK)
-               {
-                       app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the package");
-                       free(root_directory);
-                       free(appid);
-                       return NULL;
-               }
-
-               if (ail_appinfo_get_str(ail_app_info, AIL_PROP_X_SLP_PKGID_STR, &pkgid) != AIL_ERROR_OK)
-               {
-                       app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the package");
-                       free(root_directory);
-                       free(appid);
-                       ail_destroy_appinfo(ail_app_info);
-                       return NULL;
-               }
-
-               if(pkgid)
-               {
-                       free(appid);
-                       appid = strdup(pkgid);
-               }
-
-               ail_destroy_appinfo(ail_app_info);
-
-               snprintf(root_directory, TIZEN_PATH_MAX, "%s/%s", INSTALLED_PATH, appid);
-
-               free(appid);
-
-               snprintf(data_directory, sizeof(data_directory), "%s/%s", root_directory, DATA_DIRECTORY_NAME);
-
-               data_directory_length = strlen(data_directory);
-
-               free(root_directory);
-       }
-
-       if (size < data_directory_length+1)
-       {
-               app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "the buffer is not big enough");
-               return NULL;
-       }
-
-       snprintf(buffer, size, "%s", data_directory);
-
-       return buffer;
-}
-
-char* app_get_resource(const char *resource, char *buffer, int size)
-{
-       static char resource_directory[TIZEN_PATH_MAX] = {0, };
-       static int resource_directory_length = 0;
-
-       int resource_path_length = 0;
-
-       if (resource == NULL)
-       {
-               app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-               return NULL;
-       }
-
-       if (buffer == NULL || size <= 0)
-       {
-               app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
-               return NULL;
-       }
-
-       if (resource_directory[0] == '\0')
-       {
-               if (app_get_resource_directory(resource_directory, sizeof(resource_directory)) == NULL)
-               {
-                       app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the path to the resource directory");
-                       return NULL;
-               }
-
-               resource_directory_length = strlen(resource_directory);
-       }
-
-       resource_path_length = resource_directory_length + strlen("/") + strlen(resource);
-
-       if (size < resource_path_length+1)
-       {
-               app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "the buffer is not big enough");
-               return NULL;
-       }
-
-       snprintf(buffer, size, "%s/%s", resource_directory, resource);
-
-       return buffer;
-}
-
-
 void app_set_reclaiming_system_cache_on_pause(bool enable)
 {
        appcore_set_system_resource_reclaiming(enable);