void *user_data);
/**
+ * @fn int (*pkgmgrinfo_pkg_privilege_list_cb ) (const char *privilege_name, void *user_data)
+ *
+ * @brief Specifies the type of function passed to pkgmgrinfo_pkginfo_foreach_privilege()
+ *
+ * @param[in] privilege_name the name of the privilege
+ * @param[in] user_data user data passed to pkgmgrinfo_pkginfo_foreach_privilege()
+ *
+ * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative.\n
+ *
+ * @see pkgmgrinfo_pkginfo_foreach_privilege()
+ */
+typedef int (*pkgmgrinfo_pkg_privilege_list_cb ) (const char *privilege_name,
+ void *user_data);
+
+/**
* @fn int (*pkgmgrinfo_app_metadata_list_cb ) (const char *metadata_key, const char *metadata_value, void *user_data)
*
* @brief Specifies the type of function passed to pkgmgrinfo_appinfo_foreach_metadata()
int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count);
/**
+ * @fn int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data);
+ * @brief This API gets the list of privilege for a particular package
+ *
+ * @par This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ * @param[in] handle pointer to the package info handle.
+ * @param[in] privilege_func callback function for list
+ * @param[in] user_data user data to be passed to callback function
+ * @return 0 if success, error code(<0) if fail
+ * @retval PMINFO_R_OK success
+ * @retval PMINFO_R_EINVAL invalid argument
+ * @retval PMINFO_R_ERROR internal error
+ * @pre pkgmgrinfo_pkginfo_get_pkginfo()
+ * @post pkgmgrinfo_pkginfo_destroy_pkginfo()
+ * @code
+int privilege_func(const char *name, void *user_data)
+{
+ if (strcmp(name, (char *)user_data) == 0)
+ return -1;
+ else
+ return 0;
+}
+
+static int list_privilege(const char *package, char *privilege)
+{
+ int ret = 0;
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(package, &handle);
+ if (ret != PMINFO_R_OK)
+ return -1;
+ ret = pkgmgrinfo_pkginfo_foreach_privilege(handle, privilege_func, (void *)privilege);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return -1;
+ }
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data);
+
+/**
* @fn int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
pkgmgrinfo_app_list_cb app_func, void *user_data)
* @brief This API gets list of installed applications for a particular package
Name: pkgmgr-info
Summary: Packager Manager infomation api for package
-Version: 0.0.92
+Version: 0.0.95
Release: 1
Group: Application Framework/Package Management
License: Apache-2.0
%setup -q
%build
-%cmake .
+%cmake .
make %{?jobs:-j%jobs}
%install
<xs:element name="ime">
</xs:element>
<xs:element name="privileges">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:choice maxOccurs="unbounded" minOccurs="0">
+ <xs:element ref="packages:privilege"/>
+ </xs:choice>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="privilege">
</xs:element>
<xs:element name="font">
<xs:complexType>
* limitations under the License.
*
*/
-
+#define _GNU_SOURCE
#include <dlfcn.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <time.h>
+#include <string.h>
#include <libxml/parser.h>
#include <libxml/xmlreader.h>
#include <libxml/xmlschemas.h>
ACTION_MAX
} ACTION_TYPE;
-char *package;
+const char *package;
static int __ps_process_label(xmlTextReaderPtr reader, label_x *label);
+static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege);
+static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges);
static int __ps_process_deviceprofile(xmlTextReaderPtr reader, deviceprofile_x *deviceprofile);
static int __ps_process_allowed(xmlTextReaderPtr reader, allowed_x *allowed);
static int __ps_process_operation(xmlTextReaderPtr reader, operation_x *operation);
static int __ps_process_resolution(xmlTextReaderPtr reader, resolution_x *resolution);
static int __ps_process_request(xmlTextReaderPtr reader, request_x *request);
static int __ps_process_define(xmlTextReaderPtr reader, define_x *define);
-static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry);
-static int __ps_process_database(xmlTextReaderPtr reader, database_x *database);
static int __ps_process_appsvc(xmlTextReaderPtr reader, appsvc_x *appsvc);
static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions);
static int __ps_process_datashare(xmlTextReaderPtr reader, datashare_x *datashare);
-static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout);
static int __ps_process_icon(xmlTextReaderPtr reader, icon_x *icon);
static int __ps_process_author(xmlTextReaderPtr reader, author_x *author);
static int __ps_process_description(xmlTextReaderPtr reader, description_x *description);
static int __ps_process_daemon(xmlTextReaderPtr reader, daemon_x *daemon);
static int __ps_process_ime(xmlTextReaderPtr reader, ime_x *ime);
static void __ps_free_label(label_x *label);
+static void __ps_free_privilege(privilege_x *privilege);
+static void __ps_free_privileges(privileges_x *privileges);
static void __ps_free_deviceprofile(deviceprofile_x * deviceprofile);
static void __ps_free_allowed(allowed_x *allowed);
static void __ps_free_operation(operation_x *operation);
static void __ps_free_resolution(resolution_x *resolution);
static void __ps_free_request(request_x *request);
static void __ps_free_define(define_x *define);
-static void __ps_free_registry(registry_x *registry);
-static void __ps_free_database(database_x *database);
static void __ps_free_appsvc(appsvc_x *appsvc);
static void __ps_free_launchconditions(launchconditions_x *launchconditions);
static void __ps_free_datashare(datashare_x *datashare);
-static void __ps_free_layout(layout_x *layout);
static void __ps_free_icon(icon_x *icon);
static void __ps_free_author(author_x *author);
static void __ps_free_description(description_x *description);
if (temp == NULL)
return -1;
xmlNode *next_node = NULL;
- while(cur_node != NULL)
- {
- if ( (strcmp(temp->name, cur_node->name) == 0) &&
+ while(cur_node != NULL) {
+ if ( (strcmp(ASCII(temp->name), ASCII(cur_node->name)) == 0) &&
(temp->line == cur_node->line) ) {
break;
}
fclose(fp);
#endif
- ret = __ps_run_parser(copyDocPtr, name, action, pkgid);
+ ret = __ps_run_parser(copyDocPtr, ASCII(name), action, pkgid);
END:
return ret;
else {
i = 0;
for (tag = tagv[0]; tag; tag = tagv[++i])
- if (strcmp(tag, elementName) == 0) {
+ if (strcmp(tag, ASCII(elementName)) == 0) {
DBG("__run_parser_prestep tag[%s] pkgid[%s]\n", tag, pkgid);
__run_parser_prestep(reader,
action, pkgid);
category = NULL;
}
+static void __ps_free_privilege(privilege_x *privilege)
+{
+ if (privilege == NULL)
+ return;
+ if (privilege->text) {
+ free((void *)privilege->text);
+ privilege->text = NULL;
+ }
+ free((void*)privilege);
+ privilege = NULL;
+}
+
+static void __ps_free_privileges(privileges_x *privileges)
+{
+ if (privileges == NULL)
+ return;
+ /*Free Privilege*/
+ if (privileges->privilege) {
+ privilege_x *privilege = privileges->privilege;
+ privilege_x *tmp = NULL;
+ while(privilege != NULL) {
+ tmp = privilege->next;
+ __ps_free_privilege(privilege);
+ privilege = tmp;
+ }
+ }
+ free((void*)privileges);
+ privileges = NULL;
+}
+
static void __ps_free_metadata(metadata_x *metadata)
{
if (metadata == NULL)
if (capability->resolution) {
resolution_x *resolution = capability->resolution;
resolution_x *tmp = NULL;
- while(resolution != NULL)
- {
+ while(resolution != NULL) {
tmp = resolution->next;
__ps_free_resolution(resolution);
resolution = tmp;
if (datacontrol->capability) {
capability_x *capability = datacontrol->capability;
capability_x *tmp = NULL;
- while(capability != NULL)
- {
+ while(capability != NULL) {
tmp = capability->next;
__ps_free_capability(capability);
capability = tmp;
if (launchconditions->condition) {
condition_x *condition = launchconditions->condition;
condition_x *tmp = NULL;
- while(condition != NULL)
- {
+ while(condition != NULL) {
tmp = condition->next;
__ps_free_condition(condition);
condition = tmp;
if (appcontrol->operation) {
operation_x *operation = appcontrol->operation;
operation_x *tmp = NULL;
- while(operation != NULL)
- {
+ while(operation != NULL) {
tmp = operation->next;
__ps_free_operation(operation);
operation = tmp;
if (appcontrol->uri) {
uri_x *uri = appcontrol->uri;
uri_x *tmp = NULL;
- while(uri != NULL)
- {
+ while(uri != NULL) {
tmp = uri->next;
__ps_free_uri(uri);
uri = tmp;
if (appcontrol->mime) {
mime_x *mime = appcontrol->mime;
mime_x *tmp = NULL;
- while(mime != NULL)
- {
+ while(mime != NULL) {
tmp = mime->next;
__ps_free_mime(mime);
mime = tmp;
if (appcontrol->subapp) {
subapp_x *subapp = appcontrol->subapp;
subapp_x *tmp = NULL;
- while(subapp != NULL)
- {
+ while(subapp != NULL) {
tmp = subapp->next;
__ps_free_subapp(subapp);
subapp = tmp;
if (appsvc->operation) {
operation_x *operation = appsvc->operation;
operation_x *tmp = NULL;
- while(operation != NULL)
- {
+ while(operation != NULL) {
tmp = operation->next;
__ps_free_operation(operation);
operation = tmp;
if (appsvc->uri) {
uri_x *uri = appsvc->uri;
uri_x *tmp = NULL;
- while(uri != NULL)
- {
+ while(uri != NULL) {
tmp = uri->next;
__ps_free_uri(uri);
uri = tmp;
if (appsvc->mime) {
mime_x *mime = appsvc->mime;
mime_x *tmp = NULL;
- while(mime != NULL)
- {
+ while(mime != NULL) {
tmp = mime->next;
__ps_free_mime(mime);
mime = tmp;
if (appsvc->subapp) {
subapp_x *subapp = appsvc->subapp;
subapp_x *tmp = NULL;
- while(subapp != NULL)
- {
+ while(subapp != NULL) {
tmp = subapp->next;
__ps_free_subapp(subapp);
subapp = tmp;
if (define->request) {
request_x *request = define->request;
request_x *tmp = NULL;
- while(request != NULL)
- {
+ while(request != NULL) {
tmp = request->next;
__ps_free_request(request);
request = tmp;
if (define->allowed) {
allowed_x *allowed = define->allowed;
allowed_x *tmp = NULL;
- while(allowed != NULL)
- {
+ while(allowed != NULL) {
tmp = allowed->next;
__ps_free_allowed(allowed);
allowed = tmp;
define = NULL;
}
-static void __ps_free_registry(registry_x *registry)
-{
- if (registry == NULL)
- return;
- if (registry->name) {
- free((void *)registry->name);
- registry->name = NULL;
- }
- if (registry->text) {
- free((void *)registry->text);
- registry->text = NULL;
- }
- free((void*)registry);
- registry = NULL;
-}
-
-static void __ps_free_database(database_x *database)
-{
- if (database == NULL)
- return;
- if (database->name) {
- free((void *)database->name);
- database->name = NULL;
- }
- if (database->text) {
- free((void *)database->text);
- database->text = NULL;
- }
- free((void*)database);
- database = NULL;
-}
-
static void __ps_free_datashare(datashare_x *datashare)
{
if (datashare == NULL)
if (datashare->define) {
define_x *define = datashare->define;
define_x *tmp = NULL;
- while(define != NULL)
- {
+ while(define != NULL) {
tmp = define->next;
__ps_free_define(define);
define = tmp;
if (datashare->request) {
request_x *request = datashare->request;
request_x *tmp = NULL;
- while(request != NULL)
- {
+ while(request != NULL) {
tmp = request->next;
__ps_free_request(request);
request = tmp;
datashare = NULL;
}
-static void __ps_free_layout(layout_x *layout)
-{
- if (layout == NULL)
- return;
- if (layout->name) {
- free((void *)layout->name);
- layout->name = NULL;
- }
- if (layout->text) {
- free((void *)layout->text);
- layout->text = NULL;
- }
- free((void*)layout);
- layout = NULL;
-}
-
static void __ps_free_label(label_x *label)
{
if (label == NULL)
if (uiapplication->label) {
label_x *label = uiapplication->label;
label_x *tmp = NULL;
- while(label != NULL)
- {
+ while(label != NULL) {
tmp = label->next;
__ps_free_label(label);
label = tmp;
if (uiapplication->icon) {
icon_x *icon = uiapplication->icon;
icon_x *tmp = NULL;
- while(icon != NULL)
- {
+ while(icon != NULL) {
tmp = icon->next;
__ps_free_icon(icon);
icon = tmp;
if (uiapplication->image) {
image_x *image = uiapplication->image;
image_x *tmp = NULL;
- while(image != NULL)
- {
+ while(image != NULL) {
tmp = image->next;
__ps_free_image(image);
image = tmp;
if (uiapplication->appcontrol) {
appcontrol_x *appcontrol = uiapplication->appcontrol;
appcontrol_x *tmp = NULL;
- while(appcontrol != NULL)
- {
+ while(appcontrol != NULL) {
tmp = appcontrol->next;
__ps_free_appcontrol(appcontrol);
appcontrol = tmp;
if (uiapplication->launchconditions) {
launchconditions_x *launchconditions = uiapplication->launchconditions;
launchconditions_x *tmp = NULL;
- while(launchconditions != NULL)
- {
+ while(launchconditions != NULL) {
tmp = launchconditions->next;
__ps_free_launchconditions(launchconditions);
launchconditions = tmp;
if (uiapplication->notification) {
notification_x *notification = uiapplication->notification;
notification_x *tmp = NULL;
- while(notification != NULL)
- {
+ while(notification != NULL) {
tmp = notification->next;
__ps_free_notification(notification);
notification = tmp;
if (uiapplication->datashare) {
datashare_x *datashare = uiapplication->datashare;
datashare_x *tmp = NULL;
- while(datashare != NULL)
- {
+ while(datashare != NULL) {
tmp = datashare->next;
__ps_free_datashare(datashare);
datashare = tmp;
if (uiapplication->appsvc) {
appsvc_x *appsvc = uiapplication->appsvc;
appsvc_x *tmp = NULL;
- while(appsvc != NULL)
- {
+ while(appsvc != NULL) {
tmp = appsvc->next;
__ps_free_appsvc(appsvc);
appsvc = tmp;
if (uiapplication->category) {
category_x *category = uiapplication->category;
category_x *tmp = NULL;
- while(category != NULL)
- {
+ while(category != NULL) {
tmp = category->next;
__ps_free_category(category);
category = tmp;
if (uiapplication->metadata) {
metadata_x *metadata = uiapplication->metadata;
metadata_x *tmp = NULL;
- while(metadata != NULL)
- {
+ while(metadata != NULL) {
tmp = metadata->next;
__ps_free_metadata(metadata);
metadata = tmp;
if (uiapplication->permission) {
permission_x *permission = uiapplication->permission;
permission_x *tmp = NULL;
- while(permission != NULL)
- {
+ while(permission != NULL) {
tmp = permission->next;
__ps_free_permission(permission);
permission = tmp;
if (serviceapplication->label) {
label_x *label = serviceapplication->label;
label_x *tmp = NULL;
- while(label != NULL)
- {
+ while(label != NULL) {
tmp = label->next;
__ps_free_label(label);
label = tmp;
if (serviceapplication->icon) {
icon_x *icon = serviceapplication->icon;
icon_x *tmp = NULL;
- while(icon != NULL)
- {
+ while(icon != NULL) {
tmp = icon->next;
__ps_free_icon(icon);
icon = tmp;
if (serviceapplication->appcontrol) {
appcontrol_x *appcontrol = serviceapplication->appcontrol;
appcontrol_x *tmp = NULL;
- while(appcontrol != NULL)
- {
+ while(appcontrol != NULL) {
tmp = appcontrol->next;
__ps_free_appcontrol(appcontrol);
appcontrol = tmp;
if (serviceapplication->datacontrol) {
datacontrol_x *datacontrol = serviceapplication->datacontrol;
datacontrol_x *tmp = NULL;
- while(datacontrol != NULL)
- {
+ while(datacontrol != NULL) {
tmp = datacontrol->next;
__ps_free_datacontrol(datacontrol);
datacontrol = tmp;
if (serviceapplication->launchconditions) {
launchconditions_x *launchconditions = serviceapplication->launchconditions;
launchconditions_x *tmp = NULL;
- while(launchconditions != NULL)
- {
+ while(launchconditions != NULL) {
tmp = launchconditions->next;
__ps_free_launchconditions(launchconditions);
launchconditions = tmp;
if (serviceapplication->notification) {
notification_x *notification = serviceapplication->notification;
notification_x *tmp = NULL;
- while(notification != NULL)
- {
+ while(notification != NULL) {
tmp = notification->next;
__ps_free_notification(notification);
notification = tmp;
if (serviceapplication->datashare) {
datashare_x *datashare = serviceapplication->datashare;
datashare_x *tmp = NULL;
- while(datashare != NULL)
- {
+ while(datashare != NULL) {
tmp = datashare->next;
__ps_free_datashare(datashare);
datashare = tmp;
if (serviceapplication->appsvc) {
appsvc_x *appsvc = serviceapplication->appsvc;
appsvc_x *tmp = NULL;
- while(appsvc != NULL)
- {
+ while(appsvc != NULL) {
tmp = appsvc->next;
__ps_free_appsvc(appsvc);
appsvc = tmp;
if (serviceapplication->category) {
category_x *category = serviceapplication->category;
category_x *tmp = NULL;
- while(category != NULL)
- {
+ while(category != NULL) {
tmp = category->next;
__ps_free_category(category);
category = tmp;
if (serviceapplication->metadata) {
metadata_x *metadata = serviceapplication->metadata;
metadata_x *tmp = NULL;
- while(metadata != NULL)
- {
+ while(metadata != NULL) {
tmp = metadata->next;
__ps_free_metadata(metadata);
metadata = tmp;
if (serviceapplication->permission) {
permission_x *permission = serviceapplication->permission;
permission_x *tmp = NULL;
- while(permission != NULL)
- {
+ while(permission != NULL) {
tmp = permission->next;
__ps_free_permission(permission);
permission = tmp;
return 0;
}
+static int __ps_process_privilege(xmlTextReaderPtr reader, privilege_x *privilege)
+{
+ xmlTextReaderRead(reader);
+ if (xmlTextReaderValue(reader)) {
+ privilege->text = ASCII(xmlTextReaderValue(reader));
+ }
+ return 0;
+}
+
static int __ps_process_metadata(xmlTextReaderPtr reader, metadata_x *metadata)
{
if (xmlTextReaderGetAttribute(reader, XMLCHAR("key")))
xmlTextReaderRead(reader);
if (xmlTextReaderValue(reader))
permission->value = ASCII(xmlTextReaderValue(reader));
-
+ return 0;
}
static int __ps_process_compatibility(xmlTextReaderPtr reader, compatibility_x *compatibility)
return ret;
}
-static int __ps_process_registry(xmlTextReaderPtr reader, registry_x *registry)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
-static int __ps_process_database(xmlTextReaderPtr reader, database_x *database)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcontrol)
{
const xmlChar *node;
return ret;
}
+
+static int __ps_process_privileges(xmlTextReaderPtr reader, privileges_x *privileges)
+{
+ const xmlChar *node;
+ int ret = -1;
+ int depth = -1;
+ privilege_x *tmp1 = NULL;
+
+ depth = xmlTextReaderDepth(reader);
+ while ((ret = __next_child_element(reader, depth))) {
+ node = xmlTextReaderConstName(reader);
+ if (!node) {
+ DBG("xmlTextReaderConstName value is NULL\n");
+ return -1;
+ }
+
+ if (strcmp(ASCII(node), "privilege") == 0) {
+ privilege_x *privilege = malloc(sizeof(privilege_x));
+ if (privilege == NULL) {
+ DBG("Malloc Failed\n");
+ return -1;
+ }
+ memset(privilege, '\0', sizeof(privilege_x));
+ LISTADD(privileges->privilege, privilege);
+ ret = __ps_process_privilege(reader, privilege);
+ } else
+ return -1;
+ if (ret < 0) {
+ DBG("Processing privileges failed\n");
+ return ret;
+ }
+ }
+ if (privileges->privilege) {
+ LISTHEAD(privileges->privilege, tmp1);
+ privileges->privilege = tmp1;
+ }
+ return ret;
+}
+
static int __ps_process_launchconditions(xmlTextReaderPtr reader, launchconditions_x *launchconditions)
{
const xmlChar *node;
return ret;
}
-static int __ps_process_layout(xmlTextReaderPtr reader, layout_x *layout)
-{
- /*TODO: once policy is set*/
- return 0;
-}
-
static char*
-__get_icon_with_path(char* icon)
+__get_icon_with_path(const char* icon)
{
if (!icon)
return NULL;
icon->resolution = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("resolution")));
xmlTextReaderRead(reader);
if (xmlTextReaderValue(reader)) {
- char *text = ASCII(xmlTextReaderValue(reader));
+ const char *text = ASCII(xmlTextReaderValue(reader));
if(text) {
- icon->text = __get_icon_with_path(text);
- free(text);
+ icon->text = (const char *)__get_icon_with_path(text);
+ free((void *)text);
}
}
icon_x *tmp11 = NULL;
compatibility_x *tmp12 = NULL;
deviceprofile_x *tmp13 = NULL;
+ privileges_x *tmp14 = NULL;
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
memset(license, '\0', sizeof(license_x));
LISTADD(mfx->license, license);
ret = __ps_process_license(reader, license);
+ } else if (!strcmp(ASCII(node), "privileges")) {
+ privileges_x *privileges = malloc(sizeof(privileges_x));
+ if (privileges == NULL) {
+ DBG("Malloc Failed\n");
+ return -1;
+ }
+ memset(privileges, '\0', sizeof(privileges_x));
+ LISTADD(mfx->privileges, privileges);
+ ret = __ps_process_privileges(reader, privileges);
} else if (!strcmp(ASCII(node), "ui-application")) {
uiapplication_x *uiapplication = malloc(sizeof(uiapplication_x));
if (uiapplication == NULL) {
continue;
} else if (!strcmp(ASCII(node), "notifications")) {
continue;
- } else if (!strcmp(ASCII(node), "privileges")) {
- continue;
} else if (!strcmp(ASCII(node), "ime")) {
continue;
} else
LISTHEAD(mfx->deviceprofile, tmp13);
mfx->deviceprofile= tmp13;
}
-
+ if (mfx->privileges) {
+ LISTHEAD(mfx->privileges, tmp14);
+ mfx->privileges = tmp14;
+ }
return ret;
}
mime_x *mi = NULL;
uri_x *ui = NULL;
subapp_x *sub = NULL;
- char *operation = NULL;
- char *mime = NULL;
- char *uri = NULL;
- char *subapp = NULL;
+ const char *operation = NULL;
+ const char *mime = NULL;
+ const char *uri = NULL;
+ const char *subapp = NULL;
int i = 0;
asvc = up->appsvc;
- while(asvc != NULL)
- {
+ while(asvc != NULL) {
op = asvc->operation;
- while(op != NULL)
- {
+ while(op != NULL) {
if (op)
operation = op->name;
mi = asvc->mime;
mime_x *mi = NULL;
uri_x *ui = NULL;
subapp_x *sub = NULL;
- char *operation = NULL;
- char *mime = NULL;
- char *uri = NULL;
- char *subapp = NULL;
+ const char *operation = NULL;
+ const char *mime = NULL;
+ const char *uri = NULL;
+ const char *subapp = NULL;
int i = 0;
acontrol = up->appcontrol;
- while(acontrol != NULL)
- {
+ while(acontrol != NULL) {
op = acontrol->operation;
- while(op != NULL)
- {
+ while(op != NULL) {
if (op)
operation = op->name;
mi = acontrol->mime;
int state = 0;
if(strstr(manifest, MANIFEST_RO_PREFIX)) {
- free(mfx->readonly);
+ free((void *)mfx->readonly);
mfx->readonly = strdup("True");
- free(mfx->preload);
+ free((void *)mfx->preload);
mfx->preload = strdup("True");
- free(mfx->removable);
+ free((void *)mfx->removable);
mfx->removable = strdup("False");
return 0;
__str_trim(buffer);
if(!strcmp(mfx->package, buffer)) {
- free(mfx->preload);
+ free((void *)mfx->preload);
mfx->preload = strdup("True");
if(state == 2){
- free(mfx->readonly);
+ free((void *)mfx->readonly);
mfx->readonly = strdup("False");
- free(mfx->removable);
+ free((void *)mfx->removable);
mfx->removable = strdup("False");
} else if(state == 3){
- free(mfx->readonly);
+ free((void *)mfx->readonly);
mfx->readonly = strdup("False");
- free(mfx->removable);
+ free((void *)mfx->removable);
mfx->removable = strdup("True");
}
}
if (mfx->icon) {
icon_x *icon = mfx->icon;
icon_x *tmp = NULL;
- while(icon != NULL)
- {
+ while(icon != NULL) {
tmp = icon->next;
__ps_free_icon(icon);
icon = tmp;
if (mfx->label) {
label_x *label = mfx->label;
label_x *tmp = NULL;
- while(label != NULL)
- {
+ while(label != NULL) {
tmp = label->next;
__ps_free_label(label);
label = tmp;
if (mfx->author) {
author_x *author = mfx->author;
author_x *tmp = NULL;
- while(author != NULL)
- {
+ while(author != NULL) {
tmp = author->next;
__ps_free_author(author);
author = tmp;
if (mfx->description) {
description_x *description = mfx->description;
description_x *tmp = NULL;
- while(description != NULL)
- {
+ while(description != NULL) {
tmp = description->next;
__ps_free_description(description);
description = tmp;
if (mfx->license) {
license_x *license = mfx->license;
license_x *tmp = NULL;
- while(license != NULL)
- {
+ while(license != NULL) {
tmp = license->next;
__ps_free_license(license);
license = tmp;
}
}
+ /*Free Privileges*/
+ if (mfx->privileges) {
+ privileges_x *privileges = mfx->privileges;
+ privileges_x *tmp = NULL;
+ while(privileges != NULL) {
+ tmp = privileges->next;
+ __ps_free_privileges(privileges);
+ privileges = tmp;
+ }
+ }
/*Free UiApplication*/
if (mfx->uiapplication) {
uiapplication_x *uiapplication = mfx->uiapplication;
uiapplication_x *tmp = NULL;
- while(uiapplication != NULL)
- {
+ while(uiapplication != NULL) {
tmp = uiapplication->next;
__ps_free_uiapplication(uiapplication);
uiapplication = tmp;
if (mfx->serviceapplication) {
serviceapplication_x *serviceapplication = mfx->serviceapplication;
serviceapplication_x *tmp = NULL;
- while(serviceapplication != NULL)
- {
+ while(serviceapplication != NULL) {
tmp = serviceapplication->next;
__ps_free_serviceapplication(serviceapplication);
serviceapplication = tmp;
if (mfx->daemon) {
daemon_x *daemon = mfx->daemon;
daemon_x *tmp = NULL;
- while(daemon != NULL)
- {
+ while(daemon != NULL) {
tmp = daemon->next;
__ps_free_daemon(daemon);
daemon = tmp;
if (mfx->theme) {
theme_x *theme = mfx->theme;
theme_x *tmp = NULL;
- while(theme != NULL)
- {
+ while(theme != NULL) {
tmp = theme->next;
__ps_free_theme(theme);
theme = tmp;
if (mfx->font) {
font_x *font = mfx->font;
font_x *tmp = NULL;
- while(font != NULL)
- {
+ while(font != NULL) {
tmp = font->next;
__ps_free_font(font);
font = tmp;
if (mfx->ime) {
ime_x *ime = mfx->ime;
ime_x *tmp = NULL;
- while(ime != NULL)
- {
+ while(ime != NULL) {
tmp = ime->next;
__ps_free_ime(ime);
ime = tmp;
if (mfx->compatibility) {
compatibility_x *compatibility = mfx->compatibility;
compatibility_x *tmp = NULL;
- while(compatibility != NULL)
- {
+ while(compatibility != NULL) {
tmp = compatibility->next;
__ps_free_compatibility(compatibility);
compatibility = tmp;
if (mfx->deviceprofile) {
deviceprofile_x *deviceprofile = mfx->deviceprofile;
deviceprofile_x *tmp = NULL;
- while(deviceprofile != NULL)
- {
+ while(deviceprofile != NULL) {
tmp = deviceprofile->next;
__ps_free_deviceprofile(deviceprofile);
deviceprofile = tmp;
struct metadata_x *next;
} metadata_x;
+typedef struct privilege_x {
+ const char *text;
+ struct privilege_x *prev;
+ struct privilege_x *next;
+} privilege_x;
+
+typedef struct privileges_x {
+ struct privilege_x *privilege;
+ struct privileges_x *prev;
+ struct privileges_x *next;
+} privileges_x;
+
typedef struct permission_x {
const char *type;
const char *value;
const char *text;
const char *lang;
const char *section;
- struct icon_x *prev;
- struct icon_x *next;
+ struct image_x *prev;
+ struct image_x *next;
} image_x;
typedef struct allowed_x {
struct author_x *author; /**< package author*/
struct description_x *description; /**< package description*/
struct license_x *license; /**< package license*/
+ struct privileges_x *privileges; /**< package privileges*/
struct uiapplication_x *uiapplication; /**< package's ui application*/
struct serviceapplication_x *serviceapplication; /**< package's service application*/
struct daemon_x *daemon; /**< package daemon*/
#include <unistd.h>
#include <db-util.h>
#include <glib.h>
+#include "pkgmgr-info.h"
#include "pkgmgr_parser_internal.h"
#include "pkgmgr_parser_db.h"
"REFERENCES package_info(package) " \
"ON DELETE CASCADE)"
+#define QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO "create table if not exists package_privilege_info " \
+ "(package text not null, " \
+ "privilege text not null, " \
+ "PRIMARY KEY(package, privilege) " \
+ "FOREIGN KEY(package) " \
+ "REFERENCES package_info(package) " \
+ "ON DELETE CASCADE)"
+
#define QUERY_CREATE_TABLE_PACKAGE_APP_INFO "create table if not exists package_app_info " \
"(app_id text primary key not null, " \
"app_component text, " \
static void __insert_uiapplication_locale_info(gpointer data, gpointer userdata);
static void __insert_pkglocale_info(gpointer data, gpointer userdata);
static int __insert_manifest_info_in_db(manifest_x *mfx);
-static int __update_manifest_info_in_db(manifest_x *mfx);
static int __delete_manifest_info_from_db(manifest_x *mfx);
-static int __initialize_package_info_db();
-static int __initialize_package_localized_info_db();
-static int __initialize_package_app_info_db();
-static int __initialize_package_cert_info_db();
-static int __initialize_package_cert_index_info_db();
-static int __initialize_package_app_localized_info_db();
-static int __initialize_package_app_icon_section_info_db();
-static int __initialize_package_app_image_info_db();
-static int __initialize_package_app_app_svc_db();
-static int __initialize_package_app_app_category_db();
-static int __initialize_package_app_app_control_db();
-static int __initialize_package_app_app_metadata_db();
-static int __initialize_package_app_share_allowed_db();
-static int __initialize_package_app_share_request_db();
+static int __delete_appinfo_from_db(char *db_table, const char *appid);
+static int __initialize_db(sqlite3 *db_handle, const char *db_query);
static int __exec_query(char *query);
static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
char **label, char **license, char **icon, char **description, char **author);
-
static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata);
static void __trimfunc1(gpointer data, gpointer userdata);
static void __trimfunc2(gpointer data, gpointer userdata);
static GList *__create_locale_list(GList *locale, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath);
static void __preserve_guestmode_visibility_value(manifest_x *mfx);
static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname);
+static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path);
+
+static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path)
+{
+ int ret = -1;
+ sqlite3 *handle;
+ if (access(db_path, F_OK) == 0) {
+ ret =
+ db_util_open(db_path, &handle,
+ DB_UTIL_REGISTER_HOOK_METHOD);
+ if (ret != SQLITE_OK) {
+ DBG("connect db [%s] failed!\n",
+ db_path);
+ return -1;
+ }
+ *db_handle = handle;
+ return 0;
+ }
+ DBG("%s DB does not exists. Create one!!\n", db_path);
+
+ ret =
+ db_util_open(db_path, &handle,
+ DB_UTIL_REGISTER_HOOK_METHOD);
+
+ if (ret != SQLITE_OK) {
+ DBG("connect db [%s] failed!\n", db_path);
+ return -1;
+ }
+ *db_handle = handle;
+ return 0;
+}
static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname)
{
return;
}
-static int __initialize_package_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO,
- NULL, NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_INFO, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __pkgmgr_parser_cert_create_db()
-{
- int ret = -1;
- if (access(PKGMGR_CERT_DB_FILE, F_OK) == 0) {
- ret =
- db_util_open(PKGMGR_CERT_DB_FILE, &pkgmgr_cert_db,
- DB_UTIL_REGISTER_HOOK_METHOD);
- if (ret != SQLITE_OK) {
- DBG("connect db [%s] failed!\n",
- PKGMGR_CERT_DB_FILE);
- return -1;
- }
- return 0;
- }
- DBG("Pkgmgr DB does not exists. Create one!!\n");
-
- ret =
- db_util_open(PKGMGR_CERT_DB_FILE, &pkgmgr_cert_db,
- DB_UTIL_REGISTER_HOOK_METHOD);
-
- if (ret != SQLITE_OK) {
- DBG("connect db [%s] failed!\n", PKGMGR_CERT_DB_FILE);
- return -1;
- }
- return 0;
-}
-
-static int __initialize_package_cert_info_db()
-{
- char *error_message = NULL;
- int ret = -1;
- ret = __pkgmgr_parser_cert_create_db();
- if (ret == -1) {
- DBG("Failed to open DB\n");
- return ret;
- }
-
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO,
- NULL, NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_CERT_INFO, error_message);
- sqlite3_free(error_message);
- sqlite3_close(pkgmgr_cert_db);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_cert_index_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO,
- NULL, NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO, error_message);
- sqlite3_free(error_message);
- sqlite3_close(pkgmgr_cert_db);
- return -1;
- }
- sqlite3_free(error_message);
- sqlite3_close(pkgmgr_cert_db);
- return 0;
-}
-
-static int __initialize_package_localized_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO, NULL, NULL,
- &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_info_db()
+static int __initialize_db(sqlite3 *db_handle, const char *db_query)
{
char *error_message = NULL;
if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO,
+ sqlite3_exec(db_handle, db_query,
NULL, NULL, &error_message)) {
DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_INFO, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_localized_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO, NULL,
- NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_icon_section_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO, NULL,
- NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_image_info_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO, NULL,
- NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_app_control_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL, NULL, NULL,
- &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_app_category_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY, NULL, NULL,
- &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_app_metadata_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA, NULL, NULL,
- &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_app_permission_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION, NULL, NULL,
- &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_app_svc_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, NULL, NULL,
- &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC, error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_share_allowed_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED, NULL,
- NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED,
- error_message);
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
-static int __initialize_package_app_share_request_db()
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db,
- QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST, NULL,
- NULL, &error_message)) {
- DBG("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST,
- error_message);
+ db_query, error_message);
sqlite3_free(error_message);
return -1;
}
return -1;
if (strcmp((char*)a, (char*)b) > 0)
return 1;
+ return 0;
}
static void __extract_data(gpointer data, label_x *lbl, license_x *lcn, icon_x *icn, description_x *dcn, author_x *ath,
}
}
-static void __extract_image_data(gpointer data, icon_x *image, char **lang, char **img)
+static void __extract_image_data(gpointer data, image_x*image, char **lang, char **img)
{
while(image != NULL)
{
subapp_x *sub = NULL;
int ret = -1;
char query[MAX_QUERY_LEN] = {'\0'};
- char *operation = NULL;
- char *mime = NULL;
- char *uri = NULL;
- char *subapp = NULL;
+ const char *operation = NULL;
+ const char *mime = NULL;
+ const char *uri = NULL;
+ const char *subapp = NULL;
while(up != NULL)
{
acontrol = up->appcontrol;
subapp_x *sub = NULL;
int ret = -1;
char query[MAX_QUERY_LEN] = {'\0'};
- char *operation = NULL;
- char *mime = NULL;
- char *uri = NULL;
- char *subapp = NULL;
+ const char *operation = NULL;
+ const char *mime = NULL;
+ const char *uri = NULL;
+ const char *subapp = NULL;
while(up != NULL)
{
asvc = up->appsvc;
mime_x *mi = NULL;
uri_x *ui = NULL;
subapp_x *sub = NULL;
- char *operation = NULL;
- char *mime = NULL;
- char *uri = NULL;
- char *subapp = NULL;
+ const char *operation = NULL;
+ const char *mime = NULL;
+ const char *uri = NULL;
+ const char *subapp = NULL;
while(sp != NULL)
{
acontrol = sp->appcontrol;
mime_x *mi = NULL;
uri_x *ui = NULL;
subapp_x *sub = NULL;
- char *operation = NULL;
- char *mime = NULL;
- char *uri = NULL;
- char *subapp = NULL;
+ const char *operation = NULL;
+ const char *mime = NULL;
+ const char *uri = NULL;
+ const char *subapp = NULL;
while(sp != NULL)
{
asvc = sp->appsvc;
uiapplication_x *up_icn = mfx->uiapplication;
uiapplication_x *up_image = mfx->uiapplication;
serviceapplication_x *sp = mfx->serviceapplication;
+ privileges_x *pvs = NULL;
+ privilege_x *pv = NULL;
char query[MAX_QUERY_LEN] = { '\0' };
int ret = -1;
char *type = NULL;
char *path = NULL;
- char *auth_name = NULL;
- char *auth_email = NULL;
- char *auth_href = NULL;
+ const char *auth_name = NULL;
+ const char *auth_email = NULL;
+ const char *auth_href = NULL;
if (ath) {
if (ath->text)
auth_name = ath->text;
free(path);
path = NULL;
}
+
+ /*Insert in the package_privilege_info DB*/
+ pvs = mfx->privileges;
+ while (pvs != NULL) {
+ pv = pvs->privilege;
+ while (pv != NULL) {
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN,
+ "insert into package_privilege_info(package, privilege) " \
+ "values('%s','%s')",\
+ mfx->package, pv->text);
+ ret = __exec_query(query);
+ if (ret == -1) {
+ DBG("Package Privilege Info DB Insert Failed\n");
+ return -1;
+ }
+ pv = pv->next;
+ }
+ pvs = pvs->next;
+ }
+
/*Insert the package locale and app locale info */
pkglocale = __create_locale_list(pkglocale, lbl, lcn, icn, dcn, ath);
g_list_foreach(pkglocale, __trimfunc1, NULL);
}
+static int __delete_appinfo_from_db(char *db_table, const char *appid)
+{
+ char query[MAX_QUERY_LEN] = { '\0' };
+ int ret = -1;
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN,
+ "delete from %s where app_id='%s'", db_table, appid);
+ ret = __exec_query(query);
+ if (ret == -1) {
+ DBG("DB Deletion from table (%s) Failed\n", db_table);
+ return -1;
+ }
+ return 0;
+}
+
static int __delete_manifest_info_from_db(manifest_x *mfx)
{
char query[MAX_QUERY_LEN] = { '\0' };
int ret = -1;
uiapplication_x *up = mfx->uiapplication;
serviceapplication_x *sp = mfx->serviceapplication;
-
/*Delete from cert table*/
ret = pkgmgrinfo_delete_certinfo(mfx->package);
if (ret) {
DBG("Package Localized Info DB Delete Failed\n");
return -1;
}
- memset(query, '\0', MAX_QUERY_LEN);
- /*Delete from Package App Info*/
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_info where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
+ /*Delete from Package Privilege Info*/
+ snprintf(query, MAX_QUERY_LEN,
+ "delete from package_privilege_info where package='%s'", mfx->package);
+ ret = __exec_query(query);
+ if (ret == -1) {
+ DBG("Package Privilege Info DB Delete Failed\n");
+ return -1;
+ }
+
+ while (up != NULL) {
+ ret = __delete_appinfo_from_db("package_app_info", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_localized_info", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_icon_section_info", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_image_info", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_svc", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_control", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_category", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_metadata", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_permission", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_share_allowed", up->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_share_request", up->appid);
+ if (ret < 0)
+ return ret;
up = up->next;
}
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_info where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
- /*Delete from Package App Localized Info*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_localized_info where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Localized Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_localized_info where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Localized Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from App icon localized Info*/
- up = mfx->uiapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_icon_section_info where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App image Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
-
- /*Delete from App image Info*/
- up = mfx->uiapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_image_info where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App image Info DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
-
- /*Delete from Package App App-Svc*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_svc where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Svc DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_svc where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Svc DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App App-Control*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_control where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Control DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_control where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Control DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App App-Category*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_category where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Category DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_category where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Category DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App App-Metadata*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_metadata where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Metadata DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_metadata where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-Metadata DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App App-permission*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_permission where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-permission DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_app_permission where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App App-permission DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App Share Allowed*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_share_allowed where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Share Allowed DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_share_allowed where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Share Allowed DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- sp = sp->next;
- }
-
- /*Delete from Package App Share Request*/
- up = mfx->uiapplication;
- sp = mfx->serviceapplication;
- while(up != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_share_request where app_id='%s'", up->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Share Request DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- up = up->next;
- }
- while(sp != NULL)
- {
- snprintf(query, MAX_QUERY_LEN,
- "delete from package_app_share_request where app_id='%s'", sp->appid);
- ret = __exec_query(query);
- if (ret == -1) {
- DBG("Package App Share Request DB Delete Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
+ while (sp != NULL) {
+ ret = __delete_appinfo_from_db("package_app_info", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_localized_info", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_icon_section_info", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_image_info", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_svc", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_control", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_category", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_metadata", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_app_permission", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_share_allowed", sp->appid);
+ if (ret < 0)
+ return ret;
+ ret = __delete_appinfo_from_db("package_app_share_request", sp->appid);
+ if (ret < 0)
+ return ret;
sp = sp->next;
}
return 0;
int pkgmgr_parser_initialize_db()
{
int ret = -1;
- ret = __initialize_package_info_db();
+ /*Manifest DB*/
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO);
if (ret == -1) {
DBG("package info DB initialization failed\n");
return ret;
}
- ret = __initialize_package_localized_info_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO);
if (ret == -1) {
DBG("package localized info DB initialization failed\n");
return ret;
}
- ret = __initialize_package_cert_info_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO);
if (ret == -1) {
- DBG("package cert info DB initialization failed\n");
+ DBG("package app app privilege DB initialization failed\n");
return ret;
}
- ret = __initialize_package_cert_index_info_db();
- if (ret == -1) {
- DBG("package cert index info DB initialization failed\n");
- return ret;
- }
- ret = __initialize_package_app_info_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO);
if (ret == -1) {
DBG("package app info DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_localized_info_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO);
if (ret == -1) {
DBG("package app localized info DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_icon_section_info_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO);
if (ret == -1) {
DBG("package app icon localized info DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_image_info_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO);
if (ret == -1) {
DBG("package app image info DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_app_control_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL);
if (ret == -1) {
DBG("package app app control DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_app_category_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY);
if (ret == -1) {
DBG("package app app category DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_app_metadata_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA);
if (ret == -1) {
DBG("package app app category DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_app_permission_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION);
if (ret == -1) {
DBG("package app app permission DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_app_svc_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC);
if (ret == -1) {
DBG("package app app svc DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_share_allowed_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED);
if (ret == -1) {
DBG("package app share allowed DB initialization failed\n");
return ret;
}
- ret = __initialize_package_app_share_request_db();
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST);
if (ret == -1) {
DBG("package app share request DB initialization failed\n");
return ret;
}
+ /*Cert DB*/
+ ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO);
+ if (ret == -1) {
+ DBG("package cert info DB initialization failed\n");
+ return ret;
+ }
+ ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO);
+ if (ret == -1) {
+ DBG("package cert index info DB initialization failed\n");
+ return ret;
+ }
return 0;
}
int pkgmgr_parser_check_and_create_db()
{
int ret = -1;
- if (access(PKGMGR_PARSER_DB_FILE, F_OK) == 0) {
- ret =
- db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db,
- DB_UTIL_REGISTER_HOOK_METHOD);
- if (ret != SQLITE_OK) {
- DBG("connect db [%s] failed!\n",
- PKGMGR_PARSER_DB_FILE);
- return -1;
- }
- ret = chmod(PKGMGR_PARSER_DB_FILE, 0664);
- if (ret)
- DBG("Failed to change mode of manifest DB\n");
- return 0;
+ /*Manifest DB*/
+ ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, PKGMGR_PARSER_DB_FILE);
+ if (ret) {
+ DBG("Manifest DB creation Failed\n");
+ return -1;
}
- DBG("Pkgmgr DB does not exists. Create one!!\n");
-
- ret =
- db_util_open(PKGMGR_PARSER_DB_FILE, &pkgmgr_parser_db,
- DB_UTIL_REGISTER_HOOK_METHOD);
-
- if (ret != SQLITE_OK) {
- DBG("connect db [%s] failed!\n", PKGMGR_PARSER_DB_FILE);
+ /*Cert DB*/
+ ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, PKGMGR_CERT_DB_FILE);
+ if (ret) {
+ DBG("Cert DB creation Failed\n");
return -1;
}
- ret = chmod(PKGMGR_PARSER_DB_FILE, 0664);
- if (ret)
- DBG("Failed to change mode of manifest DB\n");
return 0;
}
DBG("manifest pointer is NULL\n");
return -1;
}
- int ret = -1;
+ int ret = 0;
ret = pkgmgr_parser_check_and_create_db();
if (ret == -1) {
DBG("Failed to open DB\n");
}
ret = pkgmgr_parser_initialize_db();
if (ret == -1)
- return ret;
+ goto err;
/*Begin transaction*/
ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
DBG("Failed to begin transaction\n");
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ ret = -1;
+ goto err;
}
DBG("Transaction Begin\n");
ret = __insert_manifest_info_in_db(mfx);
if (ret == -1) {
DBG("Insert into DB failed. Rollback now\n");
sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ goto err;
}
/*Commit transaction*/
ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
DBG("Failed to commit transaction. Rollback now\n");
sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ ret = -1;
+ goto err;
}
DBG("Transaction Commit and End\n");
+err:
sqlite3_close(pkgmgr_parser_db);
- return 0;
+ sqlite3_close(pkgmgr_cert_db);
+ return ret;
}
API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
DBG("manifest pointer is NULL\n");
return -1;
}
- int ret = -1;
+ int ret = 0;
ret = pkgmgr_parser_check_and_create_db();
if (ret == -1) {
DBG("Failed to open DB\n");
}
ret = pkgmgr_parser_initialize_db();
if (ret == -1)
- return ret;
+ goto err;
/*Preserve guest mode visibility*/
__preserve_guestmode_visibility_value( mfx);
/*Begin transaction*/
ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
DBG("Failed to begin transaction\n");
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ ret = -1;
+ goto err;
}
DBG("Transaction Begin\n");
ret = __delete_manifest_info_from_db(mfx);
if (ret == -1) {
DBG("Delete from DB failed. Rollback now\n");
sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ goto err;
}
ret = __insert_manifest_info_in_db(mfx);
if (ret == -1) {
DBG("Insert into DB failed. Rollback now\n");
sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ goto err;
}
/*Commit transaction*/
if (ret != SQLITE_OK) {
DBG("Failed to commit transaction. Rollback now\n");
sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ ret = -1;
+ goto err;
}
DBG("Transaction Commit and End\n");
+err:
sqlite3_close(pkgmgr_parser_db);
- return 0;
+ sqlite3_close(pkgmgr_cert_db);
+ return ret;
}
API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
DBG("manifest pointer is NULL\n");
return -1;
}
- int ret = -1;
+ int ret = 0;
ret = pkgmgr_parser_check_and_create_db();
if (ret == -1) {
DBG("Failed to open DB\n");
ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
DBG("Failed to begin transaction\n");
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ ret = -1;
+ goto err;
}
DBG("Transaction Begin\n");
ret = __delete_manifest_info_from_db(mfx);
if (ret == -1) {
DBG("Delete from DB failed. Rollback now\n");
sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ goto err;
}
/*Commit transaction*/
ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
DBG("Failed to commit transaction, Rollback now\n");
sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- sqlite3_close(pkgmgr_parser_db);
- return -1;
+ ret = -1;
+ goto err;
}
DBG("Transaction Commit and End\n");
sqlite3_close(pkgmgr_parser_db);
- return 0;
+err:
+ sqlite3_close(pkgmgr_parser_db);
+ sqlite3_close(pkgmgr_cert_db);
+ return ret;
}
#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.h"
+#include "pkgmgr_parser_db.h"
#include <dirent.h>
#include <sys/stat.h>
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);
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->root_path = strdup(coltxt[i]);
else
info->manifest_info->root_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]);
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_db_query(db, 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(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_db_query(db, 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(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_db_query(db, 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)
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(db, appid, locale);
API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
{
- if (pkg_list_cb == NULL) {
- _LOGE("callback function is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ 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'};
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) {
ret = PMINFO_R_ERROR;
goto err;
}
- pkgmgr_pkginfo_x *tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
+ pkgmgr_pkginfo_x *tmphead = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
pkgmgr_pkginfo_x *node = NULL;
pkgmgr_pkginfo_x *temp_node = NULL;
for(node = node->next; node ; node = node->next) {
pkginfo = node;
-
+ 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;
icon_x *tmp2 = NULL;
description_x *tmp3 = NULL;
author_x *tmp4 = NULL;
+ privilege_x *tmp5 = NULL;
/*validate pkgid*/
ret = __open_manifest_db();
goto err;
}
pkginfo->manifest_info->package = strdup(pkgid);
+ 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' ", pkgid);
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' ", pkgid);
+ 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'", pkgid, 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;
+ }
*handle = (void *)pkginfo;
sqlite3_close(manifest_db);
if (syslocale) {
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;
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_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;
- }
+ 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;
description_x *ptr = NULL;
*description = NULL;
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;
- }
+ 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;
author_x *ptr = NULL;
*author_name = NULL;
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)
{
- 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");
+ char *pkgid = NULL;
pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
if (pkgid == NULL){
_LOGE("invalid func parameters\n");
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);
API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
{
- if (handle == NULL) {
- _LOGE("pkginfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (path == 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(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 = info->manifest_info->root_path;
+ *path = (char *)info->manifest_info->root_path;
else
return PMINFO_R_ERROR;
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");
+ char *pkgid = NULL;
pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
if (pkgid == NULL){
_LOGD("invalid func parameters\n");
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;
API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
{
- 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(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;
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;
API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
{
- 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");
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;
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;
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;
LISTHEAD(tmphead, node);
for(node = node->next ; node ; node = node->next) {
pkginfo = node;
+ 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) {
+ 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)
{
pkgmgr_appinfo_x *appinfo = NULL;
icon_x *ptr1 = NULL;
label_x *ptr2 = NULL;
- category_x *tmp3 = NULL;
- metadata_x *tmp4 = NULL;
- permission_x *tmp5 = NULL;
- image_x *tmp6 = NULL;
+ category_x *ptr3 = NULL;
+ metadata_x *ptr4 = NULL;
+ permission_x *ptr5 = NULL;
+ image_x *ptr6 = NULL;
sqlite3 *appinfo_db = NULL;
/*get system locale*/
/*calloc allinfo*/
strncpy(glocale, locale, PKG_LOCALE_STRING_LEN_MAX - 1);
- allinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
+ 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*/
appinfo->uiapp_info->icon = ptr1;
}
if (appinfo->uiapp_info->category) {
- LISTHEAD(appinfo->uiapp_info->category, tmp3);
- appinfo->uiapp_info->category = tmp3;
+ LISTHEAD(appinfo->uiapp_info->category, ptr3);
+ appinfo->uiapp_info->category = ptr3;
}
if (appinfo->uiapp_info->metadata) {
- LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
- appinfo->uiapp_info->metadata = tmp4;
+ LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
+ appinfo->uiapp_info->metadata = ptr4;
}
if (appinfo->uiapp_info->permission) {
- LISTHEAD(appinfo->uiapp_info->permission, tmp5);
- appinfo->uiapp_info->permission = tmp5;
+ LISTHEAD(appinfo->uiapp_info->permission, ptr5);
+ appinfo->uiapp_info->permission = ptr5;
}
if (appinfo->uiapp_info->image) {
- LISTHEAD(appinfo->uiapp_info->image, tmp6);
- appinfo->uiapp_info->image = tmp6;
+ LISTHEAD(appinfo->uiapp_info->image, ptr6);
+ appinfo->uiapp_info->image = ptr6;
}
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
appinfo->svcapp_info->icon = ptr1;
}
if (appinfo->svcapp_info->category) {
- LISTHEAD(appinfo->svcapp_info->category, tmp3);
- appinfo->svcapp_info->category = tmp3;
+ LISTHEAD(appinfo->svcapp_info->category, ptr3);
+ appinfo->svcapp_info->category = ptr3;
}
if (appinfo->svcapp_info->metadata) {
- LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
- appinfo->svcapp_info->metadata = tmp4;
+ LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
+ appinfo->svcapp_info->metadata = ptr4;
}
if (appinfo->svcapp_info->permission) {
- LISTHEAD(appinfo->svcapp_info->permission, tmp5);
- appinfo->svcapp_info->permission = tmp5;
+ LISTHEAD(appinfo->svcapp_info->permission, ptr5);
+ appinfo->svcapp_info->permission = ptr5;
}
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
appinfo->uiapp_info->icon = ptr1;
}
if (appinfo->uiapp_info->category) {
- LISTHEAD(appinfo->uiapp_info->category, tmp3);
- appinfo->uiapp_info->category = tmp3;
+ LISTHEAD(appinfo->uiapp_info->category, ptr3);
+ appinfo->uiapp_info->category = ptr3;
}
if (appinfo->uiapp_info->metadata) {
- LISTHEAD(appinfo->uiapp_info->metadata, tmp4);
- appinfo->uiapp_info->metadata = tmp4;
+ LISTHEAD(appinfo->uiapp_info->metadata, ptr4);
+ appinfo->uiapp_info->metadata = ptr4;
}
if (appinfo->uiapp_info->permission) {
- LISTHEAD(appinfo->uiapp_info->permission, tmp5);
- appinfo->uiapp_info->permission = tmp5;
+ LISTHEAD(appinfo->uiapp_info->permission, ptr5);
+ appinfo->uiapp_info->permission = ptr5;
}
if (appinfo->uiapp_info->image) {
- LISTHEAD(appinfo->uiapp_info->image, tmp6);
- appinfo->uiapp_info->image = tmp6;
+ LISTHEAD(appinfo->uiapp_info->image, ptr6);
+ appinfo->uiapp_info->image = ptr6;
}
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
appinfo->svcapp_info->icon = ptr1;
}
if (appinfo->svcapp_info->category) {
- LISTHEAD(appinfo->svcapp_info->category, tmp3);
- appinfo->svcapp_info->category = tmp3;
+ LISTHEAD(appinfo->svcapp_info->category, ptr3);
+ appinfo->svcapp_info->category = ptr3;
}
if (appinfo->svcapp_info->metadata) {
- LISTHEAD(appinfo->svcapp_info->metadata, tmp4);
- appinfo->svcapp_info->metadata = tmp4;
+ LISTHEAD(appinfo->svcapp_info->metadata, ptr4);
+ appinfo->svcapp_info->metadata = ptr4;
}
if (appinfo->svcapp_info->permission) {
- LISTHEAD(appinfo->svcapp_info->permission, tmp5);
- appinfo->svcapp_info->permission = tmp5;
+ LISTHEAD(appinfo->svcapp_info->permission, ptr5);
+ appinfo->svcapp_info->permission = ptr5;
}
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
}
if (appinfo) {
if (appinfo->package) {
- free(appinfo->package);
+ free((void *)appinfo->package);
appinfo->package = NULL;
}
free(appinfo);
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
- free(appinfo->package);
+ free((void *)appinfo->package);
appinfo->package = NULL;
}
/*Service Apps*/
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;
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;
- }
+ 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;
icon_x *ptr = NULL;
icon_x *start = NULL;
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;
- }
+ 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;
label_x *ptr = NULL;
label_x *start = NULL;
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;
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;
API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
pkgmgrinfo_app_category_list_cb category_func, void *user_data)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (category_func == NULL) {
- _LOGE("Callback function is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ 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;
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 (metadata_func == NULL) {
- _LOGE("Callback function is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ 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;
API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
pkgmgrinfo_app_control_list_cb appcontrol_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");
- return PMINFO_R_EINVAL;
- }
+ 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;
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;
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 (indicator_disp == 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;
API int pkgmgrinfo_appinfo_get_effectimage(pkgmgrinfo_appinfo_h handle, char **portrait_img, char **landscape_img)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (portrait_img == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (landscape_img == 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(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){
API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h handle, bool *taskmanage)
{
- 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(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;
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 (enabled == 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;
if (info->app_component == PMINFO_UI_APP)
API int pkgmgrinfo_appinfo_get_hwacceleration(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_hwacceleration *hwacceleration)
{
- 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(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;
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;
API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ 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;
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;
}
}
if (location == INSTALL_INTERNAL) {
- strcpy(mfx->installlocation, "internal-only");
+ strcpy((char *)mfx->installlocation, "internal-only");
} else if (location == INSTALL_EXTERNAL) {
- strcpy(mfx->installlocation, "prefer-external");
+ strcpy((char *)mfx->installlocation, "prefer-external");
} else {
_LOGE("Invalid location type\n");
return PMINFO_R_ERROR;
}
}
if (removable == 0) {
- strcpy(mfx->removable, "false");
+ strcpy((char *)mfx->removable, "false");
} else if (removable == 1) {
- strcpy(mfx->removable, "true");
+ strcpy((char *)mfx->removable, "true");
} else {
_LOGE("Invalid removable type\n");
return PMINFO_R_ERROR;
}
}
if (preload == 0) {
- strcpy(mfx->preload, "false");
+ strcpy((char *)mfx->preload, "false");
} else if (preload == 1) {
- strcpy(mfx->preload, "true");
+ strcpy((char *)mfx->preload, "true");
} else {
_LOGE("Invalid preload type\n");
return PMINFO_R_ERROR;
API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
{
- if (appid == NULL) {
- _LOGE("appid is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
int ret = -1;
char query[MAX_QUERY_LEN] = {'\0'};
ret = __open_manifest_db();
API int pkgmgrinfo_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
{
- if (providerid == NULL) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (type == NULL) {
- _LOGE("Argument supplied is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (appid == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (access == NULL) {
- _LOGE("Argument supplied to hold return value is NULL\n");
- return PMINFO_R_EINVAL;
- }
-
+ 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;
API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
{
- if (appid == NULL) {
- _LOGE("appid is NULL\n");
- return PMINFO_R_EINVAL;
- }
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
int ret = -1;
char query[MAX_QUERY_LEN] = {'\0'};
char *error_message = NULL;
API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
{
- if (handle == NULL) {
- _LOGE("appinfo handle is NULL\n");
- return PMINFO_R_EINVAL;
- }
- if (status == 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\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;
API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
{
- 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");
char *val = NULL;
int ret = 0;
char *noti_string = NULL;