#include <unistd.h>
#include <sys/types.h>
-#include <sqlite3.h>
#include <glib.h>
#include "manager/pkginfo_manager.h"
#include "pkgmgr-info.h"
#include "pkgmgrinfo_debug.h"
-#include "pkgmgrinfo_internal.h"
#include "pkgmgrinfo_private.h"
-#include "pkgmgr_parser.h"
-
-API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle) {
- retvm_if(handle == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
- pkgmgr_certinfo_x *certinfo = NULL;
- certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
- *handle = NULL;
- retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
- *handle = (void *)certinfo;
- return PMINFO_R_OK;
+
+API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+ pkgmgr_certinfo_x *certinfo = NULL;
+
+ certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
+ *handle = NULL;
+ retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
+ *handle = (void *)certinfo;
+ return PMINFO_R_OK;
}
-API int pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(
- const char *lhs_package_id, const char *rhs_package_id, uid_t uid,
- pkgmgrinfo_cert_compare_result_type_e *compare_result) {
- if (lhs_package_id == NULL || rhs_package_id == NULL ||
- compare_result == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
+API int pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(const char *lhs_package_id,
+ const char *rhs_package_id, uid_t uid,
+ pkgmgrinfo_cert_compare_result_type_e *compare_result)
+{
+ if (lhs_package_id == NULL || rhs_package_id == NULL ||
+ compare_result == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
- return _certinfo_compare_pkg_certinfo(lhs_package_id, rhs_package_id,
- compare_result);
+ return _certinfo_compare_pkg_certinfo(lhs_package_id,
+ rhs_package_id, compare_result);
}
API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(
- const char *lhs_package_id, const char *rhs_package_id,
- pkgmgrinfo_cert_compare_result_type_e *compare_result) {
- return pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(
- lhs_package_id, rhs_package_id, _getuid(), compare_result);
+ const char *lhs_package_id, const char *rhs_package_id,
+ pkgmgrinfo_cert_compare_result_type_e *compare_result)
+{
+ return pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lhs_package_id,
+ rhs_package_id, _getuid(), compare_result);
}
-API int pkgmgrinfo_pkginfo_compare_usr_app_cert_info(
- const char *lhs_app_id, const char *rhs_app_id, uid_t uid,
- pkgmgrinfo_cert_compare_result_type_e *compare_result) {
- if (lhs_app_id == NULL || rhs_app_id == NULL || compare_result == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- return _certinfo_compare_app_certinfo(
- uid, lhs_app_id, rhs_app_id, compare_result);
+API int pkgmgrinfo_pkginfo_compare_usr_app_cert_info(const char *lhs_app_id,
+ const char *rhs_app_id, uid_t uid,
+ pkgmgrinfo_cert_compare_result_type_e *compare_result)
+{
+ if (lhs_app_id == NULL || rhs_app_id == NULL ||
+ compare_result == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ return _certinfo_compare_app_certinfo(uid,
+ lhs_app_id, rhs_app_id, compare_result);
}
-API int pkgmgrinfo_pkginfo_compare_app_cert_info(
- const char *lhs_app_id, const char *rhs_app_id,
- pkgmgrinfo_cert_compare_result_type_e *compare_result) {
- return pkgmgrinfo_pkginfo_compare_usr_app_cert_info(
- lhs_app_id, rhs_app_id, _getuid(), compare_result);
+API int pkgmgrinfo_pkginfo_compare_app_cert_info(const char *lhs_app_id,
+ const char *rhs_app_id,
+ pkgmgrinfo_cert_compare_result_type_e *compare_result)
+{
+ return pkgmgrinfo_pkginfo_compare_usr_app_cert_info(lhs_app_id,
+ rhs_app_id, _getuid(), compare_result);
}
API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid,
- pkgmgrinfo_certinfo_h handle,
- uid_t uid) {
- int ret;
- pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)handle;
+ pkgmgrinfo_certinfo_h handle, uid_t uid)
+{
+ int ret;
- if (pkgid == NULL || handle == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
+ if (pkgid == NULL || handle == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
- ret = _pkginfo_get_certinfo(pkgid, &info, uid);
- if (ret != PMINFO_R_OK) _LOGE("failed to get certinfo of %s ", pkgid);
+ ret = _pkginfo_get_certinfo(pkgid, handle, uid);
+ if (ret != PMINFO_R_OK)
+ _LOGE("failed to get certinfo of %s ", pkgid);
- return ret;
+ return ret;
}
API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle,
- pkgmgrinfo_cert_type cert_type,
- const char **cert_value) {
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
- retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
- retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL,
- "Invalid certificate type\n");
- retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL,
- "Invalid certificate type\n");
- pkgmgr_certinfo_x *certinfo = NULL;
- certinfo = (pkgmgr_certinfo_x *)handle;
- if ((certinfo->cert_info)[cert_type])
- *cert_value = (certinfo->cert_info)[cert_type];
- else
- *cert_value = NULL;
- return PMINFO_R_OK;
+ pkgmgrinfo_cert_type cert_type, const char **cert_value)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL,
+ "Argument supplied is NULL\n");
+ retvm_if(cert_value == NULL, PMINFO_R_EINVAL,
+ "Argument supplied is NULL\n");
+ retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL,
+ "Invalid certificate type\n");
+ retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL,
+ "Invalid certificate type\n");
+ pkgmgr_certinfo_x *certinfo = NULL;
+
+ certinfo = (pkgmgr_certinfo_x *)handle;
+ if ((certinfo->cert_info)[cert_type])
+ *cert_value = (certinfo->cert_info)[cert_type];
+ else
+ *cert_value = NULL;
+ return PMINFO_R_OK;
}
-API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle) {
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
- int i = 0;
- pkgmgr_certinfo_x *certinfo = NULL;
- certinfo = (pkgmgr_certinfo_x *)handle;
- if (certinfo->pkgid) {
- free(certinfo->pkgid);
- certinfo->pkgid = NULL;
- }
- for (i = 0; i < MAX_CERT_TYPE; i++) {
- if ((certinfo->cert_info)[i]) {
- free((certinfo->cert_info)[i]);
- (certinfo->cert_info)[i] = NULL;
- }
- }
- free(certinfo);
- certinfo = NULL;
- return PMINFO_R_OK;
+API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL,
+ "Argument supplied is NULL\n");
+ int i = 0;
+ pkgmgr_certinfo_x *certinfo = NULL;
+
+ certinfo = (pkgmgr_certinfo_x *)handle;
+ if (certinfo->pkgid) {
+ free(certinfo->pkgid);
+ certinfo->pkgid = NULL;
+ }
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ if ((certinfo->cert_info)[i]) {
+ free((certinfo->cert_info)[i]);
+ (certinfo->cert_info)[i] = NULL;
+ }
+ }
+ free(certinfo);
+ certinfo = NULL;
+ return PMINFO_R_OK;
}
API int pkgmgrinfo_create_certinfo_set_handle(
- pkgmgrinfo_instcertinfo_h *handle) {
- retvm_if(handle == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
- pkgmgr_certinfo_x *certinfo = NULL;
- *handle = NULL;
- certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
- retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
- *handle = (void *)certinfo;
- return PMINFO_R_OK;
+ pkgmgrinfo_instcertinfo_h *handle)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+ pkgmgr_certinfo_x *certinfo = NULL;
+ *handle = NULL;
+ certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
+ retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
+ *handle = (void *)certinfo;
+ return PMINFO_R_OK;
}
API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle,
- pkgmgrinfo_instcert_type cert_type,
- char *cert_value) {
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
- retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
- retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL,
- "Invalid certificate type\n");
- retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL,
- "Invalid certificate type\n");
- pkgmgr_certinfo_x *certinfo = NULL;
- certinfo = (pkgmgr_certinfo_x *)handle;
- if (certinfo->cert_info[cert_type]) free(certinfo->cert_info[cert_type]);
- (certinfo->cert_info)[cert_type] = strdup(cert_value);
- return PMINFO_R_OK;
+ pkgmgrinfo_instcert_type cert_type, char *cert_value)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL,
+ "Argument supplied is NULL\n");
+ retvm_if(cert_value == NULL, PMINFO_R_EINVAL,
+ "Argument supplied is NULL\n");
+ retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL,
+ "Invalid certificate type\n");
+ retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT,
+ PMINFO_R_EINVAL, "Invalid certificate type\n");
+ pkgmgr_certinfo_x *certinfo = NULL;
+
+ certinfo = (pkgmgr_certinfo_x *)handle;
+ if (certinfo->cert_info[cert_type])
+ free(certinfo->cert_info[cert_type]);
+ (certinfo->cert_info)[cert_type] = strdup(cert_value);
+ return PMINFO_R_OK;
}
API int pkgmgrinfo_save_certinfo(const char *pkgid,
- pkgmgrinfo_instcertinfo_h handle, uid_t uid) {
- if (pkgid == NULL || handle == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
- pkgmgr_certinfo_x *certinfo = (pkgmgr_certinfo_x *)handle;
- return _pkginfo_insert_certinfo(pkgid, certinfo, uid);
+ pkgmgrinfo_instcertinfo_h handle, uid_t uid)
+{
+ if (pkgid == NULL || handle == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+ pkgmgr_certinfo_x *certinfo = (pkgmgr_certinfo_x *)handle;
+
+ if (certinfo->pkgid == NULL) {
+ certinfo->pkgid = strdup(pkgid);
+ if (certinfo->pkgid == NULL) {
+ _LOGE("Out of memory");
+ return PMINFO_R_ERROR;
+ }
+ }
+ return _pkginfo_insert_certinfo(pkgid, certinfo, uid);
}
-API int pkgmgrinfo_destroy_certinfo_set_handle(
- pkgmgrinfo_instcertinfo_h handle) {
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
- int i = 0;
- pkgmgr_certinfo_x *certinfo = NULL;
- certinfo = (pkgmgr_certinfo_x *)handle;
- if (certinfo->pkgid) {
- free(certinfo->pkgid);
- certinfo->pkgid = NULL;
- }
- for (i = 0; i < MAX_CERT_TYPE; i++) {
- if ((certinfo->cert_info)[i]) {
- free((certinfo->cert_info)[i]);
- (certinfo->cert_info)[i] = NULL;
- }
- }
- free(certinfo);
- certinfo = NULL;
- return PMINFO_R_OK;
+API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL,
+ "Argument supplied is NULL\n");
+ int i = 0;
+ pkgmgr_certinfo_x *certinfo = NULL;
+
+ certinfo = (pkgmgr_certinfo_x *)handle;
+ if (certinfo->pkgid) {
+ free(certinfo->pkgid);
+ certinfo->pkgid = NULL;
+ }
+ for (i = 0; i < MAX_CERT_TYPE; i++) {
+ if ((certinfo->cert_info)[i]) {
+ free((certinfo->cert_info)[i]);
+ (certinfo->cert_info)[i] = NULL;
+ }
+ }
+ free(certinfo);
+ certinfo = NULL;
+ return PMINFO_R_OK;
}
-API int pkgmgrinfo_delete_usr_certinfo(const char *pkgid, uid_t uid) {
- if (pkgid == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
+API int pkgmgrinfo_delete_usr_certinfo(const char *pkgid, uid_t uid)
+{
+ if (pkgid == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
- return _pkginfo_delete_certinfo(pkgid);
+ return _pkginfo_delete_certinfo(pkgid);
}
-API int pkgmgrinfo_delete_certinfo(const char *pkgid) {
- return pkgmgrinfo_delete_usr_certinfo(pkgid, _getuid());
+API int pkgmgrinfo_delete_certinfo(const char *pkgid)
+{
+ return pkgmgrinfo_delete_usr_certinfo(pkgid, _getuid());
}