summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiwoong Im <jiwoong.im@samsung.com>2015-07-03 16:20:29 +0900
committerJiwoong Im <jiwoong.im@samsung.com>2015-07-03 17:10:27 +0900
commiteadc16839358e524a5e74fdab65bbe5cc2de61ae (patch)
tree21653d36ea0f585914b645f8fa86eb07753a2695
parent626e0bddc304dc9ea22d561507f0964a9e93feb3 (diff)
downloadapplication-eadc16839358e524a5e74fdab65bbe5cc2de61ae.tar.gz
application-eadc16839358e524a5e74fdab65bbe5cc2de61ae.tar.bz2
application-eadc16839358e524a5e74fdab65bbe5cc2de61ae.zip
- replace ail api to pkgmgr-info api. Change-Id: I014aa13dcc3f962838f68a4396663ea5a2ef80f8 Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
-rw-r--r--CMakeLists.txt2
-rw-r--r--app_common/CMakeLists.txt2
-rw-r--r--app_common/app_package.c142
-rw-r--r--packaging/capi-appfw-application.spec1
-rw-r--r--src/app_resource.c224
5 files changed, 69 insertions, 302 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1dd56d9..ac3e14c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/app_common/CMakeLists.txt b/app_common/CMakeLists.txt
index 3f65c0d..e731efa 100644
--- a/app_common/CMakeLists.txt
+++ b/app_common/CMakeLists.txt
@@ -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)
diff --git a/app_common/app_package.c b/app_common/app_package.c
index 56893a1..0c7562d 100644
--- a/app_common/app_package.c
+++ b/app_common/app_package.c
@@ -11,22 +11,16 @@
* 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;
}
+
diff --git a/packaging/capi-appfw-application.spec b/packaging/capi-appfw-application.spec
index 2db39e7..139dbbc 100644
--- a/packaging/capi-appfw-application.spec
+++ b/packaging/capi-appfw-application.spec
@@ -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)
diff --git a/src/app_resource.c b/src/app_resource.c
index cadcee8..d6a180b 100644
--- a/src/app_resource.c
+++ b/src/app_resource.c
@@ -11,29 +11,12 @@
* 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
@@ -41,211 +24,6 @@
#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);