}
return label;
+}
+
+int _appinfo_get_datacontrol_info(const char *providerid,
+ const char *type, uid_t uid, char **appid, char **access) {
+ char *query = nullptr;
+ query = sqlite3_mprintf("SELECT app_id, access FROM "
+ "package_app_data_control WHERE "
+ "providerid=%Q AND type=%Q", providerid, type);
+ if (query == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcelable(
+ new pkgmgr_common::parcel::QueryParcelable(uid, std::string(query)));
+
+ pkgmgr_client::PkgInfoClient client(parcelable, uid);
+ if (!client.SendRequest())
+ return PMINFO_R_ERROR;
+ // TODO: deliver rawdata to reqhandler directly if server is not working
+
+ std::shared_ptr<pkgmgr_common::parcel::ResultParcelable> return_parcel(
+ std::static_pointer_cast<pkgmgr_common::parcel::ResultParcelable>(
+ client.GetResultParcel()));
+ tizen_base::Parcel parcel;
+ parcel.ReadParcelable(return_parcel.get());
+ sqlite3_free(query);
+ // result_list is vector of string vector
+ auto result_list = return_parcel->GetResult();
+ if (result_list.size() == 0)
+ return PMINFO_R_ENOENT;
+ for (auto result : result_list) {
+ if (result.size() != 2)
+ return PMINFO_R_ERROR;
+ if (result.front().empty() || result.front().size() == 0 ||
+ result.back().empty() || result.back().size() == 0)
+ return PMINFO_R_ERROR;
+ *appid = strdup(result.front().c_str());
+ *access = strdup(result.back().c_str());
+ if (*appid == nullptr || *access == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ return PMINFO_R_OK;
}
\ No newline at end of file
return PMINFO_R_OK;
}
-static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
-{
- char *query = NULL;
-
- query = sqlite3_mprintf(
- "SELECT app_label FROM package_app_localized_info "
- "WHERE app_id=%Q AND app_locale=%Q", appid, locale);
- if (query == NULL) {
- _LOGE("Out of memory");
- return NULL;
- }
-
- // TODO: need to use pkginfo-client APIs
- sqlite3_free(query);
- return NULL;
-}
-
API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
{
char *val;
retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
- val = _appinfo_get_localed_label();
+ val = _appinfo_get_localed_label(appid, locale, uid);
if (val == NULL)
return PMINFO_R_ERROR;
return PMINFO_R_OK;
}
-static int _appinfo_get_datacontrol_info(const char *providerid,
- const char *type, char **appid, char **access)
-{
- char *query = NULL;
-
-
- query = sqlite3_mprintf("SELECT app_id, access FROM package_app_data_control "
- "WHERE providerid=%Q AND type=%Q", providerid, type);
- if (query == NULL) {
- LOGE("Out of memory");
- return PMINFO_R_ERROR;
- }
-
- // TODO: need to use pkginfo-client APIs
- sqlite3_free(query);
- return PMINFO_R_OK;
-}
-
-static int _pkgmgrinfo_appinfo_get_datacontrol_info(uid_t uid,
- const char *providerid, const char *type,
- char **appid, char **access)
-{
- int ret;
-
- ret = _appinfo_get_datacontrol_info(providerid, type, appid,
- access);
-
- return ret;
-}
-
API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
const char *type, uid_t uid, char **appid, char **access)
{
return PMINFO_R_EINVAL;
}
- ret = _pkgmgrinfo_appinfo_get_datacontrol_info(GLOBAL_USER, providerid,
- type, appid, access);
- if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
- ret = _pkgmgrinfo_appinfo_get_datacontrol_info(uid, providerid,
- type, appid, access);
-
+ ret = _appinfo_get_datacontrol_info(providerid, type, uid, appid, access);
/* FIXME: It should return PMINFO_R_ENOENT but to keep previous
* implementation, return PMINFO_R_ERROR. This should be
* modified later...