#include <sqlite3.h>
#include <vconf.h>
#include <glib.h>
+#include <ctype.h>
#include <assert.h>
#include <libxml/parser.h>
#include "pkgmgr_parser.h"
#include "pkgmgr-info-internal.h"
+#include "pkgmgr-info-debug.h"
#include "pkgmgr-info.h"
+#include "pkgmgr_parser_db.h"
#include <dirent.h>
#include <sys/stat.h>
#define MANIFEST_DB "/opt/dbspace/.pkgmgr_parser.db"
#define MAX_QUERY_LEN 4096
+#define MAX_CERT_TYPE 9
#define CERT_DB "/opt/dbspace/.pkgmgr_cert.db"
#define DATACONTROL_DB "/opt/usr/dbspace/.app-package.db"
#define PKG_TYPE_STRING_LEN_MAX 128
#define PKG_VERSION_STRING_LEN_MAX 128
#define PKG_VALUE_STRING_LEN_MAX 512
+#define PKG_LOCALE_STRING_LEN_MAX 8
#define PKG_RW_PATH "/opt/usr/apps/"
#define PKG_RO_PATH "/usr/apps/"
#define BLOCK_SIZE 4096 /*in bytes*/
"LEFT OUTER JOIN package_app_app_category " \
"ON package_app_info.app_id=package_app_app_category.app_id where "
-#define retv_if(expr, val) do { \
- if(expr) { \
- _LOGE("(%s) -> %s() return\n", #expr, __FUNCTION__); \
- return (val); \
- } \
-} while (0)
+#define METADATA_FILTER_QUERY_SELECT_CLAUSE "select DISTINCT package_app_info.app_id, package_app_info.app_component " \
+ "from package_app_info LEFT OUTER JOIN package_app_app_metadata " \
+ "ON package_app_info.app_id=package_app_app_metadata.app_id where "
+
+#define METADATA_FILTER_QUERY_UNION_CLAUSE " UNION "METADATA_FILTER_QUERY_SELECT_CLAUSE
#define LANGUAGE_LENGTH 2
typedef struct _pkgmgr_instcertinfo_x {
char *pkgid;
- char *auth_signer_cert;
- char *auth_im_cert;
- char *auth_root_cert;
- char *dist_signer_cert;
- char *dist_im_cert;
- char *dist_root_cert;
- char *dist2_signer_cert;
- char *dist2_im_cert;
- char *dist2_root_cert;
+ char *cert_info[MAX_CERT_TYPE]; /*certificate data*/
+ int is_new[MAX_CERT_TYPE]; /*whether already exist in table or not*/
+ int ref_count[MAX_CERT_TYPE]; /*reference count of certificate data*/
+ int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
} pkgmgr_instcertinfo_x;
-sqlite3 *cert_db = NULL;
+typedef struct _pkgmgr_certindexinfo_x {
+ int cert_id;
+ int cert_ref_count;
+} pkgmgr_certindexinfo_x;
typedef struct _pkgmgr_pkginfo_x {
manifest_x *manifest_info;
- char *tmp;
- char *tmp_dup;
+ char *locale;
struct _pkgmgr_pkginfo_x *prev;
struct _pkgmgr_pkginfo_x *next;
} pkgmgr_pkginfo_x;
typedef struct _pkgmgr_cert_x {
- const char *pkgid;
- const char *certvalue;
+ char *pkgid;
+ int cert_id;
} pkgmgr_cert_x;
typedef struct _pkgmgr_datacontrol_x {
char *iconpath;
} pkgmgr_iconpath_x;
+typedef struct _pkgmgr_image_x {
+ char *imagepath;
+} pkgmgr_image_x;
+
typedef struct _pkgmgr_locale_x {
char *locale;
} pkgmgr_locale_x;
typedef struct _pkgmgr_appinfo_x {
const char *package;
+ char *locale;
pkgmgrinfo_app_component app_component;
union {
uiapplication_x *uiapp_info;
typedef struct _pkgmgr_certinfo_x {
char *pkgid;
- char *auth_signer_cert;
- char *auth_im_cert;
- char *auth_root_cert;
- char *dist_signer_cert;
- char *dist_im_cert;
- char *dist_root_cert;
- char *dist2_signer_cert;
- char *dist2_im_cert;
- char *dist2_root_cert;
+ char *cert_value;
+ char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
+ int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
} pkgmgr_certinfo_x;
/*For filter APIs*/
typedef struct _pkgmgrinfo_node_x {
int prop;
+ char *key;
char *value;
} pkgmgrinfo_node_x;
int operation_count;
int uri_count;
int mime_count;
+ int subapp_count;
char **operation;
char **uri;
char **mime;
+ char **subapp;
} pkgmgrinfo_appcontrol_x;
typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
char *pkgtype = "rpm";
-sqlite3 *manifest_db = NULL;
-sqlite3 *datacontrol_db = NULL;
-int gflag[9];/*one for each cert type*/
-char *gpkgcert[9];/*To store pkg cert values*/
+__thread sqlite3 *manifest_db = NULL;
+__thread sqlite3 *datacontrol_db = NULL;
+__thread sqlite3 *cert_db = NULL;
static int __open_manifest_db();
static int __exec_pkginfo_query(char *query, void *data);
-static int __exec_appinfo_query(char *query, void *data);
static int __exec_certinfo_query(char *query, void *data);
-static int __exec_sqlite_query(char *query, sqlite_query_callback callback, void *data);
+static int __exec_certindexinfo_query(char *query, void *data);
static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname);
static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname);
static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname);
+static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname);
static int __validate_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __delete_certinfo_cb(void *data, int ncols, char **coltxt, char **colname);
+static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname);
static int __count_cb(void *data, int ncols, char **coltxt, char **colname);
static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
static int __svcapp_list_cb(void *data, int ncols, char **coltxt, char **colname);
static int __pkg_list_cb(void *data, int ncols, char **coltxt, char **colname);
static int __app_list_cb(void *data, int ncols, char **coltxt, char **colname);
-static int __pkgmgr_appinfo_new_handle_id();
-static int __pkgmgr_pkginfo_new_handle_id();
static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data);
static void __cleanup_appinfo(pkgmgr_appinfo_x *data);
static char* __convert_system_locale_to_manifest_locale(char *syslocale);
static void __destroy_each_node(gpointer data, gpointer user_data);
static void __get_filter_condition(gpointer data, char **condition);
+static void __get_metadata_filter_condition(gpointer data, char **condition);
static gint __compare_func(gconstpointer data1, gconstpointer data2);
+static int __delete_certinfo(const char *pkgid);
static gint __compare_func(gconstpointer data1, gconstpointer data2)
{
static void __destroy_each_node(gpointer data, gpointer user_data)
{
- if (data == NULL)
- return;
+ ret_if(data == NULL);
pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
if (node->value) {
free(node->value);
node->value = NULL;
}
+ if (node->key) {
+ free(node->key);
+ node->key = NULL;
+ }
free(node);
node = NULL;
}
+static void __get_metadata_filter_condition(gpointer data, char **condition)
+{
+ pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
+ char key[MAX_QUERY_LEN] = {'\0'};
+ char value[MAX_QUERY_LEN] = {'\0'};
+ if (node->key) {
+ snprintf(key, MAX_QUERY_LEN, "(package_app_app_metadata.md_key='%s'", node->key);
+ }
+ if (node->value) {
+ snprintf(value, MAX_QUERY_LEN, " AND package_app_app_metadata.md_value='%s')", node->value);
+ strcat(key, value);
+ } else {
+ strcat(key, ")");
+ }
+ *condition = strdup(key);
+ return;
+}
+
static void __get_filter_condition(gpointer data, char **condition)
{
pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)data;
case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION:
snprintf(buf, MAX_QUERY_LEN, "package_info.install_location='%s'", node->value);
break;
+ case E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE:
+ snprintf(buf, MAX_QUERY_LEN, "package_info.installed_storage='%s'", node->value);
+ break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME:
snprintf(buf, MAX_QUERY_LEN, "package_info.author_name='%s'", node->value);
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY:
snprintf(buf, MAX_QUERY_LEN, "package_info.package_readonly IN %s", node->value);
break;
+ case E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE:
+ snprintf(buf, MAX_QUERY_LEN, "package_info.package_update IN %s", node->value);
+ break;
+ case E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING:
+ snprintf(buf, MAX_QUERY_LEN, "package_info.package_appsetting IN %s", node->value);
+ break;
+ case E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING:
+ snprintf(buf, MAX_QUERY_LEN, "package_info.package_nodisplay IN %s", node->value);
+ break;
+
case E_PMINFO_APPINFO_PROP_APP_ID:
snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_id='%s'", node->value);
break;
case E_PMINFO_APPINFO_PROP_APP_HWACCELERATION:
snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_hwacceleration='%s'", node->value);
break;
+ case E_PMINFO_APPINFO_PROP_APP_SCREENREADER:
+ snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_screenreader='%s'", node->value);
+ break;
+ case E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION:
+ snprintf(buf, MAX_QUERY_LEN, "package_app_info.app_launchcondition IN %s", node->value);
+ break;
default:
_LOGE("Invalid Property Type\n");
*condition = NULL;
return strdup(DEFAULT_LOCALE);
char *locale = NULL;
locale = (char *)calloc(1, 6);
- if (!locale) {
- _LOGE("Malloc Failed\n");
- return NULL;
- }
+ retvm_if(!locale, NULL, "Malloc Failed\n");
+
strncpy(locale, syslocale, 2);
strncat(locale, "-", 1);
locale[3] = syslocale[3] + 32;
static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
{
- if (data == NULL)
- return;
- if (data->tmp_dup){
- free((void *)data->tmp_dup);
- data->tmp_dup = NULL;
+ ret_if(data == NULL);
+ if (data->locale){
+ free((void *)data->locale);
+ data->locale = NULL;
}
pkgmgr_parser_free_manifest_xml(data->manifest_info);
static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
{
- if (data == NULL)
- return;
+ ret_if(data == NULL);
+ if (data->package){
+ free((void *)data->package);
+ data->package = NULL;
+ }
+ if (data->locale){
+ free((void *)data->locale);
+ data->locale = NULL;
+ }
manifest_x *mfx = calloc(1, sizeof(manifest_x));
if (data->app_component == PMINFO_UI_APP)
ret =
db_util_open_with_options(MANIFEST_DB, &manifest_db,
SQLITE_OPEN_READONLY, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
- return -1;
- }
+ retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", MANIFEST_DB);
return 0;
}
_LOGE("Manifest DB does not exists !!\n");
ret =
db_util_open_with_options(DATACONTROL_DB, &datacontrol_db,
SQLITE_OPEN_READONLY, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", DATACONTROL_DB);
- return -1;
- }
+ retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB);
return 0;
}
_LOGE("Datacontrol DB does not exists !!\n");
serviceapplication_x *svcapp = NULL;
for(i = 0; i < ncols; i++)
{
- if (strcmp(colname[i], "app_component") == 0) {
+ if ((strcmp(colname[i], "app_component") == 0) ||
+ (strcmp(colname[i], "package_app_info.app_component") == 0)) {
if (coltxt[i]) {
if (strcmp(coltxt[i], "uiapp") == 0) {
uiapp = calloc(1, sizeof(uiapplication_x));
LISTADD(info->manifest_info->uiapplication, uiapp);
for(j = 0; j < ncols; j++)
{
- if (strcmp(colname[j], "app_id") == 0) {
+ if ((strcmp(colname[j], "app_id") == 0) ||
+ (strcmp(colname[j], "package_app_info.app_id") == 0)) {
if (coltxt[j])
info->manifest_info->uiapplication->appid = strdup(coltxt[j]);
} else if (strcmp(colname[j], "package") == 0) {
LISTADD(info->manifest_info->serviceapplication, svcapp);
for(j = 0; j < ncols; j++)
{
- if (strcmp(colname[j], "app_id") == 0) {
+ if ((strcmp(colname[j], "app_id") == 0) ||
+ (strcmp(colname[j], "package_app_info.app_id") == 0)) {
if (coltxt[j])
info->manifest_info->serviceapplication->appid = strdup(coltxt[j]);
} else if (strcmp(colname[j], "package") == 0) {
info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
else
info->manifest_info->uiapplication->hwacceleration = NULL;
+ } else if (strcmp(colname[i], "app_screenreader") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->screenreader = NULL;
+ } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->indicatordisplay = NULL;
+ } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->portraitimg = NULL;
+ } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->landscapeimg = NULL;
+ } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->guestmode_visibility = NULL;
} else if (strcmp(colname[i], "package") == 0 ){
if (coltxt[i])
info->manifest_info->uiapplication->package = strdup(coltxt[i]);
info->manifest_info->uiapplication->icon->text = strdup(coltxt[i]);
else
info->manifest_info->uiapplication->icon->text = NULL;
+ } else if (strcmp(colname[i], "app_enabled") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->enabled= strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->enabled = NULL;
} else if (strcmp(colname[i], "app_label") == 0 ) {
if (coltxt[i])
info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
else
info->manifest_info->uiapplication->label->text = NULL;
+ } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->recentimage = NULL;
+ } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->mainapp = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->mainapp = NULL;
} else if (strcmp(colname[i], "app_locale") == 0 ) {
if (coltxt[i]) {
info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
info->manifest_info->uiapplication->icon->lang = NULL;
info->manifest_info->uiapplication->label->lang = NULL;
}
+ } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->permission_type = NULL;
+ } else if (strcmp(colname[i], "component_type") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->component_type = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->component_type = NULL;
+ } else if (strcmp(colname[i], "app_preload") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->preload = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->preload = NULL;
+ } else if (strcmp(colname[i], "app_submode") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->submode = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->submode = NULL;
+ } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->submode_mainid = NULL;
} else
continue;
}
serviceapplication_x *svcapp = NULL;
icon_x *icon = NULL;
label_x *label = NULL;
+
svcapp = calloc(1, sizeof(serviceapplication_x));
LISTADD(info->manifest_info->serviceapplication, svcapp);
icon = calloc(1, sizeof(icon_x));
info->manifest_info->serviceapplication->icon->lang = NULL;
info->manifest_info->serviceapplication->label->lang = NULL;
}
+ } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
+ else
+ info->manifest_info->serviceapplication->permission_type = NULL;
} else
continue;
}
info->manifest_info->uiapplication->hwacceleration = strdup(coltxt[i]);
else
info->manifest_info->uiapplication->hwacceleration = NULL;
+ } else if (strcmp(colname[i], "app_screenreader") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->screenreader = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->screenreader = NULL;
+ } else if (strcmp(colname[i], "app_indicatordisplay") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->indicatordisplay = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->indicatordisplay = NULL;
+ } else if (strcmp(colname[i], "app_portraitimg") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->portraitimg = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->portraitimg = NULL;
+ } else if (strcmp(colname[i], "app_landscapeimg") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->landscapeimg = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->landscapeimg = NULL;
+ } else if (strcmp(colname[i], "app_guestmodevisibility") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->uiapplication->guestmode_visibility = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->guestmode_visibility = NULL;
} else if (strcmp(colname[i], "package") == 0 ){
if (coltxt[i])
info->manifest_info->uiapplication->package = strdup(coltxt[i]);
info->manifest_info->uiapplication->label->text = strdup(coltxt[i]);
else
info->manifest_info->uiapplication->label->text = NULL;
+ } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->recentimage = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->recentimage = NULL;
+ } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->mainapp= strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->mainapp = NULL;
} else if (strcmp(colname[i], "app_locale") == 0 ) {
if (coltxt[i]) {
info->manifest_info->uiapplication->icon->lang = strdup(coltxt[i]);
info->manifest_info->uiapplication->icon->lang = NULL;
info->manifest_info->uiapplication->label->lang = NULL;
}
+ } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->permission_type = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->permission_type = NULL;
} else
continue;
}
info->manifest_info->serviceapplication->icon->lang = NULL;
info->manifest_info->serviceapplication->label->lang = NULL;
}
+ } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->serviceapplication->permission_type = strdup(coltxt[i]);
+ else
+ info->manifest_info->serviceapplication->permission_type = NULL;
} else
continue;
}
return 0;
}
+static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
+{
+ int *p = (int*)data;
+ if (coltxt[0])
+ *p = atoi(coltxt[0]);
+ return 0;
+}
+
static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
{
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)data;
icon_x *icon = NULL;
label_x *label = NULL;
description_x *description = NULL;
+ privilege_x *privilege = NULL;
author = calloc(1, sizeof(author_x));
LISTADD(info->manifest_info->author, author);
LISTADD(info->manifest_info->label, label);
description = calloc(1, sizeof(description_x));
LISTADD(info->manifest_info->description, description);
+ privilege = calloc(1, sizeof(privilege_x));
+ LISTADD(info->manifest_info->privileges->privilege, privilege);
for(i = 0; i < ncols; i++)
{
if (strcmp(colname[i], "package_version") == 0) {
info->manifest_info->readonly = strdup(coltxt[i]);
else
info->manifest_info->readonly = NULL;
+ } else if (strcmp(colname[i], "package_update") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->update= strdup(coltxt[i]);
+ else
+ info->manifest_info->update = NULL;
+ } else if (strcmp(colname[i], "package_appsetting") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->appsetting = strdup(coltxt[i]);
+ else
+ info->manifest_info->appsetting = NULL;
} else if (strcmp(colname[i], "installed_time") == 0 ){
if (coltxt[i])
info->manifest_info->installed_time = strdup(coltxt[i]);
else
info->manifest_info->installed_time = NULL;
+ } else if (strcmp(colname[i], "installed_storage") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->installed_storage = strdup(coltxt[i]);
+ else
+ info->manifest_info->installed_storage = NULL;
} else if (strcmp(colname[i], "mainapp_id") == 0 ){
if (coltxt[i])
info->manifest_info->mainapp_id = strdup(coltxt[i]);
else
info->manifest_info->mainapp_id = NULL;
-
+ } else if (strcmp(colname[i], "root_path") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->root_path = strdup(coltxt[i]);
+ else
+ info->manifest_info->root_path = NULL;
+ } else if (strcmp(colname[i], "csc_path") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->csc_path = strdup(coltxt[i]);
+ else
+ info->manifest_info->csc_path = NULL;
+ } else if (strcmp(colname[i], "privilege") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
+ else
+ info->manifest_info->privileges->privilege->text = NULL;
} else if (strcmp(colname[i], "package_locale") == 0 ){
if (coltxt[i]) {
info->manifest_info->author->lang = strdup(coltxt[i]);
info->manifest_info->label->lang = NULL;
info->manifest_info->description->lang = NULL;
}
+ } else if (strcmp(colname[i], "package_url") == 0 ){
+ if (coltxt[i])
+ info->manifest_info->package_url = strdup(coltxt[i]);
+ else
+ info->manifest_info->package_url = NULL;
} else
continue;
}
return -1;
}
-static int __delete_certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
+static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
{
- const char *pkgid = (const char *)data;
+ pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
int i = 0;
- char *error_message = NULL;
- int ret =0;
- char query[MAX_QUERY_LEN] = {'\0'};
- pkgmgr_instcertinfo_x *certinfo = NULL;
- certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
- if (certinfo == NULL) {
- _LOGE("Out of Memory!!!\n");
- return PMINFO_R_ERROR;
- }
- for (i = 0; i < ncols; i++) {
- if (strcmp(colname[i], "package") == 0) {
+ for(i = 0; i < ncols; i++) {
+ if (strcmp(colname[i], "cert_id") == 0) {
if (coltxt[i])
- certinfo->pkgid = coltxt[i];
- } else if (strcmp(colname[i], "author_signer_cert") == 0) {
- if (coltxt[i]) {
- if (strcmp(coltxt[i], pkgid) == 0) {
- if (gflag[PMINFO_AUTHOR_SIGNER_CERT] && gpkgcert[PMINFO_AUTHOR_SIGNER_CERT]) {
- certinfo->auth_signer_cert = strdup(gpkgcert[PMINFO_AUTHOR_SIGNER_CERT]);
- continue;
- }
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info " \
- "where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, (void *)certinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- gpkgcert[PMINFO_AUTHOR_SIGNER_CERT] = strdup(certinfo->pkgid);
- gflag[PMINFO_AUTHOR_SIGNER_CERT] = 1;
- } else {
- certinfo->auth_signer_cert = strdup(coltxt[i]);
- }
- }
- continue;
- } else if (strcmp(colname[i], "author_im_cert") == 0) {
- if (coltxt[i]) {
- if (strcmp(coltxt[i], pkgid) == 0) {
- if (gflag[PMINFO_AUTHOR_INTERMEDIATE_CERT] && gpkgcert[PMINFO_AUTHOR_INTERMEDIATE_CERT]) {
- certinfo->auth_im_cert = strdup(gpkgcert[PMINFO_AUTHOR_INTERMEDIATE_CERT]);
- continue;
- }
- snprintf(query, MAX_QUERY_LEN, "select author_im_cert from package_cert_info " \
- "where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, (void *)certinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- gpkgcert[PMINFO_AUTHOR_INTERMEDIATE_CERT] = strdup(certinfo->pkgid);
- gflag[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 1;
- } else {
- certinfo->auth_im_cert = strdup(coltxt[i]);
- }
- }
- continue;
- } else if (strcmp(colname[i], "author_root_cert") == 0) {
- if (coltxt[i]) {
- if (strcmp(coltxt[i], pkgid) == 0) {
- if (gflag[PMINFO_AUTHOR_ROOT_CERT] && gpkgcert[PMINFO_AUTHOR_ROOT_CERT]) {
- certinfo->auth_root_cert = strdup(gpkgcert[PMINFO_AUTHOR_ROOT_CERT]);
- continue;
- }
- snprintf(query, MAX_QUERY_LEN, "select author_root_cert from package_cert_info " \
- "where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, (void *)certinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- gpkgcert[PMINFO_AUTHOR_ROOT_CERT] = strdup(certinfo->pkgid);
- gflag[PMINFO_AUTHOR_ROOT_CERT] = 1;
- } else {
- certinfo->auth_root_cert = strdup(coltxt[i]);
- }
- }
- continue;
- } else if (strcmp(colname[i], "dist_signer_cert") == 0 ) {
- if (coltxt[i]) {
- if (strcmp(coltxt[i], pkgid) == 0) {
- if (gflag[PMINFO_DISTRIBUTOR_SIGNER_CERT] && gpkgcert[PMINFO_DISTRIBUTOR_SIGNER_CERT]) {
- certinfo->dist_signer_cert = strdup(gpkgcert[PMINFO_DISTRIBUTOR_SIGNER_CERT]);
- continue;
- }
- snprintf(query, MAX_QUERY_LEN, "select dist_signer_cert from package_cert_info " \
- "where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, (void *)certinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- gpkgcert[PMINFO_DISTRIBUTOR_SIGNER_CERT] = strdup(certinfo->pkgid);
- gflag[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 1;
- } else {
- certinfo->dist_signer_cert = strdup(coltxt[i]);
- }
- }
- continue;
- } else if (strcmp(colname[i], "dist_im_cert") == 0 ) {
- if (coltxt[i]) {
- if (strcmp(coltxt[i], pkgid) == 0) {
- if (gflag[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] && gpkgcert[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT]) {
- certinfo->dist_im_cert = strdup(gpkgcert[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT]);
- continue;
- }
- snprintf(query, MAX_QUERY_LEN, "select dist_im_cert from package_cert_info " \
- "where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, (void *)certinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- gpkgcert[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = strdup(certinfo->pkgid);
- gflag[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 1;
- } else {
- certinfo->dist_im_cert = strdup(coltxt[i]);
- }
- }
- continue;
- } else if (strcmp(colname[i], "dist_root_cert") == 0 ) {
- if (coltxt[i]) {
- if (strcmp(coltxt[i], pkgid) == 0) {
- if (gflag[PMINFO_DISTRIBUTOR_ROOT_CERT] && gpkgcert[PMINFO_DISTRIBUTOR_ROOT_CERT]) {
- certinfo->dist_root_cert = strdup(gpkgcert[PMINFO_DISTRIBUTOR_ROOT_CERT]);
- continue;
- }
- snprintf(query, MAX_QUERY_LEN, "select dist_root_cert from package_cert_info " \
- "where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, (void *)certinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- gpkgcert[PMINFO_DISTRIBUTOR_ROOT_CERT] = strdup(certinfo->pkgid);
- gflag[PMINFO_DISTRIBUTOR_ROOT_CERT] = 1;
- } else {
- certinfo->dist_root_cert = strdup(coltxt[i]);
- }
- }
- continue;
- } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ) {
- if (coltxt[i]) {
- if (strcmp(coltxt[i], pkgid) == 0) {
- if (gflag[PMINFO_DISTRIBUTOR2_SIGNER_CERT] && gpkgcert[PMINFO_DISTRIBUTOR2_SIGNER_CERT]) {
- certinfo->dist2_signer_cert = strdup(gpkgcert[PMINFO_DISTRIBUTOR2_SIGNER_CERT]);
- continue;
- }
- snprintf(query, MAX_QUERY_LEN, "select dist2_signer_cert from package_cert_info " \
- "where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, (void *)certinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- gpkgcert[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = strdup(certinfo->pkgid);
- gflag[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 1;
- } else {
- certinfo->dist2_signer_cert = strdup(coltxt[i]);
- }
- }
- continue;
- } else if (strcmp(colname[i], "dist2_im_cert") == 0 ) {
- if (coltxt[i]) {
- if (strcmp(coltxt[i], pkgid) == 0) {
- if (gflag[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] && gpkgcert[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT]) {
- certinfo->dist2_im_cert = strdup(gpkgcert[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT]);
- continue;
- }
- snprintf(query, MAX_QUERY_LEN, "select dist2_im_cert from package_cert_info " \
- "where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, (void *)certinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- gpkgcert[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = strdup(certinfo->pkgid);
- gflag[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 1;
- } else {
- certinfo->dist2_im_cert = strdup(coltxt[i]);
- }
- }
- continue;
- } else if (strcmp(colname[i], "dist2_root_cert") == 0 ) {
- if (coltxt[i]) {
- if (strcmp(coltxt[i], pkgid) == 0) {
- if (gflag[PMINFO_DISTRIBUTOR2_ROOT_CERT] && gpkgcert[PMINFO_DISTRIBUTOR2_ROOT_CERT]) {
- certinfo->dist2_root_cert = strdup(gpkgcert[PMINFO_DISTRIBUTOR2_ROOT_CERT]);
- continue;
- }
- snprintf(query, MAX_QUERY_LEN, "select dist2_root_cert from package_cert_info " \
- "where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, (void *)certinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- gpkgcert[PMINFO_DISTRIBUTOR2_ROOT_CERT] = strdup(certinfo->pkgid);
- gflag[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 1;
- } else {
- certinfo->dist2_root_cert = strdup(coltxt[i]);
- }
- }
+ info->cert_id = atoi(coltxt[i]);
+ else
+ info->cert_id = 0;
+ } else if (strcmp(colname[i], "cert_ref_count") == 0) {
+ if (coltxt[i])
+ info->cert_ref_count = atoi(coltxt[i]);
+ else
+ info->cert_ref_count = 0;
+ } else
continue;
- }
- }
- /*Update cert info db*/
- pkgmgrinfo_save_certinfo(certinfo->pkgid, (void *)certinfo);
- ret = PMINFO_R_OK;
-err:
- if (certinfo->auth_signer_cert) {
- free(certinfo->auth_signer_cert);
- certinfo->auth_signer_cert = NULL;
- }
- if (certinfo->auth_im_cert) {
- free(certinfo->auth_im_cert);
- certinfo->auth_im_cert = NULL;
- }
- if (certinfo->auth_root_cert) {
- free(certinfo->auth_root_cert);
- certinfo->auth_root_cert = NULL;
- }
- if (certinfo->dist_signer_cert) {
- free(certinfo->dist_signer_cert);
- certinfo->dist_signer_cert = NULL;
- }
- if (certinfo->dist_im_cert) {
- free(certinfo->dist_im_cert);
- certinfo->dist_im_cert = NULL;
- }
- if (certinfo->dist_root_cert) {
- free(certinfo->dist_root_cert);
- certinfo->dist_root_cert = NULL;
- }
- if (certinfo->dist2_signer_cert) {
- free(certinfo->dist2_signer_cert);
- certinfo->dist2_signer_cert = NULL;
}
- if (certinfo->dist2_im_cert) {
- free(certinfo->dist2_im_cert);
- certinfo->dist2_im_cert = NULL;
- }
- if (certinfo->dist2_root_cert) {
- free(certinfo->dist2_root_cert);
- certinfo->dist2_root_cert = NULL;
- }
- free(certinfo);
- certinfo = NULL;
- return ret;
+ return 0;
}
-
static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
{
pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
info->pkgid = NULL;
} else if (strcmp(colname[i], "author_signer_cert") == 0) {
if (coltxt[i])
- info->auth_signer_cert = strdup(coltxt[i]);
+ (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
else
- info->auth_signer_cert = NULL;
+ (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
} else if (strcmp(colname[i], "author_im_cert") == 0) {
if (coltxt[i])
- info->auth_im_cert = strdup(coltxt[i]);
+ (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
else
- info->auth_im_cert = NULL;
+ (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
} else if (strcmp(colname[i], "author_root_cert") == 0) {
if (coltxt[i])
- info->auth_root_cert = strdup(coltxt[i]);
+ (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
else
- info->auth_root_cert = NULL;
+ (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
} else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
if (coltxt[i])
- info->dist_signer_cert = strdup(coltxt[i]);
+ (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
else
- info->dist_signer_cert = NULL;
+ (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
} else if (strcmp(colname[i], "dist_im_cert") == 0 ){
if (coltxt[i])
- info->dist_im_cert = strdup(coltxt[i]);
+ (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
else
- info->dist_im_cert = NULL;
+ (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
} else if (strcmp(colname[i], "dist_root_cert") == 0 ){
if (coltxt[i])
- info->dist_root_cert = strdup(coltxt[i]);
+ (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
else
- info->dist_root_cert = NULL;
+ (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
} else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
if (coltxt[i])
- info->dist2_signer_cert = strdup(coltxt[i]);
+ (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
else
- info->dist2_signer_cert = NULL;
+ (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
} else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
if (coltxt[i])
- info->dist2_im_cert = strdup(coltxt[i]);
+ (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
else
- info->dist2_im_cert = NULL;
+ (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
} else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
if (coltxt[i])
- info->dist2_root_cert = strdup(coltxt[i]);
+ (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
+ else
+ (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
+ } else if (strcmp(colname[i], "cert_info") == 0 ){
+ if (coltxt[i])
+ info->cert_value = strdup(coltxt[i]);
else
- info->dist2_root_cert = NULL;
+ info->cert_value = NULL;
} else
continue;
}
return 0;
}
-static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
+static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
{
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
int i = 0;
- icon_x *icon = NULL;
- label_x *label = NULL;
- category_x *category = NULL;
+ uiapplication_x *uiapp = NULL;
+ uiapp = calloc(1, sizeof(uiapplication_x));
+ if (uiapp == NULL) {
+ _LOGE("Out of Memory!!!\n");
+ return -1;
+ }
- switch (info->app_component) {
- case PMINFO_UI_APP:
- icon = calloc(1, sizeof(icon_x));
- LISTADD(info->uiapp_info->icon, icon);
- label = calloc(1, sizeof(label_x));
- LISTADD(info->uiapp_info->label, label);
- category = calloc(1, sizeof(category_x));
- LISTADD(info->uiapp_info->category, category);
- for(i = 0; i < ncols; i++)
- {
- if (strcmp(colname[i], "app_id") == 0) {
- if (coltxt[i])
- info->uiapp_info->appid = strdup(coltxt[i]);
- else
- info->uiapp_info->appid = NULL;
- } else if (strcmp(colname[i], "app_exec") == 0) {
- if (coltxt[i])
- info->uiapp_info->exec = strdup(coltxt[i]);
- else
- info->uiapp_info->exec = NULL;
- } else if (strcmp(colname[i], "app_nodisplay") == 0) {
- if (coltxt[i])
- info->uiapp_info->nodisplay = strdup(coltxt[i]);
- else
- info->uiapp_info->nodisplay = NULL;
- } else if (strcmp(colname[i], "app_type") == 0 ) {
- if (coltxt[i])
- info->uiapp_info->type = strdup(coltxt[i]);
- else
- info->uiapp_info->type = NULL;
- } else if (strcmp(colname[i], "app_icon") == 0) {
- if (coltxt[i])
- info->uiapp_info->icon->text = strdup(coltxt[i]);
- else
- info->uiapp_info->icon->text = NULL;
- } else if (strcmp(colname[i], "app_label") == 0 ) {
- if (coltxt[i])
- info->uiapp_info->label->text = strdup(coltxt[i]);
+ LISTADD(info->uiapp_info, uiapp);
+
+ for(i = 0; i < ncols; i++)
+ {
+ if (strcmp(colname[i], "app_id") == 0) {
+ /*appid being foreign key, is column in every table
+ Hence appid gets strduped every time leading to memory leak.
+ If appid is already set, just continue.*/
+ if (info->uiapp_info->appid)
+ continue;
+ if (coltxt[i])
+ info->uiapp_info->appid = strdup(coltxt[i]);
+ else
+ info->uiapp_info->appid = NULL;
+ } else if (strcmp(colname[i], "app_exec") == 0) {
+ if (coltxt[i])
+ info->uiapp_info->exec = strdup(coltxt[i]);
+ else
+ info->uiapp_info->exec = NULL;
+ } else if (strcmp(colname[i], "app_nodisplay") == 0) {
+ if (coltxt[i])
+ info->uiapp_info->nodisplay = strdup(coltxt[i]);
+ else
+ info->uiapp_info->nodisplay = NULL;
+ } else if (strcmp(colname[i], "app_type") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->type = strdup(coltxt[i]);
+ else
+ info->uiapp_info->type = NULL;
+ } else if (strcmp(colname[i], "app_multiple") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->multiple = strdup(coltxt[i]);
+ else
+ info->uiapp_info->multiple = NULL;
+ } else if (strcmp(colname[i], "app_taskmanage") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->taskmanage = strdup(coltxt[i]);
+ else
+ info->uiapp_info->taskmanage = NULL;
+ } else if (strcmp(colname[i], "app_hwacceleration") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->hwacceleration = strdup(coltxt[i]);
+ else
+ info->uiapp_info->hwacceleration = NULL;
+ } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->screenreader = strdup(coltxt[i]);
+ else
+ info->uiapp_info->screenreader = NULL;
+ } else if (strcmp(colname[i], "app_enabled") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->enabled= strdup(coltxt[i]);
+ else
+ info->uiapp_info->enabled = NULL;
+ } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
+ if (coltxt[i])
+ info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
+ else
+ info->uiapp_info->indicatordisplay = NULL;
+ } else if (strcmp(colname[i], "app_portraitimg") == 0){
+ if (coltxt[i])
+ info->uiapp_info->portraitimg = strdup(coltxt[i]);
+ else
+ info->uiapp_info->portraitimg = NULL;
+ } else if (strcmp(colname[i], "app_landscapeimg") == 0){
+ if (coltxt[i])
+ info->uiapp_info->landscapeimg = strdup(coltxt[i]);
+ else
+ info->uiapp_info->landscapeimg = NULL;
+ } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
+ if (coltxt[i])
+ info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
+ else
+ info->uiapp_info->guestmode_visibility = NULL;
+ } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->recentimage = strdup(coltxt[i]);
+ else
+ info->uiapp_info->recentimage = NULL;
+ } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->mainapp = strdup(coltxt[i]);
+ else
+ info->uiapp_info->mainapp = NULL;
+ } else if (strcmp(colname[i], "package") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->package = strdup(coltxt[i]);
+ else
+ info->uiapp_info->package = NULL;
+ } else if (strcmp(colname[i], "app_component") == 0) {
+ if (coltxt[i])
+ info->uiapp_info->app_component = strdup(coltxt[i]);
+ else
+ info->uiapp_info->app_component = NULL;
+ } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->permission_type = strdup(coltxt[i]);
+ else
+ info->uiapp_info->permission_type = NULL;
+ } else if (strcmp(colname[i], "component_type") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->component_type = strdup(coltxt[i]);
+ else
+ info->uiapp_info->component_type = NULL;
+ } else if (strcmp(colname[i], "app_preload") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->preload = strdup(coltxt[i]);
+ else
+ info->uiapp_info->preload = NULL;
+ } else if (strcmp(colname[i], "app_submode") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->submode = strdup(coltxt[i]);
+ else
+ info->uiapp_info->submode = NULL;
+ } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->submode_mainid = strdup(coltxt[i]);
+ else
+ info->uiapp_info->submode_mainid = NULL;
+ } else
+ continue;
+ }
+
+ return 0;
+}
+
+static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
+ int i = 0;
+ icon_x *icon = NULL;
+ label_x *label = NULL;
+ category_x *category = NULL;
+ metadata_x *metadata = NULL;
+ permission_x *permission = NULL;
+ image_x *image = NULL;
+
+ switch (info->app_component) {
+ case PMINFO_UI_APP:
+ icon = calloc(1, sizeof(icon_x));
+ LISTADD(info->uiapp_info->icon, icon);
+ label = calloc(1, sizeof(label_x));
+ LISTADD(info->uiapp_info->label, label);
+ category = calloc(1, sizeof(category_x));
+ LISTADD(info->uiapp_info->category, category);
+ metadata = calloc(1, sizeof(metadata_x));
+ LISTADD(info->uiapp_info->metadata, metadata);
+ permission = calloc(1, sizeof(permission_x));
+ LISTADD(info->uiapp_info->permission, permission);
+ image = calloc(1, sizeof(image_x));
+ LISTADD(info->uiapp_info->image, image);
+
+ for(i = 0; i < ncols; i++)
+ {
+ if (strcmp(colname[i], "app_id") == 0) {
+ /*appid being foreign key, is column in every table
+ Hence appid gets strduped every time leading to memory leak.
+ If appid is already set, just continue.*/
+ if (info->uiapp_info->appid)
+ continue;
+ if (coltxt[i])
+ info->uiapp_info->appid = strdup(coltxt[i]);
+ else
+ info->uiapp_info->appid = NULL;
+ } else if (strcmp(colname[i], "app_exec") == 0) {
+ if (coltxt[i])
+ info->uiapp_info->exec = strdup(coltxt[i]);
+ else
+ info->uiapp_info->exec = NULL;
+ } else if (strcmp(colname[i], "app_nodisplay") == 0) {
+ if (coltxt[i])
+ info->uiapp_info->nodisplay = strdup(coltxt[i]);
+ else
+ info->uiapp_info->nodisplay = NULL;
+ } else if (strcmp(colname[i], "app_type") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->type = strdup(coltxt[i]);
+ else
+ info->uiapp_info->type = NULL;
+ } else if (strcmp(colname[i], "app_icon_section") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->icon->section= strdup(coltxt[i]);
+ else
+ info->uiapp_info->icon->section = NULL;
+ } else if (strcmp(colname[i], "app_icon") == 0) {
+ if (coltxt[i])
+ info->uiapp_info->icon->text = strdup(coltxt[i]);
+ else
+ info->uiapp_info->icon->text = NULL;
+ } else if (strcmp(colname[i], "app_label") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->label->text = strdup(coltxt[i]);
else
info->uiapp_info->label->text = NULL;
} else if (strcmp(colname[i], "app_multiple") == 0 ) {
info->uiapp_info->hwacceleration = strdup(coltxt[i]);
else
info->uiapp_info->hwacceleration = NULL;
+ } else if (strcmp(colname[i], "app_screenreader") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->screenreader = strdup(coltxt[i]);
+ else
+ info->uiapp_info->screenreader = NULL;
+ } else if (strcmp(colname[i], "app_enabled") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->enabled= strdup(coltxt[i]);
+ else
+ info->uiapp_info->enabled = NULL;
+ } else if (strcmp(colname[i], "app_indicatordisplay") == 0){
+ if (coltxt[i])
+ info->uiapp_info->indicatordisplay = strdup(coltxt[i]);
+ else
+ info->uiapp_info->indicatordisplay = NULL;
+ } else if (strcmp(colname[i], "app_portraitimg") == 0){
+ if (coltxt[i])
+ info->uiapp_info->portraitimg = strdup(coltxt[i]);
+ else
+ info->uiapp_info->portraitimg = NULL;
+ } else if (strcmp(colname[i], "app_landscapeimg") == 0){
+ if (coltxt[i])
+ info->uiapp_info->landscapeimg = strdup(coltxt[i]);
+ else
+ info->uiapp_info->landscapeimg = NULL;
+ } else if (strcmp(colname[i], "app_guestmodevisibility") == 0){
+ if (coltxt[i])
+ info->uiapp_info->guestmode_visibility = strdup(coltxt[i]);
+ else
+ info->uiapp_info->guestmode_visibility = NULL;
} else if (strcmp(colname[i], "category") == 0 ) {
if (coltxt[i])
info->uiapp_info->category->name = strdup(coltxt[i]);
else
info->uiapp_info->category->name = NULL;
+ } else if (strcmp(colname[i], "md_key") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->metadata->key = strdup(coltxt[i]);
+ else
+ info->uiapp_info->metadata->key = NULL;
+ } else if (strcmp(colname[i], "md_value") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->metadata->value = strdup(coltxt[i]);
+ else
+ info->uiapp_info->metadata->value = NULL;
+ } else if (strcmp(colname[i], "pm_type") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->permission->type= strdup(coltxt[i]);
+ else
+ info->uiapp_info->permission->type = NULL;
+ } else if (strcmp(colname[i], "pm_value") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->permission->value = strdup(coltxt[i]);
+ else
+ info->uiapp_info->permission->value = NULL;
+ } else if (strcmp(colname[i], "app_recentimage") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->recentimage = strdup(coltxt[i]);
+ else
+ info->uiapp_info->recentimage = NULL;
+ } else if (strcmp(colname[i], "app_mainapp") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->mainapp = strdup(coltxt[i]);
+ else
+ info->uiapp_info->mainapp = NULL;
} else if (strcmp(colname[i], "app_locale") == 0 ) {
if (coltxt[i]) {
info->uiapp_info->icon->lang = strdup(coltxt[i]);
info->uiapp_info->icon->lang = NULL;
info->uiapp_info->label->lang = NULL;
}
+ } else if (strcmp(colname[i], "app_image") == 0) {
+ if (coltxt[i])
+ info->uiapp_info->image->text= strdup(coltxt[i]);
+ else
+ info->uiapp_info->image->text = NULL;
+ } else if (strcmp(colname[i], "app_image_section") == 0) {
+ if (coltxt[i])
+ info->uiapp_info->image->section= strdup(coltxt[i]);
+ else
+ info->uiapp_info->image->section = NULL;
+ } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->permission_type = strdup(coltxt[i]);
+ else
+ info->uiapp_info->permission_type = NULL;
+ } else if (strcmp(colname[i], "component_type") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->component_type = strdup(coltxt[i]);
+ else
+ info->uiapp_info->component_type = NULL;
+ } else if (strcmp(colname[i], "app_preload") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->preload = strdup(coltxt[i]);
+ else
+ info->uiapp_info->preload = NULL;
+ } else if (strcmp(colname[i], "app_submode") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->submode = strdup(coltxt[i]);
+ else
+ info->uiapp_info->submode = NULL;
+ } else if (strcmp(colname[i], "app_submode_mainid") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->submode_mainid = strdup(coltxt[i]);
+ else
+ info->uiapp_info->submode_mainid = NULL;
} else
continue;
}
LISTADD(info->svcapp_info->label, label);
category = calloc(1, sizeof(category_x));
LISTADD(info->svcapp_info->category, category);
+ metadata = calloc(1, sizeof(metadata_x));
+ LISTADD(info->svcapp_info->metadata, metadata);
+ permission = calloc(1, sizeof(permission_x));
+ LISTADD(info->svcapp_info->permission, permission);
for(i = 0; i < ncols; i++)
{
if (strcmp(colname[i], "app_id") == 0) {
+ /*appid being foreign key, is column in every table
+ Hence appid gets strduped every time leading to memory leak.
+ If appid is already set, just continue.*/
+ if (info->svcapp_info->appid)
+ continue;
if (coltxt[i])
info->svcapp_info->appid = strdup(coltxt[i]);
else
info->svcapp_info->autorestart = strdup(coltxt[i]);
else
info->svcapp_info->autorestart = NULL;
+ } else if (strcmp(colname[i], "app_enabled") == 0 ) {
+ if (coltxt[i])
+ info->svcapp_info->enabled= strdup(coltxt[i]);
+ else
+ info->svcapp_info->enabled = NULL;
} else if (strcmp(colname[i], "category") == 0 ) {
if (coltxt[i])
info->svcapp_info->category->name = strdup(coltxt[i]);
else
info->svcapp_info->category->name = NULL;
+ } else if (strcmp(colname[i], "md_key") == 0 ) {
+ if (coltxt[i])
+ info->svcapp_info->metadata->key = strdup(coltxt[i]);
+ else
+ info->svcapp_info->metadata->key = NULL;
+ } else if (strcmp(colname[i], "md_value") == 0 ) {
+ if (coltxt[i])
+ info->svcapp_info->metadata->value = strdup(coltxt[i]);
+ else
+ info->svcapp_info->metadata->value = NULL;
+ } else if (strcmp(colname[i], "pm_type") == 0 ) {
+ if (coltxt[i])
+ info->svcapp_info->permission->type= strdup(coltxt[i]);
+ else
+ info->svcapp_info->permission->type = NULL;
+ } else if (strcmp(colname[i], "pm_value") == 0 ) {
+ if (coltxt[i])
+ info->svcapp_info->permission->value = strdup(coltxt[i]);
+ else
+ info->svcapp_info->permission->value = NULL;
} else if (strcmp(colname[i], "app_locale") == 0 ) {
if (coltxt[i]) {
info->svcapp_info->icon->lang = strdup(coltxt[i]);
info->svcapp_info->icon->lang = NULL;
info->svcapp_info->label->lang = NULL;
}
+ } else if (strcmp(colname[i], "app_permissiontype") == 0 ) {
+ if (coltxt[i])
+ info->svcapp_info->permission_type = strdup(coltxt[i]);
+ else
+ info->svcapp_info->permission_type = NULL;
} else
continue;
}
return 0;
}
-static int __icon_name_cb(void *data, int ncols, char **coltxt, char **colname)
-{
- pkgmgr_iconpath_x *icon_name = (pkgmgr_iconpath_x *)data;
- int i = 0;
- for(i = 0; i < ncols; i++)
- {
- if (strcmp(colname[i], "app_icon") == 0) {
- if (coltxt[i])
- icon_name->iconpath = strdup(coltxt[i]);
- else
- icon_name->iconpath = NULL;
- } else
- continue;
- }
- return 0;
-}
-
static int __cert_cb(void *data, int ncols, char **coltxt, char **colname)
{
pkgmgr_cert_x *info = (pkgmgr_cert_x *)data;
{
if (strcmp(colname[i], "author_signer_cert") == 0) {
if (coltxt[i])
- info->certvalue= strdup(coltxt[i]);
+ info->cert_id = atoi(coltxt[i]);
else
- info->certvalue = NULL;
+ info->cert_id = 0;
} else if (strcmp(colname[i], "package") == 0) {
if (coltxt[i])
info->pkgid= strdup(coltxt[i]);
return 0;
}
-static int __exec_appcomponent_query(char *query, void *data)
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __appcomponent_cb, data, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-
-static int __exec_appinfo_query(char *query, void *data)
+static int __exec_certindexinfo_query(char *query, void *data)
{
char *error_message = NULL;
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __appinfo_cb, data, &error_message)) {
+ sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
return 0;
}
-static int __exec_sqlite_query(char *query, sqlite_query_callback callback, void *data)
+static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
{
char *error_message = NULL;
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, callback, data, &error_message)) {
+ sqlite3_exec(db, query, callback, data, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
return ret;
}
-static char *__get_package_from_icon(char *icon)
-{
- char *package;
- char *extension;
-
- retv_if(!icon, NULL);
-
- package = strdup(icon);
- retv_if(!package, NULL);
- extension = rindex(package, '.');
- if (extension) {
- *extension = '\0';
- } else {
- _LOGE("cannot extract from icon [%s] to package.", icon);
- }
-
- return package;
-}
-
-static char *__get_icon_with_path(char *icon)
-{
- retv_if(!icon, NULL);
-
- if (index(icon, '/') == NULL) {
- char *package;
- char *theme = NULL;
- char *icon_with_path = NULL;
- int len;
-
- package = __get_package_from_icon(icon);
- retv_if(!package, NULL);
-
- theme = vconf_get_str("db/setting/theme");
- if (!theme) {
- theme = strdup("default");
- if(!theme) {
- free(package);
- return NULL;
- }
- }
-
- len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
- icon_with_path = malloc(len);
- if(icon_with_path == NULL) {
- _LOGE("(icon_with_path == NULL) return\n");
- free(package);
- free(theme);
- return NULL;
- }
-
- memset(icon_with_path, 0, len);
-
- sqlite3_snprintf( len, icon_with_path,"/opt/share/icons/%q/small/%q", theme, icon);
- do {
- if (access(icon_with_path, R_OK) == 0) break;
- sqlite3_snprintf( len, icon_with_path,"/usr/share/icons/%q/small/%q", theme, icon);
- if (access(icon_with_path, R_OK) == 0) break;
- _LOGE("cannot find icon %s", icon_with_path);
- sqlite3_snprintf( len, icon_with_path, "/opt/share/icons/default/small/%q", icon);
- if (access(icon_with_path, R_OK) == 0) break;
- sqlite3_snprintf( len, icon_with_path, "/usr/share/icons/default/small/%q", icon);
- if (access(icon_with_path, R_OK) == 0) break;
-
- #if 1 /* this will be remove when finish the work for moving icon path */
- _LOGE("icon file must be moved to %s", icon_with_path);
- sqlite3_snprintf( len, icon_with_path, "/opt/apps/%q/res/icons/%q/small/%q", package, theme, icon);
- if (access(icon_with_path, R_OK) == 0) break;
- sqlite3_snprintf( len, icon_with_path, "/usr/apps/%q/res/icons/%q/small/%q", package, theme, icon);
- if (access(icon_with_path, R_OK) == 0) break;
- _LOGE("cannot find icon %s", icon_with_path);
- sqlite3_snprintf( len, icon_with_path, "/opt/apps/%q/res/icons/default/small/%q", package, icon);
- if (access(icon_with_path, R_OK) == 0) break;
- sqlite3_snprintf( len, icon_with_path, "/usr/apps/%q/res/icons/default/small/%q", package, icon);
- if (access(icon_with_path, R_OK) == 0) break;
- #endif
- } while (0);
-
- free(theme);
- free(package);
-
- _LOGD("Icon path : %s ---> %s", icon, icon_with_path);
-
- return icon_with_path;
- } else {
- char* confirmed_icon = NULL;
-
- confirmed_icon = strdup(icon);
- retv_if(!confirmed_icon, NULL);
- return confirmed_icon;
- }
-}
-
static int __check_validation_of_qurey_cb(void *data, int ncols, char **coltxt, char **colname)
{
int *p = (int*)data;
return 0;
}
-static int __check_app_locale_from_app_localized_info_by_exact(const char *appid, const char *locale)
+static int __check_app_locale_from_app_localized_info_by_exact(sqlite3 *db, const char *appid, const char *locale)
{
int result_query = -1;
+ int ret = 0;
char query[MAX_QUERY_LEN];
snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale='%s')", appid, locale);
- __exec_sqlite_query(query, __check_validation_of_qurey_cb, (void *)&result_query);
-
+ ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
+ retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
return result_query;
}
-static int __check_app_locale_from_app_localized_info_by_fallback(const char *appid, const char *locale)
+static int __check_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
{
int result_query = -1;
+ int ret = 0;
char wildcard[2] = {'%','\0'};
char query[MAX_QUERY_LEN];
char lang[3] = {'\0'};
strncpy(lang, locale, LANGUAGE_LENGTH);
snprintf(query, MAX_QUERY_LEN, "select exists(select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s')", appid, lang, wildcard);
- __exec_sqlite_query(query, __check_validation_of_qurey_cb, (void *)&result_query);
-
+ ret = __exec_db_query(db, query, __check_validation_of_qurey_cb, (void *)&result_query);
+ retvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
return result_query;
}
-static char* __get_app_locale_from_app_localized_info_by_fallback(const char *appid, const char *locale)
+static char* __get_app_locale_from_app_localized_info_by_fallback(sqlite3 *db, const char *appid, const char *locale)
{
+ int ret = 0;
char wildcard[2] = {'%','\0'};
char lang[3] = {'\0'};
char query[MAX_QUERY_LEN];
_LOGE("Out of Memory!!!\n");
return NULL;
}
- memset(info, NULL, sizeof(*info));
+ memset(info, '\0', sizeof(*info));
strncpy(lang, locale, 2);
snprintf(query, MAX_QUERY_LEN, "select app_locale from package_app_localized_info where app_id='%s' and app_locale like '%s%s'", appid, lang, wildcard);
- __exec_sqlite_query(query, __fallback_locale_cb, (void *)info);
+ ret = __exec_db_query(db, query, __fallback_locale_cb, (void *)info);
+ tryvm_if(ret == -1, PMINFO_R_ERROR, "Exec DB query failed");
locale_new = info->locale;
free(info);
-
return locale_new;
+catch:
+ if (info) {
+ free(info);
+ info = NULL;
+ }
+ return NULL;
}
static char* __convert_syslocale_to_manifest_locale(char *syslocale)
return locale;
}
-static char* __get_app_locale_by_fallback(const char *appid, const char *syslocale)
+static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const char *syslocale)
{
assert(appid);
assert(syslocale);
char *locale_new = NULL;
int check_result = 0;
- locale = __convert_syslocale_to_manifest_locale(syslocale);
+ locale = __convert_syslocale_to_manifest_locale((char *)syslocale);
/*check exact matching */
- check_result = __check_app_locale_from_app_localized_info_by_exact(appid, locale);
+ check_result = __check_app_locale_from_app_localized_info_by_exact(db, appid, locale);
/* Exact found */
if (check_result == 1) {
}
/* fallback matching */
- check_result = __check_app_locale_from_app_localized_info_by_fallback(appid, locale);
+ check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
if(check_result == 1) {
- locale_new = __get_app_locale_from_app_localized_info_by_fallback(appid, locale);
- _LOGD("%s found (%s) language-locale in DB by fallback!\n", appid, locale_new);
+ locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
free(locale);
if (locale_new == NULL)
locale_new = strdup(DEFAULT_LOCALE);
/* default locale */
free(locale);
- _LOGD("%s DEFAULT_LOCALE)\n", appid);
return strdup(DEFAULT_LOCALE);
}
struct dirent *ep = NULL;
struct stat fileinfo;
char abs_filename[FILENAME_MAX] = { 0, };
- if (dirname == NULL) {
- _LOGE("dirname is NULL");
- return PMINFO_R_ERROR;
- }
+ retvm_if(dirname == NULL, PMINFO_R_ERROR, "dirname is NULL");
+
dp = opendir(dirname);
if (dp != NULL) {
while ((ep = readdir(dp)) != NULL) {
}
-API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
+static int __delete_certinfo(const char *pkgid)
{
- if (pkg_list_cb == NULL) {
- _LOGE("callback function is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ int ret = -1;
+ int i = 0;
+ int j = 0;
+ int c = 0;
+ int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
char *error_message = NULL;
- int ret = PMINFO_R_OK;
char query[MAX_QUERY_LEN] = {'\0'};
- char *syslocale = NULL;
- char *locale = NULL;
- pkgmgr_pkginfo_x *pkginfo = NULL;
- label_x *tmp1 = NULL;
- icon_x *tmp2 = NULL;
- description_x *tmp3 = NULL;
- author_x *tmp4 = NULL;
-
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
+ pkgmgr_certinfo_x *certinfo = NULL;
+ pkgmgr_certindexinfo_x *indexinfo = NULL;
+ certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
+ retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
+ indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
+ if (indexinfo == NULL) {
+ _LOGE("Out of Memory!!!");
ret = PMINFO_R_ERROR;
goto err;
}
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- ret = PMINFO_R_EINVAL;
- goto err;
- }
-
- ret = __open_manifest_db();
+ /*populate certinfo from DB*/
+ snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
+ ret = __exec_certinfo_query(query, (void *)certinfo);
if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
+ _LOGE("Package Cert Info DB Information retrieval failed\n");
ret = PMINFO_R_ERROR;
goto err;
}
- pkgmgr_pkginfo_x *tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
- pkgmgr_pkginfo_x *node = NULL;
- pkgmgr_pkginfo_x *temp_node = NULL;
-
- snprintf(query, MAX_QUERY_LEN, "select * from package_info");
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
+ /*Update cert index table*/
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ if ((certinfo->cert_id)[i]) {
+ for (j = 0; j < MAX_CERT_TYPE; j++) {
+ if ((certinfo->cert_id)[i] == unique_id[j]) {
+ /*Ref count has already been updated. Just continue*/
+ break;
+ }
+ }
+ if (j == MAX_CERT_TYPE)
+ unique_id[c++] = (certinfo->cert_id)[i];
+ else
+ continue;
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
+ ret = __exec_certindexinfo_query(query, (void *)indexinfo);
+ if (ret == -1) {
+ _LOGE("Cert Info DB Information retrieval failed\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ memset(query, '\0', MAX_QUERY_LEN);
+ if (indexinfo->cert_ref_count > 1) {
+ /*decrease ref count*/
+ snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
+ indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
+ } else {
+ /*delete this certificate as ref count is 1 and it will become 0*/
+ snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
+ }
+ if (SQLITE_OK !=
+ sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
+ _LOGE("Don't execute query = %s error message = %s\n", query,
+ error_message);
+ sqlite3_free(error_message);
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ }
+ }
+ /*Now delete the entry from db*/
+ snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
+ if (SQLITE_OK !=
+ sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
+ _LOGE("Don't execute query = %s error message = %s\n", query,
+ error_message);
+ sqlite3_free(error_message);
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ ret = PMINFO_R_OK;
+err:
+ if (indexinfo) {
+ free(indexinfo);
+ indexinfo = NULL;
+ }
+ if (certinfo->pkgid) {
+ free(certinfo->pkgid);
+ certinfo->pkgid = NULL;
+ }
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ if ((certinfo->cert_info)[i]) {
+ free((certinfo->cert_info)[i]);
+ (certinfo->cert_info)[i] = NULL;
+ }
+ }
+ free(certinfo);
+ certinfo = NULL;
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
+{
+ retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
+ char *error_message = NULL;
+ int ret = PMINFO_R_OK;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ char *syslocale = NULL;
+ char *locale = NULL;
+ pkgmgr_pkginfo_x *pkginfo = NULL;
+ label_x *tmp1 = NULL;
+ icon_x *tmp2 = NULL;
+ description_x *tmp3 = NULL;
+ author_x *tmp4 = NULL;
+ privilege_x *tmp5 = NULL;
+
+ syslocale = vconf_get_str(VCONFKEY_LANGSET);
+ if (syslocale == NULL) {
+ _LOGE("current locale is NULL\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ locale = __convert_system_locale_to_manifest_locale(syslocale);
+ if (locale == NULL) {
+ _LOGE("manifest locale is NULL\n");
+ ret = PMINFO_R_EINVAL;
+ goto err;
+ }
+
+ ret = __open_manifest_db();
+ if (ret == -1) {
+ _LOGE("Fail to open manifest DB\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
+ pkgmgr_pkginfo_x *node = NULL;
+ pkgmgr_pkginfo_x *temp_node = NULL;
+
+ snprintf(query, MAX_QUERY_LEN, "select * from package_info");
+ if (SQLITE_OK !=
+ sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
+ _LOGE("Don't execute query = %s error message = %s\n", query,
+ error_message);
sqlite3_free(error_message);
sqlite3_close(manifest_db);
ret = PMINFO_R_ERROR;
for(node = node->next; node ; node = node->next) {
pkginfo = node;
-
+ pkginfo->locale = strdup(locale);
+ pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
+ if (pkginfo->manifest_info->privileges == NULL) {
+ _LOGE("Failed to allocate memory for privileges info\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
/*populate manifest_info from DB*/
snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
ret = __exec_pkginfo_query(query, (void *)pkginfo);
goto err;
}
memset(query, '\0', MAX_QUERY_LEN);
+ /*populate privilege_info from DB*/
+ snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkginfo->manifest_info->package);
+ ret = __exec_pkginfo_query(query, (void *)pkginfo);
+ if (ret == -1) {
+ _LOGE("Package Privilege Info DB Information retrieval failed\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
" package='%s' and package_locale='%s'", pkginfo->manifest_info->package, locale);
ret = __exec_pkginfo_query(query, (void *)pkginfo);
LISTHEAD(pkginfo->manifest_info->author, tmp4);
pkginfo->manifest_info->author = tmp4;
}
+ if (pkginfo->manifest_info->privileges->privilege) {
+ LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
+ pkginfo->manifest_info->privileges->privilege = tmp5;
+ }
}
LISTHEAD(tmphead, node);
API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
{
- if (pkgid == NULL) {
- _LOGE("package name is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (handle == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *pkginfo = NULL;
- char *error_message = NULL;
int ret = PMINFO_R_OK;
char query[MAX_QUERY_LEN] = {'\0'};
char *syslocale = NULL;
icon_x *tmp2 = NULL;
description_x *tmp3 = NULL;
author_x *tmp4 = NULL;
+ privilege_x *tmp5 = NULL;
+ sqlite3 *pkginfo_db = NULL;
/*validate pkgid*/
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = db_util_open_with_options(MANIFEST_DB, &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
+ retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+
+ /*check pkgid exist on db*/
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- return PMINFO_R_ERROR;
- }
- if (exist == 0) {
- _LOGE("Package not found in DB\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
+ tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
+ /*get system locale*/
syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
+
+ /*get locale on db*/
locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- ret = PMINFO_R_EINVAL;
- goto err;
- }
+ tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
+
pkginfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
- if (pkginfo == NULL) {
- _LOGE("Failed to allocate memory for pkginfo\n");
- return PMINFO_R_ERROR;
- }
+ tryvm_if(pkginfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for pkginfo");
+
+ pkginfo->locale = strdup(locale);
pkginfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
- if (pkginfo->manifest_info == NULL) {
- _LOGE("Failed to allocate memory for manifest info\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(pkginfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for manifest info");
+
pkginfo->manifest_info->package = strdup(pkgid);
+ pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
+ tryvm_if(pkginfo->manifest_info->privileges == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for privileges info");
+
/*populate manifest_info from DB*/
snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
- ret = __exec_pkginfo_query(query, (void *)pkginfo);
- if (ret == -1) {
- _LOGE("Package Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
+
+ memset(query, '\0', MAX_QUERY_LEN);
+ /*populate privilege_info from DB*/
+ snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
+ ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
+
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
" package='%s' and package_locale='%s'", pkgid, locale);
- ret = __exec_pkginfo_query(query, (void *)pkginfo);
- if (ret == -1) {
- _LOGE("Package Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
+
/*Also store the values corresponding to default locales*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
" package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
- ret = __exec_pkginfo_query(query, (void *)pkginfo);
- if (ret == -1) {
- _LOGE("Package Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
+
if (pkginfo->manifest_info->label) {
LISTHEAD(pkginfo->manifest_info->label, tmp1);
pkginfo->manifest_info->label = tmp1;
LISTHEAD(pkginfo->manifest_info->author, tmp4);
pkginfo->manifest_info->author = tmp4;
}
- *handle = (void *)pkginfo;
- sqlite3_close(manifest_db);
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
+ if (pkginfo->manifest_info->privileges->privilege) {
+ LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
+ pkginfo->manifest_info->privileges->privilege = tmp5;
}
- if (locale) {
- free(locale);
- locale = NULL;
+
+catch:
+ if (ret == PMINFO_R_OK)
+ *handle = (void*)pkginfo;
+ else {
+ *handle = NULL;
+ __cleanup_pkginfo(pkginfo);
}
- return PMINFO_R_OK;
+ sqlite3_close(pkginfo_db);
-err:
- *handle = NULL;
- __cleanup_pkginfo(pkginfo);
- sqlite3_close(manifest_db);
if (syslocale) {
free(syslocale);
syslocale = NULL;
API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (pkg_name == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
if (info->manifest_info->package)
- *pkg_name = info->manifest_info->package;
+ *pkg_name = (char *)info->manifest_info->package;
else
return PMINFO_R_ERROR;
API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (pkgid == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
if (info->manifest_info->package)
- *pkgid = info->manifest_info->package;
+ *pkgid = (char *)info->manifest_info->package;
else
return PMINFO_R_ERROR;
API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (type == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
if (info->manifest_info->type)
- *type = info->manifest_info->type;
+ *type = (char *)info->manifest_info->type;
else
*type = pkgtype;
return PMINFO_R_OK;
API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (version == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
*version = (char *)info->manifest_info->version;
return PMINFO_R_OK;
API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (location == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *val = NULL;
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
val = (char *)info->manifest_info->installlocation;
API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (size == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *val = NULL;
char *location = NULL;
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
location = (char *)info->manifest_info->installlocation;
- if (strcmp(location, "prefer-external") == 0)
- {
- val = (char *)info->manifest_info->package_size;
- if (val) {
- *size = atoi(val);
- } else {
- *size = 0;
- _LOGE("package size is not specified\n");
- return PMINFO_R_ERROR;
- }
+ val = (char *)info->manifest_info->package_size;
+ if (val) {
+ *size = atoi(val);
} else {
*size = 0;
+ _LOGE("package size is not specified\n");
+ return PMINFO_R_ERROR;
}
return PMINFO_R_OK;
}
API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (size == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *pkgid = NULL;
char device_path[PKG_STRING_LEN_MAX] = { '\0', };
API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (size == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *pkgid = NULL;
char device_path[PKG_STRING_LEN_MAX] = { '\0', };
API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
{
-#if 0
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (icon == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- char *syslocale = NULL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ int ret = PMINFO_R_OK;
char *locale = NULL;
- char *save = NULL;
icon_x *ptr = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- save = locale;
*icon = NULL;
+
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ locale = info->locale;
+ retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
+
for(ptr = info->manifest_info->icon; ptr != NULL; ptr = ptr->next)
{
if (ptr->lang) {
}
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
- }
-#else
- pkgmgr_pkginfo_x *info_tmp = (pkgmgr_pkginfo_x *)handle;
- pkgmgrinfo_appinfo_h apphandle;
-
- pkgmgrinfo_appinfo_get_appinfo(info_tmp->manifest_info->mainapp_id, &apphandle);
- pkgmgrinfo_appinfo_get_icon(apphandle, &info_tmp->tmp);
- if (info_tmp->tmp_dup){
- free((void *)info_tmp->tmp_dup);
- info_tmp->tmp_dup = NULL;
- }
- info_tmp->tmp_dup= strdup(info_tmp->tmp);
- *icon = info_tmp->tmp_dup;
- pkgmgrinfo_appinfo_destroy_appinfo(apphandle);
-#endif
- return PMINFO_R_OK;
+ return ret;
}
API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
{
-#if 0
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (label == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- char *syslocale = NULL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ int ret = PMINFO_R_OK;
char *locale = NULL;
- char *save = NULL;
label_x *ptr = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- save = locale;
*label = NULL;
+
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ locale = info->locale;
+ retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
+
for(ptr = info->manifest_info->label; ptr != NULL; ptr = ptr->next)
{
if (ptr->lang) {
}
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
- }
-#else
- pkgmgr_pkginfo_x *info_tmp = (pkgmgr_pkginfo_x *)handle;
- pkgmgrinfo_appinfo_h apphandle;
-
- pkgmgrinfo_appinfo_get_appinfo(info_tmp->manifest_info->mainapp_id, &apphandle);
- pkgmgrinfo_appinfo_get_label(apphandle, &info_tmp->tmp);
- if (info_tmp->tmp_dup){
- free((void *)info_tmp->tmp_dup);
- info_tmp->tmp_dup = NULL;
- }
- info_tmp->tmp_dup = strdup(info_tmp->tmp);
- *label = info_tmp->tmp_dup;
- pkgmgrinfo_appinfo_destroy_appinfo(apphandle);
-#endif
- return PMINFO_R_OK;
+ return ret;
}
API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (description == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- char *syslocale = NULL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *locale = NULL;
- char *save = NULL;
description_x *ptr = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- save = locale;
*description = NULL;
+
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ locale = info->locale;
+ retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
+
for(ptr = info->manifest_info->description; ptr != NULL; ptr = ptr->next)
{
if (ptr->lang) {
}
}
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
- }
return PMINFO_R_OK;
}
API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (author_name == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- char *syslocale = NULL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *locale = NULL;
- char *save = NULL;
author_x *ptr = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- save = locale;
*author_name = NULL;
+
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ locale = info->locale;
+ retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
+
for(ptr = info->manifest_info->author; ptr != NULL; ptr = ptr->next)
{
if (ptr->lang) {
}
}
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
- }
return PMINFO_R_OK;
}
API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (author_email == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
*author_email = (char *)info->manifest_info->author->email;
return PMINFO_R_OK;
API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (author_href == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
*author_href = (char *)info->manifest_info->author->href;
return PMINFO_R_OK;
API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
{
- int ret = -1;
- char *pkgid;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
- pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
- if (pkgid == NULL){
- _LOGE("invalid func parameters\n");
- return PMINFO_R_ERROR;
- }
-
- FILE *fp = NULL;
- char app_mmc_path[FILENAME_MAX] = { 0, };
- char app_dir_path[FILENAME_MAX] = { 0, };
- char app_mmc_internal_path[FILENAME_MAX] = { 0, };
- snprintf(app_dir_path, FILENAME_MAX,
- "%s%s", PKG_INSTALLATION_PATH, pkgid);
- snprintf(app_mmc_path, FILENAME_MAX,
- "%s%s", PKG_SD_PATH, pkgid);
- snprintf(app_mmc_internal_path, FILENAME_MAX,
- "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- /*check whether application is in external memory or not */
- fp = fopen(app_mmc_path, "r");
- if (fp == NULL) {
- _LOGE(" app path in external memory not accesible\n");
- } else {
- fclose(fp);
- fp = NULL;
- *storage = PMINFO_EXTERNAL_STORAGE;
- return PMINFO_R_OK;
- }
+ if (strcmp(info->manifest_info->installed_storage,"installed_internal") == 0)
+ *storage = PMINFO_INTERNAL_STORAGE;
+ else if (strcmp(info->manifest_info->installed_storage,"installed_external") == 0)
+ *storage = PMINFO_EXTERNAL_STORAGE;
+ else
+ return PMINFO_R_ERROR;
- /*check whether application is in internal or not */
- fp = fopen(app_dir_path, "r");
- if (fp == NULL) {
- _LOGE(" app path in internal memory not accesible\n");
- *storage = -1;
- return PMINFO_R_ERROR;
- } else {
- fclose(fp);
- /*check whether the application is installed in SD card
- but SD card is not present*/
- fp = fopen(app_mmc_internal_path, "r");
- if (fp == NULL) {
- *storage = PMINFO_INTERNAL_STORAGE;
- return PMINFO_R_OK;
- } else {
- fclose(fp);
- *storage = PMINFO_EXTERNAL_STORAGE;
- return PMINFO_R_OK;
- }
- }
+ return PMINFO_R_OK;
}
API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (installed_time == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
if (info->manifest_info->installed_time)
*installed_time = atoi(info->manifest_info->installed_time);
API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (storeclientid == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
*storeclientid = (char *)info->manifest_info->storeclient_id;
return PMINFO_R_OK;
API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (mainappid == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
*mainappid = (char *)info->manifest_info->mainapp_id;
return PMINFO_R_OK;
API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (url == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
*url = (char *)info->manifest_info->package_url;
return PMINFO_R_OK;
API int pkgmgrinfo_pkginfo_get_size_from_xml(const char *manifest, int *size)
{
- char *val = NULL;
+ const char *val = NULL;
const xmlChar *node;
xmlTextReaderPtr reader;
-
- if (manifest == NULL) {
- _LOGE("input argument is NULL\n");
- return PMINFO_R_ERROR;
- }
-
- if (size == NULL) {
- _LOGE("output argument is NULL\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
+ retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
xmlInitParser();
reader = xmlReaderForFile(manifest, NULL, 0);
API int pkgmgrinfo_pkginfo_get_location_from_xml(const char *manifest, pkgmgrinfo_install_location *location)
{
- char *val = NULL;
+ const char *val = NULL;
const xmlChar *node;
xmlTextReaderPtr reader;
-
- if (manifest == NULL) {
- _LOGE("input argument is NULL\n");
- return PMINFO_R_ERROR;
- }
-
- if (location == NULL) {
- _LOGE("output argument is NULL\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(manifest == NULL, PMINFO_R_EINVAL, "Input argument is NULL\n");
+ retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
xmlInitParser();
reader = xmlReaderForFile(manifest, NULL, 0);
return PMINFO_R_OK;
}
+
+API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ if (info->manifest_info->root_path)
+ *path = (char *)info->manifest_info->root_path;
+ else
+ return PMINFO_R_ERROR;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ if (info->manifest_info->csc_path)
+ *path = (char *)info->manifest_info->csc_path;
+ else
+ *path = (char *)info->manifest_info->csc_path;
+
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
{
- if (lhs_package_id == NULL || rhs_package_id == NULL)
- {
- _LOGE("pkginfo id is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (compare_result == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(lhs_package_id == NULL, PMINFO_R_EINVAL, "lhs package ID is NULL");
+ retvm_if(rhs_package_id == NULL, PMINFO_R_EINVAL, "rhs package ID is NULL");
+ retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
int ret = PMINFO_R_OK;
char query[MAX_QUERY_LEN] = {'\0'};
char *error_message = NULL;
pkgmgr_cert_x *info= NULL;
- char *lcert = NULL;
- char *rcert = NULL;
+ int lcert = 0;
+ int rcert = 0;
int exist = -1;
-
+ *compare_result = PMINFO_CERT_COMPARE_ERROR;
info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
- if (info == NULL) {
- _LOGE("Out of Memory!!!\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
ret = db_util_open_with_options(CERT_DB, &cert_db,
SQLITE_OPEN_READONLY, NULL);
if (ret != SQLITE_OK) {
_LOGE("connect db [%s] failed!\n", CERT_DB);
- free(info);
- info = NULL;
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto err;
}
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
}
if (exist == 0) {
- lcert = NULL;
+ lcert = 0;
} else {
snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
if (SQLITE_OK !=
ret = PMINFO_R_ERROR;
goto err;
}
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", info->certvalue);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- lcert = info->certvalue;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", info->certvalue);
- free(info->certvalue);
- info->certvalue = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- lcert = info->certvalue;
- }
+ lcert = info->cert_id;
}
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
}
if (exist == 0) {
- rcert = NULL;
+ rcert = 0;
} else {
snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
if (SQLITE_OK !=
ret = PMINFO_R_ERROR;
goto err;
}
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", info->certvalue);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- rcert = info->certvalue;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", info->certvalue);
- free(info->certvalue);
- info->certvalue = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- rcert = info->certvalue;
- }
+ rcert = info->cert_id;
}
- if ((lcert == NULL) || (rcert == NULL))
+ if ((lcert == 0) || (rcert == 0))
{
- if ((lcert == NULL) && (rcert == NULL))
+ if ((lcert == 0) && (rcert == 0))
*compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
- else if (lcert == NULL)
+ else if (lcert == 0)
*compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
- else if (rcert == NULL)
+ else if (rcert == 0)
*compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
} else {
- if (strcmp(lcert, rcert) == 0)
+ if (lcert == rcert)
*compare_result = PMINFO_CERT_COMPARE_MATCH;
else
*compare_result = PMINFO_CERT_COMPARE_MISMATCH;
sqlite3_free(error_message);
sqlite3_close(cert_db);
if (info) {
+ if (info->pkgid) {
+ free(info->pkgid);
+ info->pkgid = NULL;
+ }
free(info);
info = NULL;
}
-
return ret;
}
API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id, const char *rhs_app_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
{
- if (lhs_app_id == NULL || rhs_app_id == NULL)
- {
- _LOGE("pkginfo id is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (compare_result == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(lhs_app_id == NULL, PMINFO_R_EINVAL, "lhs app ID is NULL");
+ retvm_if(rhs_app_id == NULL, PMINFO_R_EINVAL, "rhs app ID is NULL");
+ retvm_if(compare_result == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
int ret = PMINFO_R_OK;
char query[MAX_QUERY_LEN] = {'\0'};
char *error_message = NULL;
pkgmgr_cert_x *info= NULL;
- char *lcert = NULL;
- char *rcert = NULL;
- char *lhs_package_id = NULL;
- char *rhs_package_id = NULL;
- int exist = -1;
+ int exist = -1;
+ char *lpkgid = NULL;
+ char *rpkgid = NULL;
info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
- if (info == NULL) {
- _LOGE("Out of Memory!!!\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
ret = db_util_open_with_options(MANIFEST_DB, &manifest_db,
SQLITE_OPEN_READONLY, NULL);
if (ret != SQLITE_OK) {
_LOGE("connect db [%s] failed!\n", MANIFEST_DB);
- free(info);
- info = NULL;
- return PMINFO_R_ERROR;
- }
- ret = db_util_open_with_options(CERT_DB, &cert_db,
- SQLITE_OPEN_READONLY, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", CERT_DB);
- sqlite3_close(manifest_db);
- free(info);
- info = NULL;
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto err;
}
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
}
if (exist == 0) {
- lcert = NULL;
+ lpkgid = NULL;
} else {
snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
if (SQLITE_OK !=
ret = PMINFO_R_ERROR;
goto err;
}
-
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", info->pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
+ lpkgid = strdup(info->pkgid);
+ if (lpkgid == NULL) {
+ _LOGE("Out of Memory\n");
ret = PMINFO_R_ERROR;
goto err;
}
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", info->certvalue);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- lcert = info->certvalue;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", info->certvalue);
- free(info->certvalue);
- info->certvalue = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- lcert = info->certvalue;
- }
+ free(info->pkgid);
+ info->pkgid = NULL;
}
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
}
if (exist == 0) {
- rcert = NULL;
+ rpkgid = NULL;
} else {
snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
if (SQLITE_OK !=
ret = PMINFO_R_ERROR;
goto err;
}
-
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", info->pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
+ rpkgid = strdup(info->pkgid);
+ if (rpkgid == NULL) {
+ _LOGE("Out of Memory\n");
ret = PMINFO_R_ERROR;
goto err;
}
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", info->certvalue);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- rcert = info->certvalue;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", info->certvalue);
- free(info->certvalue);
- info->certvalue = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- rcert = info->certvalue;
- }
+ free(info->pkgid);
+ info->pkgid = NULL;
}
-
- if ((lcert == NULL) || (rcert == NULL))
- {
- if ((lcert == NULL) && (rcert == NULL))
- *compare_result = PMINFO_CERT_COMPARE_BOTH_NO_CERT;
- else if (lcert == NULL)
- *compare_result = PMINFO_CERT_COMPARE_LHS_NO_CERT;
- else if (rcert == NULL)
- *compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
- } else {
- if (strcmp(lcert, rcert) == 0)
- *compare_result = PMINFO_CERT_COMPARE_MATCH;
- else
- *compare_result = PMINFO_CERT_COMPARE_MISMATCH;
- }
-
-err:
+ ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
+ err:
sqlite3_free(error_message);
sqlite3_close(manifest_db);
- sqlite3_close(cert_db);
if (info) {
+ if (info->pkgid) {
+ free(info->pkgid);
+ info->pkgid = NULL;
+ }
free(info);
info = NULL;
}
-
+ if (lpkgid) {
+ free(lpkgid);
+ lpkgid = NULL;
+ }
+ if (rpkgid) {
+ free(rpkgid);
+ rpkgid = NULL;
+ }
return ret;
}
API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
{
- char *pkgid;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+#if 0 //smack issue occured, check later
+ char *pkgid = NULL;
pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
if (pkgid == NULL){
_LOGD("invalid func parameters\n");
}
_LOGD("pkgmgr_get_pkg_external_validation() end\n");
+#endif
+
+ *accessible = 1;
return PMINFO_R_OK;
}
API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (removable == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *val = NULL;
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
val = (char *)info->manifest_info->removable;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
+API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (preload == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ char *val = NULL;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ val = (char *)info->manifest_info->installlocation;
+ if (val) {
+ if (strcmp(val, "internal-only") == 0)
+ *movable = 0;
+ else if (strcmp(val, "prefer-external") == 0)
+ *movable = 1;
+ else
+ *movable = 1;
}
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *val = NULL;
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
val = (char *)info->manifest_info->preload;
return PMINFO_R_OK;
}
+API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ char *preload = NULL;
+ char *removable = NULL;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ preload = (char *)info->manifest_info->preload;
+ removable = (char *)info->manifest_info->removable;
+
+ if ((strcasecmp(preload, "true") == 0) && (strcasecmp(removable, "false") == 0))
+ *system = 1;
+ else
+ *system = 0;
+
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (readonly == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *val = NULL;
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
val = (char *)info->manifest_info->readonly;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
+API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ char *val = NULL;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ val = (char *)info->manifest_info->update;
+ if (val) {
+ if (strcasecmp(val, "true") == 0)
+ *update = 1;
+ else if (strcasecmp(val, "false") == 0)
+ *update = 0;
+ else
+ *update = 1;
}
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
__cleanup_pkginfo(info);
return PMINFO_R_OK;
API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
{
- if (handle == NULL) {
- _LOGE("Filter handle output parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
*handle = NULL;
pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)calloc(1, sizeof(pkgmgrinfo_filter_x));
if (filter == NULL) {
API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
{
- if (handle == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
if (filter->list){
g_slist_foreach(filter->list, __destroy_each_node, NULL);
API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
const char *property, const int value)
{
- if (handle == NULL || property == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
char *val = NULL;
GSList *link = NULL;
API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
const char *property, const bool value)
{
- if (handle == NULL || property == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char *val = NULL;
GSList *link = NULL;
int prop = -1;
API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
const char *property, const char *value)
{
- if (handle == NULL || property == NULL || value == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char *val = NULL;
GSList *link = NULL;
int prop = -1;
val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
+ else if (strcmp(value, "installed_internal") == 0)
+ val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
+ else if (strcmp(value, "installed_external") == 0)
+ val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
else
val = strndup(value, PKG_STRING_LEN_MAX - 1);
if (val == NULL) {
API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
{
- if (handle == NULL || count == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char *syslocale = NULL;
char *locale = NULL;
char *condition = NULL;
free(syslocale);
return PMINFO_R_ERROR;
}
+
ret = __open_manifest_db();
if (ret == -1) {
_LOGE("Fail to open manifest DB\n");
API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
{
- if (handle == NULL || pkg_cb == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(pkg_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char *syslocale = NULL;
char *locale = NULL;
char *condition = NULL;
icon_x *tmp2 = NULL;
description_x *tmp3 = NULL;
author_x *tmp4 = NULL;
+ privilege_x *tmp5 = NULL;
pkgmgr_pkginfo_x *node = NULL;
pkgmgr_pkginfo_x *tmphead = NULL;
pkgmgr_pkginfo_x *pkginfo = NULL;
free(syslocale);
return PMINFO_R_ERROR;
}
+
ret = __open_manifest_db();
if (ret == -1) {
_LOGE("Fail to open manifest DB\n");
LISTHEAD(tmphead, node);
for(node = node->next ; node ; node = node->next) {
pkginfo = node;
+ pkginfo->locale = strdup(locale);
+ pkginfo->manifest_info->privileges = (privileges_x *)calloc(1, sizeof(privileges_x));
+ if (pkginfo->manifest_info->privileges == NULL) {
+ _LOGE("Failed to allocate memory for privileges info\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
/*populate manifest_info from DB*/
snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkginfo->manifest_info->package);
LISTHEAD(pkginfo->manifest_info->author, tmp4);
pkginfo->manifest_info->author = tmp4;
}
+ if (pkginfo->manifest_info->privileges->privilege) {
+ LISTHEAD(pkginfo->manifest_info->privileges->privilege, tmp5);
+ pkginfo->manifest_info->privileges->privilege = tmp5;
+ }
}
LISTHEAD(tmphead, node);
return ret;
}
+API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret = -1;
+ privilege_x *ptr = NULL;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ ptr = info->manifest_info->privileges->privilege;
+ for (; ptr; ptr = ptr->next) {
+ if (ptr->text){
+ ret = privilege_func(ptr->text, user_data);
+ if (ret < 0)
+ break;
+ }
+ }
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
pkgmgrinfo_app_list_cb app_func, void *user_data)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (app_func == NULL) {
- _LOGE("callback pointer is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (component != PMINFO_UI_APP && component != PMINFO_SVC_APP && component != PMINFO_ALL_APP) {
- _LOGE("Invalid App Component Type\n");
- return PMINFO_R_EINVAL;
- }
- char *error_message = NULL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback pointer is NULL");
+ retvm_if((component != PMINFO_UI_APP) && (component != PMINFO_SVC_APP) && (component != PMINFO_ALL_APP), PMINFO_R_EINVAL, "Invalid App Component Type");
+
char *syslocale = NULL;
char *locale = NULL;
int ret = -1;
pkgmgr_appinfo_x *appinfo = NULL;
icon_x *ptr1 = NULL;
label_x *ptr2 = NULL;
+ category_x *ptr3 = NULL;
+ metadata_x *ptr4 = NULL;
+ permission_x *ptr5 = NULL;
+ image_x *ptr6 = NULL;
+ sqlite3 *appinfo_db = NULL;
+ /*get system locale*/
syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(syslocale == NULL, ret = PMINFO_R_EINVAL, "current locale is NULL");
+
+ /*get locale on db*/
locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- ret = PMINFO_R_EINVAL;
- goto err;
- }
+ tryvm_if(locale == NULL, ret = PMINFO_R_EINVAL, "manifest locale is NULL");
- allinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
- if (allinfo == NULL) {
- _LOGE("Failed to allocate memory for appinfo\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ /*calloc allinfo*/
+ allinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
+ tryvm_if(allinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
+
+ /*calloc manifest_info*/
allinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
- if (allinfo->manifest_info == NULL) {
- _LOGE("Out of Memory!!!\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(allinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+ /*calloc appinfo*/
appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
- if (appinfo == NULL) {
- _LOGE("Failed to allocate memory for appinfo\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
+
+ /*set component type*/
if (component == PMINFO_UI_APP)
appinfo->app_component = PMINFO_UI_APP;
if (component == PMINFO_SVC_APP)
appinfo->app_component = PMINFO_SVC_APP;
if (component == PMINFO_ALL_APP)
appinfo->app_component = PMINFO_ALL_APP;
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+
+ /*open db */
+ ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
appinfo->package = strdup(info->manifest_info->package);
snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
switch(component) {
case PMINFO_UI_APP:
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ /*Populate ui app info */
+ ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
+
uiapplication_x *tmp = NULL;
if (info->manifest_info->uiapplication) {
LISTHEAD(info->manifest_info->uiapplication, tmp);
/*If the callback func return < 0 we break and no more call back is called*/
while(tmp != NULL)
{
+ appinfo->locale = strdup(locale);
appinfo->uiapp_info = tmp;
-
if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
if (locale) {
free(locale);
}
- locale = __get_app_locale_by_fallback(appinfo->uiapp_info->appid, syslocale);
+ locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
}
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
+ /*store setting notification icon section*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
+
+ /*store app preview image info*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->label, ptr2);
appinfo->uiapp_info->label = ptr2;
LISTHEAD(appinfo->uiapp_info->icon, ptr1);
appinfo->uiapp_info->icon = ptr1;
}
+ if (appinfo->uiapp_info->category) {
+ LISTHEAD(appinfo->uiapp_info->category, ptr3);
+ appinfo->uiapp_info->category = ptr3;
+ }
+ if (appinfo->uiapp_info->metadata) {
+ LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
+ appinfo->uiapp_info->metadata = ptr4;
+ }
+ if (appinfo->uiapp_info->permission) {
+ LISTHEAD(appinfo->uiapp_info->permission, ptr5);
+ appinfo->uiapp_info->permission = ptr5;
+ }
+ if (appinfo->uiapp_info->image) {
+ LISTHEAD(appinfo->uiapp_info->image, ptr6);
+ appinfo->uiapp_info->image = ptr6;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
}
break;
case PMINFO_SVC_APP:
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ /*Populate svc app info */
+ ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
+
serviceapplication_x *tmp1 = NULL;
if (info->manifest_info->serviceapplication) {
LISTHEAD(info->manifest_info->serviceapplication, tmp1);
/*If the callback func return < 0 we break and no more call back is called*/
while(tmp1 != NULL)
{
+ appinfo->locale = strdup(locale);
appinfo->svcapp_info = tmp1;
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->label, ptr2);
appinfo->svcapp_info->label = ptr2;
LISTHEAD(appinfo->svcapp_info->icon, ptr1);
appinfo->svcapp_info->icon = ptr1;
}
+ if (appinfo->svcapp_info->category) {
+ LISTHEAD(appinfo->svcapp_info->category, ptr3);
+ appinfo->svcapp_info->category = ptr3;
+ }
+ if (appinfo->svcapp_info->metadata) {
+ LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
+ appinfo->svcapp_info->metadata = ptr4;
+ }
+ if (appinfo->svcapp_info->permission) {
+ LISTHEAD(appinfo->svcapp_info->permission, ptr5);
+ appinfo->svcapp_info->permission = ptr5;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
case PMINFO_ALL_APP:
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __allapp_list_cb, (void *)allinfo, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- ret = PMINFO_R_ERROR;
- goto err;
- }
+
+ /*Populate all app info */
+ ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
/*UI Apps*/
appinfo->app_component = PMINFO_UI_APP;
/*If the callback func return < 0 we break and no more call back is called*/
while(tmp2 != NULL)
{
+ appinfo->locale = strdup(locale);
appinfo->uiapp_info = tmp2;
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
+ /*store setting notification icon section*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
+
+ /*store app preview image info*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->label, ptr2);
appinfo->uiapp_info->label = ptr2;
LISTHEAD(appinfo->uiapp_info->icon, ptr1);
appinfo->uiapp_info->icon = ptr1;
}
+ if (appinfo->uiapp_info->category) {
+ LISTHEAD(appinfo->uiapp_info->category, ptr3);
+ appinfo->uiapp_info->category = ptr3;
+ }
+ if (appinfo->uiapp_info->metadata) {
+ LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
+ appinfo->uiapp_info->metadata = ptr4;
+ }
+ if (appinfo->uiapp_info->permission) {
+ LISTHEAD(appinfo->uiapp_info->permission, ptr5);
+ appinfo->uiapp_info->permission = ptr5;
+ }
+ if (appinfo->uiapp_info->image) {
+ LISTHEAD(appinfo->uiapp_info->image, ptr6);
+ appinfo->uiapp_info->image = ptr6;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
/*If the callback func return < 0 we break and no more call back is called*/
while(tmp3 != NULL)
{
+ appinfo->locale = strdup(locale);
appinfo->svcapp_info = tmp3;
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->label, ptr2);
appinfo->svcapp_info->label = ptr2;
LISTHEAD(appinfo->svcapp_info->icon, ptr1);
appinfo->svcapp_info->icon = ptr1;
}
+ if (appinfo->svcapp_info->category) {
+ LISTHEAD(appinfo->svcapp_info->category, ptr3);
+ appinfo->svcapp_info->category = ptr3;
+ }
+ if (appinfo->svcapp_info->metadata) {
+ LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
+ appinfo->svcapp_info->metadata = ptr4;
+ }
+ if (appinfo->svcapp_info->permission) {
+ LISTHEAD(appinfo->svcapp_info->permission, ptr5);
+ appinfo->svcapp_info->permission = ptr5;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
}
ret = PMINFO_R_OK;
-err:
+catch:
if (locale) {
free(locale);
locale = NULL;
}
if (appinfo) {
if (appinfo->package) {
- free(appinfo->package);
+ free((void *)appinfo->package);
appinfo->package = NULL;
}
free(appinfo);
}
__cleanup_pkginfo(allinfo);
- sqlite3_close(manifest_db);
+ sqlite3_close(appinfo_db);
return ret;
}
-API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
+API int pkgmgrinfo_appinfo_get_install_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
{
- if (app_func == NULL) {
- _LOGE("callback function is NULL\n");
- return PMINFO_R_EINVAL;
- }
- char *error_message = NULL;
+ retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
+
int ret = PMINFO_R_OK;
char query[MAX_QUERY_LEN] = {'\0'};
- char *syslocale = NULL;
- char *locale = NULL;
+ pkgmgr_appinfo_x *info = NULL;
pkgmgr_appinfo_x *appinfo = NULL;
uiapplication_x *ptr1 = NULL;
- serviceapplication_x *ptr2 = NULL;
- label_x *tmp1 = NULL;
- icon_x *tmp2 = NULL;
+ sqlite3 *appinfo_db = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- ret = PMINFO_R_EINVAL;
- goto err;
- }
+ /*open db*/
+ ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
- pkgmgr_pkginfo_x *info = NULL;
- info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
- if (info == NULL) {
- _LOGE("Out of Memory!!!\n");
- ret = PMINFO_R_ERROR;
- goto err;
+ /*calloc appinfo*/
+ info = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+ tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+
+ /*calloc uiapplication_x*/
+ info->uiapp_info= (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
+ tryvm_if(info->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+
+ /*calloc appinfo*/
+ appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+ tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+
+ /*query package_app_info*/
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
+ ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
+ LISTHEAD(info->uiapp_info, ptr1);
+
+ /*call back*/
+ for(ptr1 = ptr1->next ; ptr1 ; ptr1 = ptr1->next)
+ {
+ appinfo->uiapp_info= ptr1;
+ appinfo->package = strdup(ptr1->package);
+ appinfo->app_component = PMINFO_UI_APP;
+
+ ret = app_func((void *)appinfo, user_data);
+ if (ret < 0)
+ break;
+ free((void *)appinfo->package);
+ appinfo->package = NULL;
}
- info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
- if (info->manifest_info == NULL) {
- _LOGE("Out of Memory!!!\n");
- ret = PMINFO_R_ERROR;
- goto err;
+
+catch:
+ sqlite3_close(appinfo_db);
+
+ if (appinfo) {
+ free(appinfo);
+ appinfo = NULL;
}
+ __cleanup_appinfo(info);
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func, void *user_data)
+{
+ retvm_if(app_func == NULL, PMINFO_R_EINVAL, "callback function is NULL");
+
+ int ret = PMINFO_R_OK;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ char *syslocale = NULL;
+ char *locale = NULL;
+ pkgmgr_appinfo_x *appinfo = NULL;
+ uiapplication_x *ptr1 = NULL;
+ serviceapplication_x *ptr2 = NULL;
+ label_x *tmp1 = NULL;
+ icon_x *tmp2 = NULL;
+ category_x *tmp3 = NULL;
+ metadata_x *tmp4 = NULL;
+ permission_x *tmp5 = NULL;
+ image_x *tmp6 = NULL;
+ sqlite3 *appinfo_db = NULL;
+
+ /*get system locale*/
+ syslocale = vconf_get_str(VCONFKEY_LANGSET);
+ tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
+
+ /*get locale on db*/
+ locale = __convert_system_locale_to_manifest_locale(syslocale);
+ tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
+
+ /*open db*/
+ ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+
+ /*calloc pkginfo*/
+ pkgmgr_pkginfo_x *info = NULL;
+ info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
+ tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+
+ /*calloc manifest_info*/
+ info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
+ tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
+
+ /*calloc appinfo*/
appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
- if (appinfo == NULL) {
- _LOGE("Out of Memory!!!\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- memset(query, '\0', MAX_QUERY_LEN);
+ ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
if (info->manifest_info->uiapplication) {
LISTHEAD(info->manifest_info->uiapplication, ptr1);
info->manifest_info->uiapplication = ptr1;
/*UI Apps*/
for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
{
+ appinfo->locale = strdup(locale);
appinfo->app_component = PMINFO_UI_APP;
appinfo->package = strdup(ptr1->package);
appinfo->uiapp_info = ptr1;
snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
"from package_app_info where " \
"app_id='%s'", ptr1->appid);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
if (locale) {
free(locale);
}
- locale = __get_app_locale_by_fallback(ptr1->appid, syslocale);
+ locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
}
memset(query, '\0', MAX_QUERY_LEN);
"from package_app_localized_info where " \
"app_id='%s' and app_locale='%s'",
ptr1->appid, locale);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
"from package_app_localized_info where " \
"app_id='%s' and app_locale='%s'",
ptr1->appid, DEFAULT_LOCALE);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
+ /*store setting notification icon section*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
+
+ /*store app preview image info*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->label, tmp1);
appinfo->uiapp_info->label = tmp1;
LISTHEAD(appinfo->uiapp_info->icon, tmp2);
appinfo->uiapp_info->icon= tmp2;
}
+ if (appinfo->uiapp_info->category) {
+ LISTHEAD(appinfo->uiapp_info->category, tmp3);
+ appinfo->uiapp_info->category = tmp3;
+ }
+ if (appinfo->uiapp_info->metadata) {
+ LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
+ appinfo->uiapp_info->metadata = tmp4;
+ }
+ if (appinfo->uiapp_info->permission) {
+ LISTHEAD(appinfo->uiapp_info->permission, tmp5);
+ appinfo->uiapp_info->permission = tmp5;
+ }
+ if (appinfo->uiapp_info->image) {
+ LISTHEAD(appinfo->uiapp_info->image, tmp6);
+ appinfo->uiapp_info->image = tmp6;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
- free(appinfo->package);
+ free((void *)appinfo->package);
appinfo->package = NULL;
}
/*Service Apps*/
for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
{
+ appinfo->locale = strdup(locale);
appinfo->app_component = PMINFO_SVC_APP;
appinfo->package = strdup(ptr2->package);
appinfo->svcapp_info = ptr2;
+ memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
"from package_app_info where " \
"app_id='%s'", ptr2->appid);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
"from package_app_localized_info where " \
"app_id='%s' and app_locale='%s'",
ptr2->appid, locale);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
"from package_app_localized_info where " \
"app_id='%s' and app_locale='%s'",
ptr2->appid, DEFAULT_LOCALE);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->label, tmp1);
appinfo->svcapp_info->label = tmp1;
LISTHEAD(appinfo->svcapp_info->icon, tmp2);
appinfo->svcapp_info->icon= tmp2;
}
+ if (appinfo->svcapp_info->category) {
+ LISTHEAD(appinfo->svcapp_info->category, tmp3);
+ appinfo->svcapp_info->category = tmp3;
+ }
+ if (appinfo->svcapp_info->metadata) {
+ LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
+ appinfo->svcapp_info->metadata = tmp4;
+ }
+ if (appinfo->svcapp_info->permission) {
+ LISTHEAD(appinfo->svcapp_info->permission, tmp5);
+ appinfo->svcapp_info->permission = tmp5;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
- free(appinfo->package);
+ free((void *)appinfo->package);
appinfo->package = NULL;
}
ret = PMINFO_R_OK;
-err:
+catch:
if (locale) {
free(locale);
locale = NULL;
free(syslocale);
syslocale = NULL;
}
- sqlite3_close(manifest_db);
+ sqlite3_close(appinfo_db);
if (appinfo) {
free(appinfo);
appinfo = NULL;
API int pkgmgrinfo_appinfo_get_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
{
- if (appid == NULL) {
- _LOGE("appid is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (handle == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+
pkgmgr_appinfo_x *appinfo = NULL;
- char *error_message = NULL;
char *syslocale = NULL;
char *locale = NULL;
int ret = -1;
label_x *tmp1 = NULL;
icon_x *tmp2 = NULL;
category_x *tmp3 = NULL;
+ metadata_x *tmp4 = NULL;
+ permission_x *tmp5 = NULL;
+ image_x *tmp6 = NULL;
char query[MAX_QUERY_LEN] = {'\0'};
+ sqlite3 *appinfo_db = NULL;
- /*Validate appid*/
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ /*open db*/
+ ret = db_util_open_with_options(MANIFEST_DB, &appinfo_db, SQLITE_OPEN_READONLY, NULL);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+
+ /*check appid exist on db*/
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- return PMINFO_R_ERROR;
- }
- if (exist == 0) {
- _LOGE("Appid not found in DB\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
+ tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
+
+ /*get system locale*/
syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(syslocale == NULL, ret = PMINFO_R_ERROR, "current locale is NULL");
+
+ /*get locale on db*/
locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
+
+ /*calloc appinfo*/
appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
- if (appinfo == NULL) {
- _LOGE("Failed to allocate memory for appinfo\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for appinfo");
/*check app_component from DB*/
+ memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
- ret = __exec_appcomponent_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+ /*calloc app_component*/
if (appinfo->app_component == PMINFO_UI_APP) {
appinfo->uiapp_info = (uiapplication_x *)calloc(1, sizeof(uiapplication_x));
- if (appinfo->uiapp_info == NULL) {
- _LOGE("Failed to allocate memory for uiapp info\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(appinfo->uiapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for uiapp info");
} else {
appinfo->svcapp_info = (serviceapplication_x *)calloc(1, sizeof(serviceapplication_x));
- if (appinfo->svcapp_info == NULL) {
- _LOGE("Failed to allocate memory for svcapp info\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ tryvm_if(appinfo->svcapp_info == NULL, ret = PMINFO_R_ERROR, "Failed to allocate memory for svcapp info");
}
+ appinfo->locale = strdup(locale);
/*populate app_info from DB*/
+ memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
-
- if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
- if (locale) {
- free(locale);
- }
- locale = __get_app_locale_by_fallback(appid, syslocale);
- }
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appid, locale);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+
/*Also store the values corresponding to default locales*/
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where" \
- " app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Localized Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+
/*Populate app category*/
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where" \
- " app_id='%s'", appid);
- ret = __exec_appinfo_query(query, (void *)appinfo);
- if (ret == -1) {
- _LOGE("App Category Info DB Information retrieval failed\n");
- ret = PMINFO_R_ERROR;
- goto err;
- }
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
+
+ /*Populate app metadata*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
+
+ /*Populate app permission*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
+
+ /*store setting notification icon section*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
+
+ /*store app preview image info*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
+ ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+
switch (appinfo->app_component) {
case PMINFO_UI_APP:
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->category, tmp3);
appinfo->uiapp_info->category = tmp3;
}
+ if (appinfo->uiapp_info->metadata) {
+ LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
+ appinfo->uiapp_info->metadata = tmp4;
+ }
+ if (appinfo->uiapp_info->permission) {
+ LISTHEAD(appinfo->uiapp_info->permission, tmp5);
+ appinfo->uiapp_info->permission = tmp5;
+ }
+ if (appinfo->uiapp_info->image) {
+ LISTHEAD(appinfo->uiapp_info->image, tmp6);
+ appinfo->uiapp_info->image = tmp6;
+ }
break;
case PMINFO_SVC_APP:
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->category, tmp3);
appinfo->svcapp_info->category = tmp3;
}
+ if (appinfo->svcapp_info->metadata) {
+ LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
+ appinfo->svcapp_info->metadata = tmp4;
+ }
+ if (appinfo->svcapp_info->permission) {
+ LISTHEAD(appinfo->svcapp_info->permission, tmp5);
+ appinfo->svcapp_info->permission = tmp5;
+ }
break;
default:
break;
}
- *handle = (void*)appinfo;
- sqlite3_close(manifest_db);
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- if (locale) {
- free(locale);
- locale = NULL;
+ ret = PMINFO_R_OK;
+
+catch:
+ if (ret == PMINFO_R_OK)
+ *handle = (void*)appinfo;
+ else {
+ *handle = NULL;
+ __cleanup_appinfo(appinfo);
}
- return PMINFO_R_OK;
-err:
- *handle = NULL;
- __cleanup_appinfo(appinfo);
- sqlite3_close(manifest_db);
+
+ sqlite3_close(appinfo_db);
if (syslocale) {
free(syslocale);
syslocale = NULL;
API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (appid == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
if (info->app_component == PMINFO_UI_APP)
API int pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo_h handle, char **pkg_name)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (pkg_name == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
*pkg_name = (char *)info->package;
API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (pkgid == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
*pkgid = (char *)info->package;
API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (exec == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(exec == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
if (info->app_component == PMINFO_UI_APP)
API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (icon == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- char *syslocale = NULL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *locale = NULL;
- char *save = NULL;
icon_x *ptr = NULL;
icon_x *start = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- save = locale;
*icon = NULL;
+
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ locale = info->locale;
+ retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
+
if (info->app_component == PMINFO_UI_APP)
start = info->uiapp_info->icon;
if (info->app_component == PMINFO_SVC_APP)
}
}
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
- }
return PMINFO_R_OK;
}
API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (label == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- char *syslocale = NULL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *locale = NULL;
- char *save = NULL;
label_x *ptr = NULL;
label_x *start = NULL;
- syslocale = vconf_get_str(VCONFKEY_LANGSET);
- if (syslocale == NULL) {
- _LOGE("current locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
- locale = __convert_system_locale_to_manifest_locale(syslocale);
- if (locale == NULL) {
- _LOGE("manifest locale is NULL\n");
- return PMINFO_R_EINVAL;
- }
-
- save = locale;
*label = NULL;
+
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ locale = info->locale;
+ retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
+
if (info->app_component == PMINFO_UI_APP)
start = info->uiapp_info->label;
if (info->app_component == PMINFO_SVC_APP)
}
}
}
- if (syslocale) {
- free(syslocale);
- syslocale = NULL;
- }
- locale = save;
- if (locale) {
- free(locale);
- locale = NULL;
- }
return PMINFO_R_OK;
}
API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (component == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(component == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
if (info->app_component == PMINFO_UI_APP)
API int pkgmgrinfo_appinfo_get_apptype(pkgmgrinfo_appinfo_h handle, char **app_type)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (app_type == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(app_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
if (info->app_component == PMINFO_UI_APP)
API int pkgmgrinfo_appinfo_get_operation(pkgmgrinfo_appcontrol_h handle,
int *operation_count, char ***operation)
{
- if (handle == NULL) {
- _LOGE("appcontrol handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (operation_count == NULL || operation == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(operation == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ retvm_if(operation_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
*operation_count = data->operation_count;
*operation = data->operation;
API int pkgmgrinfo_appinfo_get_uri(pkgmgrinfo_appcontrol_h handle,
int *uri_count, char ***uri)
{
- if (handle == NULL) {
- _LOGE("appcontrol handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (uri_count == NULL || uri == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(uri == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ retvm_if(uri_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
*uri_count = data->uri_count;
*uri = data->uri;
API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h handle,
int *mime_count, char ***mime)
{
- if (handle == NULL) {
- _LOGE("appcontrol handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (mime_count == NULL || mime == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(mime == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ retvm_if(mime_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
*mime_count = data->mime_count;
*mime = data->mime;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
+API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h handle,
+ int *subapp_count, char ***subapp)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (icon == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- int ret = -1;
- char *error_message = NULL;
- char query[MAX_QUERY_LEN] = {'\0'};
- char path_buf[PKG_STRING_LEN_MAX] = {'\0'};
- pkgmgr_iconpath_x *data = NULL;
- char *icon_path;
- char *readpath;
- char *appid;
-
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
+ *subapp_count = data->subapp_count;
+ *subapp = data->subapp;
+ return PMINFO_R_OK;
+}
- ret = pkgmgrinfo_appinfo_get_appid(handle,&appid);
- if(ret < 0 || appid == NULL)
- return PMINFO_R_ERROR;
+API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
- data = (pkgmgr_iconpath_x *)calloc(1, sizeof(pkgmgr_iconpath_x));
- if (data == NULL) {
- _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
- sqlite3_close(manifest_db);
- return PMINFO_R_ERROR;
- }
+ char *val = NULL;
+ icon_x *ptr = NULL;
+ icon_x *start = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- snprintf(query, MAX_QUERY_LEN, "select app_icon from package_app_icon_localized_info where app_id='%s' and app_icon_section ='setting'", appid);
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __icon_name_cb, (void *)data, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- free(data);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- return PMINFO_R_ERROR;
- }
- icon_path = __get_icon_with_path(data->iconpath);
- *icon = (char *)icon_path;
+ start = info->uiapp_info->icon;
- if (data) {
- free(data);
- data = NULL;
+ for(ptr = start; ptr != NULL; ptr = ptr->next)
+ {
+ if (ptr->section) {
+ val = (char *)ptr->section;
+ if (strcmp(val, "setting") == 0){
+ *icon = (char *)ptr->text;
+ break;
+ }
+ }
}
- sqlite3_close(manifest_db);
return PMINFO_R_OK;
}
API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (icon == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- int ret = -1;
- char *error_message = NULL;
- char query[MAX_QUERY_LEN] = {'\0'};
- char path_buf[PKG_STRING_LEN_MAX] = {'\0'};
- pkgmgr_iconpath_x *data = NULL;
- char *icon_path;
- char *readpath;
- char *appid;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
- ret = __open_manifest_db();
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- return PMINFO_R_ERROR;
- }
+ char *val = NULL;
+ icon_x *ptr = NULL;
+ icon_x *start = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- ret = pkgmgrinfo_appinfo_get_appid(handle,&appid);
- if(ret < 0 || appid == NULL)
- return PMINFO_R_ERROR;
+ start = info->uiapp_info->icon;
- data = (pkgmgr_iconpath_x *)calloc(1, sizeof(pkgmgr_iconpath_x));
- if (data == NULL) {
- _LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
- sqlite3_close(manifest_db);
- return PMINFO_R_ERROR;
- }
+ for(ptr = start; ptr != NULL; ptr = ptr->next)
+ {
+ if (ptr->section) {
+ val = (char *)ptr->section;
- snprintf(query, MAX_QUERY_LEN, "select app_icon from package_app_icon_localized_info where app_id='%s' and app_icon_section ='notification'", appid);
- if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __icon_name_cb, (void *)data, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- free(data);
- sqlite3_free(error_message);
- sqlite3_close(manifest_db);
- return PMINFO_R_ERROR;
+ if (strcmp(val, "notification") == 0){
+ *icon = (char *)ptr->text;
+ break;
+ }
+ }
}
- icon_path = __get_icon_with_path(data->iconpath);
- *icon = (char *)icon_path;
- if (data) {
- free(data);
- data = NULL;
- }
- sqlite3_close(manifest_db);
return PMINFO_R_OK;
}
API int pkgmgrinfo_appinfo_get_recent_image_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (type == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *val = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
val = (char *)info->uiapp_info->recentimage;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_category_list_cb category_func, void *user_data)
+API int pkgmgrinfo_appinfo_get_preview_image(pkgmgrinfo_appinfo_h handle, char **preview_img)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(preview_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ char *val = NULL;
+ image_x *ptr = NULL;
+ image_x *start = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ start = info->uiapp_info->image;
+
+ for(ptr = start; ptr != NULL; ptr = ptr->next)
+ {
+ if (ptr->section) {
+ val = (char *)ptr->section;
+
+ if (strcmp(val, "preview") == 0)
+ *preview_img = (char *)ptr->text;
+
+ break;
+ }
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_permission_type(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_permission_type *permission)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(permission == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ char *val = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ val = info->uiapp_info->permission_type;
+
+ if (strcmp(val, "signature") == 0)
+ *permission = PMINFO_PERMISSION_SIGNATURE;
+ else if (strcmp(val, "privilege") == 0)
+ *permission = PMINFO_PERMISSION_PRIVILEGE;
+ else
+ *permission = PMINFO_PERMISSION_NORMAL;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_component_type(pkgmgrinfo_appinfo_h handle, char **component_type)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(component_type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ *component_type = (char *)info->uiapp_info->component_type;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ char *val = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ val = (char *)info->uiapp_info->hwacceleration;
+ if (val) {
+ if (strcasecmp(val, "not-use-GL") == 0)
+ *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
+ else if (strcasecmp(val, "use-GL") == 0)
+ *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
+ else
+ *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_screenreader(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_screenreader *screenreader)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(screenreader == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ char *val = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ val = (char *)info->uiapp_info->screenreader;
+ if (val) {
+ if (strcasecmp(val, "screenreader-off") == 0)
+ *screenreader = PMINFO_SCREENREADER_OFF;
+ else if (strcasecmp(val, "screenreader-on") == 0)
+ *screenreader = PMINFO_SCREENREADER_ON;
+ else
+ *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_component == PMINFO_UI_APP){
+ *portrait_img = (char *)info->uiapp_info->portraitimg;
+ *landscape_img = (char *)info->uiapp_info->landscapeimg;
}
- if (category_func == NULL) {
- _LOGE("Callback function is NULL\n");
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h handle, char **submode_mainid)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ *submode_mainid = (char *)info->uiapp_info->submode_mainid;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret = -1;
+ permission_x *ptr = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ if (info->app_component == PMINFO_UI_APP)
+ ptr = info->uiapp_info->permission;
+ else if (info->app_component == PMINFO_SVC_APP)
+ ptr = info->svcapp_info->permission;
+ else
return PMINFO_R_EINVAL;
+ for (; ptr; ptr = ptr->next) {
+ ret = permission_func(ptr->value, user_data);
+ if (ret < 0)
+ break;
}
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_category_list_cb category_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(category_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
int ret = -1;
category_x *ptr = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
+API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (appcontrol_func == NULL) {
- _LOGE("Callback function is NULL\n");
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(metadata_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret = -1;
+ metadata_x *ptr = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ if (info->app_component == PMINFO_UI_APP)
+ ptr = info->uiapp_info->metadata;
+ else if (info->app_component == PMINFO_SVC_APP)
+ ptr = info->svcapp_info->metadata;
+ else
return PMINFO_R_EINVAL;
+ for (; ptr; ptr = ptr->next) {
+ if (ptr->key) {
+ ret = metadata_func(ptr->key, ptr->value, user_data);
+ if (ret < 0)
+ break;
+ }
}
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
int i = 0;
int ret = -1;
int oc = 0;
int mc = 0;
int uc = 0;
+ int sc = 0;
char *pkgid = NULL;
char *manifest = NULL;
char **operation = NULL;
char **uri = NULL;
char **mime = NULL;
+ char **subapp = NULL;
appcontrol_x *appcontrol = NULL;
manifest_x *mfx = NULL;
operation_x *op = NULL;
uri_x *ui = NULL;
mime_x *mi = NULL;
+ subapp_x *sa = NULL;
pkgmgrinfo_app_component component;
pkgmgrinfo_appcontrol_x *ptr = NULL;
ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
switch (component) {
case PMINFO_UI_APP:
if (mfx->uiapplication) {
- if (mfx->uiapplication->appcontrol) {
- appcontrol = mfx->uiapplication->appcontrol;
+ if (mfx->uiapplication->appsvc) {
+ appcontrol = mfx->uiapplication->appsvc;
}
}
break;
case PMINFO_SVC_APP:
if (mfx->serviceapplication) {
- if (mfx->serviceapplication->appcontrol) {
- appcontrol = mfx->serviceapplication->appcontrol;
+ if (mfx->serviceapplication->appsvc) {
+ appcontrol = mfx->serviceapplication->appsvc;
}
}
break;
mc = mc + 1;
mi = appcontrol->mime;
+ sa = appcontrol->subapp;
+ for (; sa; sa = sa->next)
+ sc = sc + 1;
+ sa = appcontrol->subapp;
+
operation = (char **)calloc(oc, sizeof(char *));
for (i = 0; i < oc; i++) {
operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
mi = mi->next;
}
+
+ subapp = (char **)calloc(sc, sizeof(char *));
+ for (i = 0; i < sc; i++) {
+ subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
+ sa = sa->next;
+ }
+
/*populate appcontrol handle*/
ptr->operation_count = oc;
ptr->uri_count = uc;
ptr->mime_count = mc;
+ ptr->subapp_count = sc;
ptr->operation = operation;
ptr->uri = uri;
ptr->mime = mime;
+ ptr->subapp = subapp;
+
ret = appcontrol_func((void *)ptr, user_data);
for (i = 0; i < oc; i++) {
if (operation[i]) {
free(mime);
mime = NULL;
}
+ for (i = 0; i < sc; i++) {
+ if (subapp[i]) {
+ free(subapp[i]);
+ subapp[i] = NULL;
+ }
+ }
+ if (subapp) {
+ free(subapp);
+ subapp = NULL;
+ }
if (ret < 0)
break;
uc = 0;
mc = 0;
oc = 0;
+ sc = 0;
}
pkgmgr_parser_free_manifest_xml(mfx);
if (ptr) {
API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (nodisplay == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *val = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
val = (char *)info->uiapp_info->nodisplay;
API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multiple)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (multiple == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *val = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
val = (char *)info->uiapp_info->multiple;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
+API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (taskmanage == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ char *val = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ val = (char *)info->uiapp_info->indicatordisplay;
+ if (val) {
+ if (strcasecmp(val, "true") == 0){
+ *indicator_disp = 1;
+ }else if (strcasecmp(val, "false") == 0){
+ *indicator_disp = 0;
+ }else{
+ *indicator_disp = 0;
+ }
}
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *val = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
val = (char *)info->uiapp_info->taskmanage;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
+API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h handle, bool *enabled)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (hwacceleration == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *val = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- val = (char *)info->uiapp_info->hwacceleration;
+ if (info->app_component == PMINFO_UI_APP)
+ val = (char *)info->uiapp_info->enabled;
+ else if (info->app_component == PMINFO_SVC_APP)
+ val = (char *)info->uiapp_info->enabled;
+ else {
+ _LOGE("invalid component type\n");
+ return PMINFO_R_EINVAL;
+ }
+
if (val) {
- if (strcasecmp(val, "not-use-GL") == 0)
- *hwacceleration = PMINFO_HWACCELERATION_NOT_USE_GL;
- else if (strcasecmp(val, "use-GL") == 0)
- *hwacceleration = PMINFO_HWACCELERATION_USE_GL;
+ if (strcasecmp(val, "true") == 0)
+ *enabled = 1;
+ else if (strcasecmp(val, "false") == 0)
+ *enabled = 0;
else
- *hwacceleration = PMINFO_HWACCELERATION_USE_SYSTEM_SETTING;
+ *enabled = 1;
}
return PMINFO_R_OK;
+
}
API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h handle, bool *onboot)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (onboot == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *val = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
val = (char *)info->svcapp_info->onboot;
API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h handle, bool *autorestart)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (autorestart == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *val = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
val = (char *)info->svcapp_info->autorestart;
API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h handle, bool *mainapp)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (mainapp == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
char *val = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
val = (char *)info->uiapp_info->mainapp;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
+API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+ char *val = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ val = (char *)info->uiapp_info->preload;
+ if (val) {
+ if (strcasecmp(val, "true") == 0)
+ *preload = 1;
+ else if (strcasecmp(val, "false") == 0)
+ *preload = 0;
+ else
+ *preload = 0;
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+ char *val = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ val = (char *)info->uiapp_info->submode;
+ if (val) {
+ if (strcasecmp(val, "true") == 0)
+ *submode = 1;
+ else if (strcasecmp(val, "false") == 0)
+ *submode = 0;
+ else
+ *submode = 0;
}
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
__cleanup_appinfo(info);
return PMINFO_R_OK;
API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
const char *property, const int value)
{
- if (handle == NULL || property == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
char *val = NULL;
GSList *link = NULL;
API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
const char *property, const bool value)
{
- if (handle == NULL || property == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char *val = NULL;
GSList *link = NULL;
int prop = -1;
API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
const char *property, const char *value)
{
- if (handle == NULL || property == NULL || value == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char *val = NULL;
pkgmgrinfo_node_x *ptr = NULL;
char prev[PKG_STRING_LEN_MAX] = {'\0'};
API int pkgmgrinfo_appinfo_filter_count(pkgmgrinfo_appinfo_filter_h handle, int *count)
{
- if (handle == NULL || count == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(count == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char *syslocale = NULL;
char *locale = NULL;
char *condition = NULL;
free(syslocale);
return PMINFO_R_ERROR;
}
+
ret = __open_manifest_db();
if (ret == -1) {
_LOGE("Fail to open manifest DB\n");
API int pkgmgrinfo_appinfo_filter_foreach_appinfo(pkgmgrinfo_appinfo_filter_h handle,
pkgmgrinfo_app_list_cb app_cb, void * user_data)
{
- if (handle == NULL || app_cb == NULL) {
- _LOGE("Filter handle input parameter is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
char *syslocale = NULL;
char *locale = NULL;
char *condition = NULL;
free(syslocale);
return PMINFO_R_ERROR;
}
+
ret = __open_manifest_db();
if (ret == -1) {
_LOGE("Fail to open manifest DB\n");
/*If the callback func return < 0 we break and no more call back is called*/
while(ptr1 != NULL)
{
+ appinfo->locale = strdup(locale);
appinfo->uiapp_info = ptr1;
appinfo->app_component = PMINFO_UI_APP;
ret = app_cb((void *)appinfo, user_data);
/*If the callback func return < 0 we break and no more call back is called*/
while(ptr2 != NULL)
{
+ appinfo->locale = strdup(locale);
appinfo->svcapp_info = ptr2;
appinfo->app_component = PMINFO_SVC_APP;
ret = app_cb((void *)appinfo, user_data);
return ret;
}
-API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
+API int pkgmgrinfo_appinfo_metadata_filter_create(pkgmgrinfo_appinfo_metadata_filter_h *handle)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
+ return (pkgmgrinfo_pkginfo_filter_create(handle));
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_destroy(pkgmgrinfo_appinfo_metadata_filter_h handle)
+{
+ return (pkgmgrinfo_pkginfo_filter_destroy(handle));
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_add(pkgmgrinfo_appinfo_metadata_filter_h handle,
+ const char *key, const char *value)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
+ retvm_if(key == NULL, PMINFO_R_EINVAL, "metadata key supplied is NULL\n");
+ /*value can be NULL. In that case all apps with specified key should be displayed*/
+ int ret = 0;
+ char *k = NULL;
+ char *v = NULL;
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+ pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x*)calloc(1, sizeof(pkgmgrinfo_node_x));
+ retvm_if(node == NULL, PMINFO_R_ERROR, "Out of Memory!!!\n");
+ k = strdup(key);
+ tryvm_if(k == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+ node->key = k;
+ if (value) {
+ v = strdup(value);
+ tryvm_if(v == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+ }
+ node->value = v;
+ /*If API is called multiple times, we should OR all conditions.*/
+ filter->list = g_slist_append(filter->list, (gpointer)node);
+ /*All memory will be freed in destroy API*/
+ return PMINFO_R_OK;
+catch:
+ if (node) {
+ if (node->key) {
+ free(node->key);
+ node->key = NULL;
+ }
+ if (node->value) {
+ free(node->value);
+ node->value = NULL;
+ }
+ free(node);
+ node = NULL;
}
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
+ pkgmgrinfo_app_list_cb app_cb, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "filter handle is NULL\n");
+ retvm_if(app_cb == NULL, PMINFO_R_EINVAL, "Callback function supplied is NULL\n");
+ char *syslocale = NULL;
+ char *locale = NULL;
+ char *condition = NULL;
+ char *error_message = NULL;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ char where[MAX_QUERY_LEN] = {'\0'};
+ GSList *list;
int ret = 0;
+ pkgmgr_pkginfo_x *info = NULL;
+ pkgmgr_pkginfo_x *filtinfo = NULL;
+ pkgmgr_appinfo_x *appinfo = NULL;
+ uiapplication_x *ptr1 = NULL;
+ serviceapplication_x *ptr2 = NULL;
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+
+ /*Get current locale*/
+ syslocale = vconf_get_str(VCONFKEY_LANGSET);
+ retvm_if(syslocale == NULL, PMINFO_R_ERROR, "current locale is NULL\n");
+ locale = __convert_system_locale_to_manifest_locale(syslocale);
+ tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL\n");
+
+ ret = __open_manifest_db();
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Fail to open manifest DB\n");
+
+ /*Start constructing query*/
+ memset(where, '\0', MAX_QUERY_LEN);
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN - 1, METADATA_FILTER_QUERY_SELECT_CLAUSE);
+ /*Get where clause*/
+ for (list = filter->list; list; list = g_slist_next(list)) {
+ __get_metadata_filter_condition(list->data, &condition);
+ if (condition) {
+ strncat(where, condition, sizeof(where) - strlen(where) -1);
+ free(condition);
+ condition = NULL;
+ }
+ if (g_slist_next(list)) {
+ strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
+ }
+ }
+ _LOGE("where = %s (%d)\n", where, strlen(where));
+ if (strlen(where) > 0) {
+ strncat(query, where, sizeof(query) - strlen(query) - 1);
+ }
+ _LOGE("query = %s (%d)\n", query, strlen(query));
+ /*To get filtered list*/
+ info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
+ tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+
+ info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
+ tryvm_if(info->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+
+ /*To get detail app info for each member of filtered list*/
+ filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
+ tryvm_if(filtinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+
+ filtinfo->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
+ tryvm_if(filtinfo->manifest_info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+
+ appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+ tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
+
+ ret = sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message);
+ tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
+ memset(query, '\0', MAX_QUERY_LEN);
+
+ if (info->manifest_info->uiapplication) {
+ LISTHEAD(info->manifest_info->uiapplication, ptr1);
+ info->manifest_info->uiapplication = ptr1;
+ }
+ if (info->manifest_info->serviceapplication) {
+ LISTHEAD(info->manifest_info->serviceapplication, ptr2);
+ info->manifest_info->serviceapplication = ptr2;
+ }
+
+ /*UI Apps*/
+ for(ptr1 = info->manifest_info->uiapplication; ptr1; ptr1 = ptr1->next)
+ {
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
+ ptr1->appid, "uiapp");
+ ret = sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
+ tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
+ memset(query, '\0', MAX_QUERY_LEN);
+ }
+ /*Service Apps*/
+ for(ptr2 = info->manifest_info->serviceapplication; ptr2; ptr2 = ptr2->next)
+ {
+ snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
+ ptr2->appid, "svcapp");
+ ret = sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
+ tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
+ memset(query, '\0', MAX_QUERY_LEN);
+ }
+ /*Filtered UI Apps*/
+ if (filtinfo->manifest_info->uiapplication) {
+ LISTHEAD(filtinfo->manifest_info->uiapplication, ptr1);
+ filtinfo->manifest_info->uiapplication = ptr1;
+ }
+ /*If the callback func return < 0 we break and no more call back is called*/
+ while(ptr1 != NULL)
+ {
+ appinfo->locale = strdup(locale);
+ appinfo->uiapp_info = ptr1;
+ appinfo->app_component = PMINFO_UI_APP;
+ ret = app_cb((void *)appinfo, user_data);
+ if (ret < 0)
+ break;
+ ptr1 = ptr1->next;
+ }
+ /*Filtered Service Apps*/
+ if (filtinfo->manifest_info->serviceapplication) {
+ LISTHEAD(filtinfo->manifest_info->serviceapplication, ptr2);
+ filtinfo->manifest_info->serviceapplication = ptr2;
+ }
+ /*If the callback func return < 0 we break and no more call back is called*/
+ while(ptr2 != NULL)
+ {
+ appinfo->locale = strdup(locale);
+ appinfo->svcapp_info = ptr2;
+ appinfo->app_component = PMINFO_SVC_APP;
+ ret = app_cb((void *)appinfo, user_data);
+ if (ret < 0)
+ break;
+ ptr2 = ptr2->next;
+ }
+ ret = PMINFO_R_OK;
+catch:
+ if (locale) {
+ free(locale);
+ locale = NULL;
+ }
+ if (syslocale) {
+ free(syslocale);
+ syslocale = NULL;
+ }
+ sqlite3_free(error_message);
+ sqlite3_close(manifest_db);
+ if (appinfo) {
+ free(appinfo);
+ appinfo = NULL;
+ }
+ __cleanup_pkginfo(info);
+ __cleanup_pkginfo(filtinfo);
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_certinfo_x *certinfo = NULL;
certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
- if (!certinfo) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
*handle = (void *)certinfo;
- /*Open db. It will be closed in destroy handle API*/
- ret = db_util_open_with_options(CERT_DB, &cert_db,
- SQLITE_OPEN_READONLY, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", MANIFEST_DB);
- free(certinfo);
- return PMINFO_R_ERROR;
- }
return PMINFO_R_OK;
}
API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
{
- if (pkgid == NULL) {
- _LOGE("package ID is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (handle == NULL) {
- _LOGE("Certinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
pkgmgr_certinfo_x *certinfo = NULL;
char *error_message = NULL;
int ret = PMINFO_R_OK;
char query[MAX_QUERY_LEN] = {'\0'};
int exist = 0;
+ int i = 0;
+ /*Open db.*/
+ ret = db_util_open_with_options(CERT_DB, &cert_db,
+ SQLITE_OPEN_READONLY, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("connect db [%s] failed!\n", CERT_DB);
+ return PMINFO_R_ERROR;
+ }
/*validate pkgid*/
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
if (SQLITE_OK !=
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto err;
}
if (exist == 0) {
_LOGE("Package not found in DB\n");
ret = PMINFO_R_ERROR;
goto err;
}
- return PMINFO_R_OK;
-err:
- return ret;
-}
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
+ ret = __exec_certinfo_query(query, (void *)certinfo);
+ if (ret == -1) {
+ _LOGE("Cert Info DB Information retrieval failed\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ if (certinfo->cert_value) {
+ (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
+ free(certinfo->cert_value);
+ certinfo->cert_value = NULL;
+ }
+ }
+err:
+ sqlite3_close(cert_db);
+ return ret;
+}
API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
{
- if (!handle || !cert_value) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if ((cert_type < PMINFO_AUTHOR_ROOT_CERT) || (cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT)) {
- _LOGE("Invalid certificate type\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
+ retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
pkgmgr_certinfo_x *certinfo = NULL;
- char *error_message = NULL;
- int ret = PMINFO_R_OK;
- char query[MAX_QUERY_LEN] = {'\0'};
- int exist = 0;
certinfo = (pkgmgr_certinfo_x *)handle;
- *cert_value = NULL;
- switch(cert_type) {
- case PMINFO_AUTHOR_SIGNER_CERT:
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", certinfo->auth_signer_cert);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- *cert_value = certinfo->auth_signer_cert;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info " \
- "where package='%s'", certinfo->auth_signer_cert);
- free(certinfo->auth_signer_cert);
- certinfo->auth_signer_cert = NULL;
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- *cert_value = certinfo->auth_signer_cert;
- }
- break;
- case PMINFO_AUTHOR_INTERMEDIATE_CERT:
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", certinfo->auth_im_cert);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- *cert_value = certinfo->auth_im_cert;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select author_im_cert from package_cert_info " \
- "where package='%s'", certinfo->auth_im_cert);
- free(certinfo->auth_im_cert);
- certinfo->auth_im_cert = NULL;
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- *cert_value = certinfo->auth_im_cert;
- }
- break;
- case PMINFO_AUTHOR_ROOT_CERT:
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", certinfo->auth_root_cert);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- *cert_value = certinfo->auth_root_cert;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select author_root_cert from package_cert_info " \
- "where package='%s'", certinfo->auth_root_cert);
- free(certinfo->auth_root_cert);
- certinfo->auth_root_cert = NULL;
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- *cert_value = certinfo->auth_root_cert;
- }
- break;
- case PMINFO_DISTRIBUTOR_SIGNER_CERT:
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", certinfo->dist_signer_cert);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- *cert_value = certinfo->dist_signer_cert;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select dist_signer_cert from package_cert_info " \
- "where package='%s'", certinfo->dist_signer_cert);
- free(certinfo->dist_signer_cert);
- certinfo->dist_signer_cert = NULL;
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- *cert_value = certinfo->dist_signer_cert;
- }
- break;
- case PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT:
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", certinfo->dist_im_cert);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- *cert_value = certinfo->dist_im_cert;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select dist_im_cert from package_cert_info " \
- "where package='%s'", certinfo->dist_im_cert);
- free(certinfo->dist_im_cert);
- certinfo->dist_im_cert = NULL;
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- *cert_value = certinfo->dist_im_cert;
- }
- break;
- case PMINFO_DISTRIBUTOR_ROOT_CERT:
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", certinfo->dist_root_cert);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- *cert_value = certinfo->dist_root_cert;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select dist_root_cert from package_cert_info " \
- "where package='%s'", certinfo->dist_root_cert);
- free(certinfo->dist_root_cert);
- certinfo->dist_root_cert = NULL;
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- *cert_value = certinfo->dist_root_cert;
- }
- break;
- case PMINFO_DISTRIBUTOR2_SIGNER_CERT:
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", certinfo->dist2_signer_cert);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- *cert_value = certinfo->dist2_signer_cert;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select dist2_signer_cert from package_cert_info " \
- "where package='%s'", certinfo->dist2_signer_cert);
- free(certinfo->dist2_signer_cert);
- certinfo->dist2_signer_cert = NULL;
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- *cert_value = certinfo->dist2_signer_cert;
- }
- break;
- case PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT:
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", certinfo->dist2_im_cert);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- *cert_value = certinfo->dist2_im_cert;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select dist2_im_cert from package_cert_info " \
- "where package='%s'", certinfo->dist2_im_cert);
- free(certinfo->dist2_im_cert);
- certinfo->dist2_im_cert = NULL;
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- *cert_value = certinfo->dist2_im_cert;
- }
- break;
- case PMINFO_DISTRIBUTOR2_ROOT_CERT:
- snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", certinfo->dist2_root_cert);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- return PMINFO_R_ERROR;
- }
- if (exist == 0)
- *cert_value = certinfo->dist2_root_cert;
- else {
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select dist2_root_cert from package_cert_info " \
- "where package='%s'", certinfo->dist2_root_cert);
- free(certinfo->dist2_root_cert);
- certinfo->dist2_root_cert = NULL;
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- *cert_value = certinfo->dist2_root_cert;
- }
- break;
- }
+ if ((certinfo->cert_info)[cert_type])
+ *cert_value = (certinfo->cert_info)[cert_type];
+ else
+ *cert_value = NULL;
return PMINFO_R_OK;
}
API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ int i = 0;
pkgmgr_certinfo_x *certinfo = NULL;
certinfo = (pkgmgr_certinfo_x *)handle;
if (certinfo->pkgid) {
free(certinfo->pkgid);
certinfo->pkgid = NULL;
}
- if (certinfo->auth_signer_cert) {
- free(certinfo->auth_signer_cert);
- certinfo->auth_signer_cert = NULL;
- }
- if (certinfo->auth_im_cert) {
- free(certinfo->auth_im_cert);
- certinfo->auth_im_cert = NULL;
- }
- if (certinfo->auth_root_cert) {
- free(certinfo->auth_root_cert);
- certinfo->auth_root_cert = NULL;
- }
- if (certinfo->dist_signer_cert) {
- free(certinfo->dist_signer_cert);
- certinfo->dist_signer_cert = NULL;
- }
- if (certinfo->dist_im_cert) {
- free(certinfo->dist_im_cert);
- certinfo->dist_im_cert = NULL;
- }
- if (certinfo->dist_root_cert) {
- free(certinfo->dist_root_cert);
- certinfo->dist_root_cert = NULL;
- }
- if (certinfo->dist2_signer_cert) {
- free(certinfo->dist2_signer_cert);
- certinfo->dist2_signer_cert = NULL;
- }
- if (certinfo->dist2_im_cert) {
- free(certinfo->dist2_im_cert);
- certinfo->dist2_im_cert = NULL;
- }
- if (certinfo->dist2_root_cert) {
- free(certinfo->dist2_root_cert);
- certinfo->dist2_root_cert = NULL;
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ if ((certinfo->cert_info)[i]) {
+ free((certinfo->cert_info)[i]);
+ (certinfo->cert_info)[i] = NULL;
+ }
}
free(certinfo);
certinfo = NULL;
- sqlite3_close(cert_db);
return PMINFO_R_OK;
}
API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_instcertinfo_x *certinfo = NULL;
- int ret = 0;
certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
- if (!certinfo) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
*handle = (void *)certinfo;
- /*Open db. It will be closed in destroy handle API*/
- ret = db_util_open(CERT_DB, &cert_db,
- DB_UTIL_REGISTER_HOOK_METHOD);
- if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", CERT_DB);
- free(certinfo);
- return PMINFO_R_ERROR;
- }
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
{
- if (!handle || !cert_value) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if ((cert_type < PMINFO_SET_AUTHOR_ROOT_CERT) || (cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT)) {
- _LOGE("Invalid certificate type\n");
- return PMINFO_R_EINVAL;
- }
- char query[MAX_QUERY_LEN] = {'\0'};
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
+ retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
pkgmgr_instcertinfo_x *certinfo = NULL;
- int ret = 0;
certinfo = (pkgmgr_instcertinfo_x *)handle;
- switch(cert_type) {
- case PMINFO_SET_AUTHOR_SIGNER_CERT:
- snprintf(query, MAX_QUERY_LEN, "select package from package_cert_info " \
- "where author_signer_cert='%s'", cert_value);
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- if (certinfo->pkgid)
- certinfo->auth_signer_cert = strdup(certinfo->pkgid);
- else
- certinfo->auth_signer_cert = strdup(cert_value);
- break;
- case PMINFO_SET_AUTHOR_INTERMEDIATE_CERT:
- snprintf(query, MAX_QUERY_LEN, "select package from package_cert_info " \
- "where author_im_cert='%s'", cert_value);
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- if (certinfo->pkgid)
- certinfo->auth_im_cert = strdup(certinfo->pkgid);
- else
- certinfo->auth_im_cert = strdup(cert_value);
- break;
- case PMINFO_SET_AUTHOR_ROOT_CERT:
- snprintf(query, MAX_QUERY_LEN, "select package from package_cert_info " \
- "where author_root_cert='%s'", cert_value);
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- if (certinfo->pkgid)
- certinfo->auth_root_cert = strdup(certinfo->pkgid);
- else
- certinfo->auth_root_cert = strdup(cert_value);
- break;
- case PMINFO_SET_DISTRIBUTOR_SIGNER_CERT:
- snprintf(query, MAX_QUERY_LEN, "select package from package_cert_info " \
- "where dist_signer_cert='%s'", cert_value);
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- if (certinfo->pkgid)
- certinfo->dist_signer_cert = strdup(certinfo->pkgid);
- else
- certinfo->dist_signer_cert = strdup(cert_value);
- break;
- case PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT:
- snprintf(query, MAX_QUERY_LEN, "select package from package_cert_info " \
- "where dist_im_cert='%s'", cert_value);
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- if (certinfo->pkgid)
- certinfo->dist_im_cert = strdup(certinfo->pkgid);
- else
- certinfo->dist_im_cert = strdup(cert_value);
- break;
- case PMINFO_SET_DISTRIBUTOR_ROOT_CERT:
- snprintf(query, MAX_QUERY_LEN, "select package from package_cert_info " \
- "where dist_root_cert='%s'", cert_value);
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- if (certinfo->pkgid)
- certinfo->dist_root_cert = strdup(certinfo->pkgid);
- else
- certinfo->dist_root_cert = strdup(cert_value);
- break;
- case PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT:
- snprintf(query, MAX_QUERY_LEN, "select package from package_cert_info " \
- "where dist2_signer_cert='%s'", cert_value);
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- if (certinfo->pkgid)
- certinfo->dist2_signer_cert = strdup(certinfo->pkgid);
- else
- certinfo->dist2_signer_cert = strdup(cert_value);
- break;
- case PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT:
- snprintf(query, MAX_QUERY_LEN, "select package from package_cert_info " \
- "where dist2_im_cert='%s'", cert_value);
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- if (certinfo->pkgid)
- certinfo->dist2_im_cert = strdup(certinfo->pkgid);
- else
- certinfo->dist2_im_cert = strdup(cert_value);
- break;
- case PMINFO_SET_DISTRIBUTOR2_ROOT_CERT:
- snprintf(query, MAX_QUERY_LEN, "select package from package_cert_info " \
- "where dist2_root_cert='%s'", cert_value);
- ret = __exec_certinfo_query(query, (void *)certinfo);
- if (ret == -1) {
- _LOGE("Cert Info DB Information retrieval failed\n");
- return PMINFO_R_ERROR;
- }
- if (certinfo->pkgid)
- certinfo->dist2_root_cert = strdup(certinfo->pkgid);
- else
- certinfo->dist2_root_cert = strdup(cert_value);
- break;
- }
- if (certinfo->pkgid) {
- free(certinfo->pkgid);
- certinfo->pkgid = NULL;
- }
+ (certinfo->cert_info)[cert_type] = strdup(cert_value);
return PMINFO_R_OK;
}
API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
{
- if (!handle || !pkgid) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
- int ret = -1;
+ retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
char *error_message = NULL;
- int exist = -1;
char query[MAX_QUERY_LEN] = {'\0'};
char *vquery = NULL;
int len = 0;
+ int i = 0;
+ int j = 0;
+ int c = 0;
+ int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+ int newid = 0;
+ int is_new = 0;
+ int exist = -1;
+ int ret = -1;
+ int maxid = 0;
+ int flag = 0;
pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
+ pkgmgr_certindexinfo_x *indexinfo = NULL;
+ indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
+ if (indexinfo == NULL) {
+ _LOGE("Out of Memory!!!");
+ return PMINFO_R_ERROR;
+ }
info->pkgid = strdup(pkgid);
+
+ /*Open db.*/
+ ret = db_util_open_with_options(CERT_DB, &cert_db,
+ SQLITE_OPEN_READWRITE, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("connect db [%s] failed!\n", CERT_DB);
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ /*Begin Transaction*/
+ ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to begin transaction\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ _LOGE("Transaction Begin\n");
+ /*Check if request is to insert/update*/
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
if (SQLITE_OK !=
sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto err;
}
-
- len = 4096;
- if (info->auth_root_cert)
- len += strlen(info->auth_root_cert);
- if (info->auth_im_cert)
- len += strlen(info->auth_im_cert);
- if (info->auth_signer_cert)
- len += strlen(info->auth_signer_cert);
- if (info->dist_root_cert)
- len += strlen(info->dist_root_cert);
- if (info->dist_im_cert)
- len += strlen(info->dist_im_cert);
- if (info->dist_signer_cert)
- len += strlen(info->dist_signer_cert);
- if (info->dist2_root_cert)
- len += strlen(info->dist2_root_cert);
- if (info->dist2_im_cert)
- len += strlen(info->dist2_im_cert);
- if (info->dist2_signer_cert)
- len += strlen(info->dist2_signer_cert);
- vquery = (char *)calloc(1, len);
-
- if (exist == 0) {
- _LOGE("pkgid not found in DB\n");
- /*insert*/
- snprintf(vquery, len,
- "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
- "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
- "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
- info->pkgid, info->auth_root_cert, info->auth_im_cert, info->auth_signer_cert, info->dist_root_cert, info->dist_im_cert,
- info->dist_signer_cert, info->dist2_root_cert, info->dist2_im_cert, info->dist2_signer_cert);
- } else {
- _LOGE("pkgid exists in DB..Update it\n");
- /*Update*/
- snprintf(vquery, len,
- "update package_cert_info set author_root_cert='%s', author_im_cert='%s', author_signer_cert='%s', dist_root_cert='%s', " \
- "dist_im_cert='%s', dist_signer_cert='%s', dist2_root_cert='%s', dist2_im_cert='%s', dist2_signer_cert='%s' " \
- "where package='%s'",\
- info->auth_root_cert, info->auth_im_cert, info->auth_signer_cert, info->dist_root_cert, info->dist_im_cert,
- info->dist_signer_cert, info->dist2_root_cert, info->dist2_im_cert, info->dist2_signer_cert, info->pkgid);
+ if (exist) {
+ /*Update request.
+ We cant just issue update query directly. We need to manage index table also.
+ Hence it is better to delete and insert again in case of update*/
+ ret = __delete_certinfo(pkgid);
+ if (ret < 0)
+ _LOGE("Certificate Deletion Failed\n");
+ }
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ if ((info->cert_info)[i]) {
+ for (j = 0; j < i; j++) {
+ if ( (info->cert_info)[j]) {
+ if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
+ (info->cert_id)[i] = (info->cert_id)[j];
+ (info->is_new)[i] = 0;
+ (info->ref_count)[i] = (info->ref_count)[j];
+ break;
+ }
+ }
+ }
+ if (j < i)
+ continue;
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
+ "where cert_info='%s'",(info->cert_info)[i]);
+ ret = __exec_certindexinfo_query(query, (void *)indexinfo);
+ if (ret == -1) {
+ _LOGE("Cert Info DB Information retrieval failed\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ if (indexinfo->cert_id == 0) {
+ /*New certificate. Get newid*/
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
+ if (SQLITE_OK !=
+ sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
+ _LOGE("Don't execute query = %s error message = %s\n", query,
+ error_message);
+ sqlite3_free(error_message);
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ newid = newid + 1;
+ if (flag == 0) {
+ maxid = newid;
+ flag = 1;
+ }
+ indexinfo->cert_id = maxid;
+ indexinfo->cert_ref_count = 1;
+ is_new = 1;
+ maxid = maxid + 1;
+ }
+ (info->cert_id)[i] = indexinfo->cert_id;
+ (info->is_new)[i] = is_new;
+ (info->ref_count)[i] = indexinfo->cert_ref_count;
+ _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
+ indexinfo->cert_id = 0;
+ indexinfo->cert_ref_count = 0;
+ is_new = 0;
+ }
}
+ len = MAX_QUERY_LEN;
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ if ((info->cert_info)[i])
+ len+= strlen((info->cert_info)[i]);
+ }
+ vquery = (char *)calloc(1, len);
+ /*insert*/
+ snprintf(vquery, len,
+ "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
+ "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
+ "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
+ info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
+ (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
+ (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
+ (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
+ (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
if (SQLITE_OK !=
sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", vquery,
error_message);
sqlite3_free(error_message);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto err;
}
- return PMINFO_R_OK;
+ /*Update index table info*/
+ /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ if ((info->cert_info)[i]) {
+ memset(vquery, '\0', len);
+ if ((info->is_new)[i]) {
+ snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
+ "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
+ unique_id[c++] = (info->cert_id)[i];
+ } else {
+ /*Update*/
+ for (j = 0; j < MAX_CERT_TYPE; j++) {
+ if ((info->cert_id)[i] == unique_id[j]) {
+ /*Ref count has already been increased. Just continue*/
+ break;
+ }
+ }
+ if (j == MAX_CERT_TYPE)
+ unique_id[c++] = (info->cert_id)[i];
+ else
+ continue;
+ snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
+ "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
+ }
+ if (SQLITE_OK !=
+ sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
+ _LOGE("Don't execute query = %s error message = %s\n", vquery,
+ error_message);
+ sqlite3_free(error_message);
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ }
+ }
+ /*Commit transaction*/
+ ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to commit transaction, Rollback now\n");
+ sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ _LOGE("Transaction Commit and End\n");
+ ret = PMINFO_R_OK;
+err:
+ sqlite3_close(cert_db);
+ if (vquery) {
+ free(vquery);
+ vquery = NULL;
+ }
+ if (indexinfo) {
+ free(indexinfo);
+ indexinfo = NULL;
+ }
+ return ret;
}
API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ int i = 0;
pkgmgr_instcertinfo_x *certinfo = NULL;
certinfo = (pkgmgr_instcertinfo_x *)handle;
if (certinfo->pkgid) {
free(certinfo->pkgid);
certinfo->pkgid = NULL;
}
- if (certinfo->auth_signer_cert) {
- free(certinfo->auth_signer_cert);
- certinfo->auth_signer_cert = NULL;
- }
- if (certinfo->auth_im_cert) {
- free(certinfo->auth_im_cert);
- certinfo->auth_im_cert = NULL;
- }
- if (certinfo->auth_root_cert) {
- free(certinfo->auth_root_cert);
- certinfo->auth_root_cert = NULL;
- }
- if (certinfo->dist_signer_cert) {
- free(certinfo->dist_signer_cert);
- certinfo->dist_signer_cert = NULL;
- }
- if (certinfo->dist_im_cert) {
- free(certinfo->dist_im_cert);
- certinfo->dist_im_cert = NULL;
- }
- if (certinfo->dist_root_cert) {
- free(certinfo->dist_root_cert);
- certinfo->dist_root_cert = NULL;
- }
- if (certinfo->dist2_signer_cert) {
- free(certinfo->dist2_signer_cert);
- certinfo->dist2_signer_cert = NULL;
- }
- if (certinfo->dist2_im_cert) {
- free(certinfo->dist2_im_cert);
- certinfo->dist2_im_cert = NULL;
- }
- if (certinfo->dist2_root_cert) {
- free(certinfo->dist2_root_cert);
- certinfo->dist2_root_cert = NULL;
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ if ((certinfo->cert_info)[i]) {
+ free((certinfo->cert_info)[i]);
+ (certinfo->cert_info)[i] = NULL;
+ }
}
free(certinfo);
certinfo = NULL;
- sqlite3_close(cert_db);
return PMINFO_R_OK;
}
API int pkgmgrinfo_delete_certinfo(const char *pkgid)
{
- if (!pkgid) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
int ret = -1;
- int i = 0;
- char *error_message = NULL;
- char query[MAX_QUERY_LEN] = {'\0'};
- ret = db_util_open(CERT_DB, &cert_db,
- DB_UTIL_REGISTER_HOOK_METHOD);
+ /*Open db.*/
+ ret = db_util_open_with_options(CERT_DB, &cert_db,
+ SQLITE_OPEN_READWRITE, NULL);
if (ret != SQLITE_OK) {
_LOGE("connect db [%s] failed!\n", CERT_DB);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto err;
}
- /*First make copy of all entries for which other packages have an index here*/
- snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package!='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __delete_certinfo_cb, (void *)pkgid, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(cert_db);
+ /*Begin Transaction*/
+ ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to begin transaction\n");
ret = PMINFO_R_ERROR;
goto err;
- }
- /*Now delete the entry from db*/
- snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- sqlite3_free(error_message);
- sqlite3_close(cert_db);
+ }
+ _LOGE("Transaction Begin\n");
+ ret = __delete_certinfo(pkgid);
+ if (ret < 0) {
+ _LOGE("Certificate Deletion Failed\n");
+ } else {
+ _LOGE("Certificate Deletion Success\n");
+ }
+ /*Commit transaction*/
+ ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to commit transaction, Rollback now\n");
+ sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
ret = PMINFO_R_ERROR;
goto err;
- }
+ }
+ _LOGE("Transaction Commit and End\n");
ret = PMINFO_R_OK;
err:
sqlite3_close(cert_db);
- for (i = 0; i < 9; i++) {
- gflag[i] = 0;
- if (gpkgcert[i]) {
- free(gpkgcert[i]);
- gpkgcert[i] = NULL;
- }
- }
return ret;
}
API int pkgmgrinfo_create_pkgdbinfo(const char *pkgid, pkgmgrinfo_pkgdbinfo_h *handle)
{
- if (!pkgid || !handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!pkgid, PMINFO_R_EINVAL, "pkgid is NULL");
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
+ char *manifest = NULL;
manifest_x *mfx = NULL;
- mfx = calloc(1, sizeof(manifest_x));
- if (!mfx) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
+
+ manifest = pkgmgr_parser_get_manifest_file(pkgid);
+ retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
+
+ mfx = pkgmgr_parser_process_manifest_xml(manifest);
+ if (manifest) {
+ free(manifest);
+ manifest = NULL;
}
- mfx->package = strdup(pkgid);
+ retvm_if(mfx == NULL, PMINFO_R_EINVAL, "pkg[%s] parsing fail", pkgid);
+
*handle = (void *)mfx;
+
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_type_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *type)
{
- if (!type || !handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!type, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
int len = strlen(type);
+ retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_TYPE_STRING_LEN_MAX) {
- _LOGE("pkg type length exceeds the max limit\n");
- return PMINFO_R_EINVAL;
- }
- if (mfx->type == NULL)
- mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
- else
- mfx->type = type;
+ mfx->type = strndup(type, PKG_TYPE_STRING_LEN_MAX);
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_version_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *version)
{
- if (!version || !handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!version, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
int len = strlen(version);
+ retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_VERSION_STRING_LEN_MAX) {
- _LOGE("pkg version length exceeds the max limit\n");
- return PMINFO_R_EINVAL;
- }
- if (mfx->version == NULL)
- mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
- else
- mfx->version = version;
+ mfx->version = strndup(version, PKG_VERSION_STRING_LEN_MAX);
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_install_location_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (location < 0 || location > 1) {
- _LOGE("Argument supplied is invalid\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
+
manifest_x *mfx = (manifest_x *)handle;
- if (mfx->installlocation == NULL) {
- mfx->installlocation = (char *)calloc(1, strlen("prefer-external"));
- if (mfx->installlocation == NULL) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
- }
- }
- if (location == INSTALL_INTERNAL) {
+
+ if (location == INSTALL_INTERNAL)
strcpy(mfx->installlocation, "internal-only");
- } else if (location == INSTALL_EXTERNAL) {
+ else if (location == INSTALL_EXTERNAL)
strcpy(mfx->installlocation, "prefer-external");
- } else {
- _LOGE("Invalid location type\n");
- return PMINFO_R_ERROR;
- }
+
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_size_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *size)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (size == NULL) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
manifest_x *mfx = (manifest_x *)handle;
- if (mfx->installlocation == NULL) {
- _LOGE("cant set size without specifying install location\n");
- return PMINFO_R_ERROR;
- }
- if (strcmp(mfx->installlocation, "prefer-external") == 0) {
- if (mfx->package_size == NULL)
- mfx->package_size = strdup(size);
- else
- mfx->package_size = size;
- } else {
- _LOGE("cant set size for internal location\n");
- return PMINFO_R_ERROR;
- }
+
+ mfx->package_size = strdup(size);
+
return PMINFO_R_OK;
}
+
API int pkgmgrinfo_set_label_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *label_txt, const char *locale)
{
- if (!handle || !label_txt) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if(!label_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
int len = strlen(label_txt);
+ retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_VALUE_STRING_LEN_MAX) {
- _LOGE("label length exceeds the max limit\n");
- return PMINFO_R_EINVAL;
- }
+
label_x *label = calloc(1, sizeof(label_x));
- if (label == NULL) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(label == NULL, PMINFO_R_EINVAL, "Malloc Failed");
+
LISTADD(mfx->label, label);
if (locale)
mfx->label->lang = strdup(locale);
API int pkgmgrinfo_set_icon_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *icon_txt, const char *locale)
{
- if (!handle || !icon_txt) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if(!icon_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
int len = strlen(icon_txt);
+ retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_VALUE_STRING_LEN_MAX) {
- _LOGE("icon length exceeds the max limit\n");
- return PMINFO_R_EINVAL;
- }
+
icon_x *icon = calloc(1, sizeof(icon_x));
- if (icon == NULL) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(icon == NULL, PMINFO_R_EINVAL, "Malloc Failed");
+
LISTADD(mfx->icon, icon);
if (locale)
mfx->icon->lang = strdup(locale);
API int pkgmgrinfo_set_description_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *desc_txt, const char *locale)
{
- if (!handle || !desc_txt) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if(!desc_txt, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
int len = strlen(desc_txt);
+ retvm_if(len > PKG_TYPE_STRING_LEN_MAX, PMINFO_R_EINVAL, "pkg type length exceeds the max limit");
+
manifest_x *mfx = (manifest_x *)handle;
- if (len > PKG_VALUE_STRING_LEN_MAX) {
- _LOGE("description length exceeds the max limit\n");
- return PMINFO_R_EINVAL;
- }
+
description_x *description = calloc(1, sizeof(description_x));
- if (description == NULL) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(description == NULL, PMINFO_R_EINVAL, "Malloc Failed");
+
LISTADD(mfx->description, description);
if (locale)
mfx->description->lang = strdup(locale);
API int pkgmgrinfo_set_author_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, const char *author_name,
const char *author_email, const char *author_href, const char *locale)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
manifest_x *mfx = (manifest_x *)handle;
author_x *author = calloc(1, sizeof(author_x));
- if (author == NULL) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
- }
+ retvm_if(author == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
LISTADD(mfx->author, author);
if (author_name)
mfx->author->text = strdup(author_name);
API int pkgmgrinfo_set_removable_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int removable)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (removable < 0 || removable > 1) {
- _LOGE("Argument supplied is invalid\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if((removable < 0) || (removable > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
+
manifest_x *mfx = (manifest_x *)handle;
- if (mfx->removable == NULL) {
- mfx->removable = (char *)calloc(1, strlen("false"));
- if (mfx->removable == NULL) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
- }
- }
- if (removable == 0) {
+
+ if (removable == 0)
strcpy(mfx->removable, "false");
- } else if (removable == 1) {
+ else if (removable == 1)
strcpy(mfx->removable, "true");
- } else {
- _LOGE("Invalid removable type\n");
- return PMINFO_R_ERROR;
- }
+
return PMINFO_R_OK;
}
API int pkgmgrinfo_set_preload_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, int preload)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (preload < 0 || preload > 1) {
- _LOGE("Argument supplied is invalid\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if((preload < 0) || (preload > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
+
manifest_x *mfx = (manifest_x *)handle;
- if (mfx->preload == NULL) {
- mfx->preload = (char *)calloc(1, strlen("false"));
- if (mfx->preload == NULL) {
- _LOGE("Malloc Failed\n");
- return PMINFO_R_ERROR;
- }
- }
- if (preload == 0) {
+
+ if (preload == 0)
strcpy(mfx->preload, "false");
- } else if (preload == 1) {
+ else if (preload == 1)
strcpy(mfx->preload, "true");
- } else {
- _LOGE("Invalid preload type\n");
- return PMINFO_R_ERROR;
- }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_set_installed_storage_to_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle, INSTALL_LOCATION location)
+{
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+ retvm_if((location < 0) || (location > 1), PMINFO_R_EINVAL, "Argument supplied is NULL");
+
+ manifest_x *mfx = (manifest_x *)handle;
+
+ if (location == INSTALL_INTERNAL)
+ strcpy(mfx->installed_storage, "installed_internal");
+ else if (location == INSTALL_EXTERNAL)
+ strcpy(mfx->installed_storage, "installed_external");
+
return PMINFO_R_OK;
}
API int pkgmgrinfo_save_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
int ret = 0;
manifest_x *mfx = NULL;
- label_x *tmp1 = NULL;
- icon_x *tmp2 = NULL;
- description_x *tmp3 = NULL;
- author_x *tmp4 = NULL;
mfx = (manifest_x *)handle;
- /*First move to head of all list pointers*/
- if (mfx->label) {
- LISTHEAD(mfx->label, tmp1);
- mfx->label = tmp1;
- }
- if (mfx->icon) {
- LISTHEAD(mfx->icon, tmp2);
- mfx->icon = tmp2;
- }
- if (mfx->description) {
- LISTHEAD(mfx->description, tmp3);
- mfx->description= tmp3;
- }
- if (mfx->author) {
- LISTHEAD(mfx->author, tmp4);
- mfx->author = tmp4;
- }
- ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
+
+ ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
if (ret == 0) {
_LOGE("Successfully stored info in DB\n");
return PMINFO_R_OK;
API int pkgmgrinfo_destroy_pkgdbinfo(pkgmgrinfo_pkgdbinfo_h handle)
{
- if (!handle) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(!handle, PMINFO_R_EINVAL, "Argument supplied is NULL");
+
manifest_x *mfx = NULL;
mfx = (manifest_x *)handle;
pkgmgr_parser_free_manifest_xml(mfx);
return PMINFO_R_OK;
}
-API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
+API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
{
- if (providerid == NULL) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
+ /* Should be implemented later */
+ return 0;
+}
+
+API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
+{
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ ret = __open_manifest_db();
+
+ if (access(MANIFEST_DB, F_OK) == 0) {
+ ret = db_util_open(MANIFEST_DB, &manifest_db,
+ DB_UTIL_REGISTER_HOOK_METHOD);
+ if (ret != SQLITE_OK) {
+ _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
+ return PMINFO_R_ERROR;
+ }
}
- if (type == NULL) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
+
+ /*Begin transaction*/
+ ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to begin transaction\n");
+ sqlite3_close(manifest_db);
+ return PMINFO_R_ERROR;
}
- if (appid == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
+ _LOGD("Transaction Begin\n");
+
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN,
+ "update package_app_info set app_enabled='%s' where app_id='%s'", enabled?"true":"false", appid);
+
+ char *error_message = NULL;
+ if (SQLITE_OK !=
+ sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
+ _LOGE("Don't execute query = %s error message = %s\n", query,
+ error_message);
+ sqlite3_free(error_message);
+ return PMINFO_R_ERROR;
}
- if (access == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
+ sqlite3_free(error_message);
+
+ /*Commit transaction*/
+ ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to commit transaction. Rollback now\n");
+ sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
+ sqlite3_close(manifest_db);
+ return PMINFO_R_ERROR;
}
+ _LOGD("Transaction Commit and End\n");
+ sqlite3_close(manifest_db);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
+{
+ retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+ retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
int ret = PMINFO_R_OK;
char query[MAX_QUERY_LEN] = {'\0'};
char *error_message = NULL;
return PMINFO_R_OK;
}
+
+API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
+{
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ char *error_message = NULL;
+ ret = __open_manifest_db();
+
+ if (access(MANIFEST_DB, F_OK) == 0) {
+ ret = db_util_open(MANIFEST_DB, &manifest_db,
+ DB_UTIL_REGISTER_HOOK_METHOD);
+ if (ret != SQLITE_OK) {
+ _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ /*Begin transaction*/
+ ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to begin transaction\n");
+ sqlite3_close(manifest_db);
+ return PMINFO_R_ERROR;
+ }
+ _LOGD("Transaction Begin\n");
+
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN,
+ "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
+
+ if (SQLITE_OK !=
+ sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
+ _LOGE("Don't execute query = %s error message = %s\n", query,
+ error_message);
+ sqlite3_free(error_message);
+ return PMINFO_R_ERROR;
+ }
+
+ /*Commit transaction*/
+ ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to commit transaction. Rollback now\n");
+ sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
+ sqlite3_close(manifest_db);
+ return PMINFO_R_ERROR;
+ }
+ _LOGD("Transaction Commit and End\n");
+ sqlite3_close(manifest_db);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+ char *val = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ val = (char *)info->uiapp_info->guestmode_visibility;
+ if (val) {
+ if (strcasecmp(val, "true") == 0){
+ *status = 1;
+ }else if (strcasecmp(val, "false") == 0){
+ *status = 0;
+ }else{
+ *status = 1;
+ }
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ char *val = NULL;
+ int ret = 0;
+ char *noti_string = NULL;
+ int len = 0;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ char *errmsg = NULL;
+ sqlite3 *pkgmgr_parser_db;
+
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ val = (char *)info->uiapp_info->guestmode_visibility;
+ if (val ) {
+ ret =
+ db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db,
+ SQLITE_OPEN_READWRITE, NULL);
+
+ if (ret != SQLITE_OK) {
+ _LOGE("DB Open Failed\n");
+ return PMINFO_R_ERROR;
+ }
+
+ /*TODO: Write to DB here*/
+ if (status == true)
+ snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
+ else
+ snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
+
+ if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
+ _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
+ free(errmsg);
+ sqlite3_close(pkgmgr_parser_db);
+ return PMINFO_R_ERROR;
+ }else{
+ sqlite3_close(pkgmgr_parser_db);
+ len = strlen((char *)info->uiapp_info->appid) + 8;
+ noti_string = calloc(1, len);
+ if (noti_string == NULL){
+ return PMINFO_R_ERROR;
+ }
+ snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
+ vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
+ vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
+ free(noti_string);
+ }
+ }
+ return PMINFO_R_OK;
+}