// found in the LICENSE file.
#include <glib.h>
+
+#include <dlog.h>
#include <pkgmgr_parser.h>
+#include <pkgmgr-info.h>
#include <cstring>
#include <string>
const char kThemeMetadataKey[] = "http://tizen.org/metadata/theme";
+std::string GetThemeFilePath(const char* pkgid) {
+ pkgmgrinfo_pkginfo_h handle;
+ int ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ if (ret != PMINFO_R_OK)
+ return {};
+
+ char *root_path;
+ ret = pkgmgrinfo_pkginfo_get_root_path(handle, &root_path);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ return {};
+ }
+ std::string path(root_path);
+ path += "/res/";
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ return path;
+}
+
} // namespace
bool InstallTheme(const std::string& id, const std::string& path) {
extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(
const char* pkgid, const char* appid, GList* metadata) {
+ std::string root_path = GetThemeFilePath(pkgid);
+ if (root_path.empty())
+ return -1;
+
for (__metadata_t* md : GListRange<__metadata_t*>(metadata)) {
if (!strcmp(md->key, kThemeMetadataKey)) {
- InstallTheme(appid, md->value);
+ InstallTheme(appid, (root_path + md->value));
}
}
return 0;
extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(
const char* pkgid, const char* appid, GList* metadata) {
+ std::string root_path = GetThemeFilePath(pkgid);
+ if (root_path.empty())
+ return -1;
+
for (__metadata_t* md : GListRange<__metadata_t*>(metadata)) {
if (!strcmp(md->key, kThemeMetadataKey)) {
- UpgradeTheme(appid, md->value);
+ UpgradeTheme(appid, (root_path + md->value));
}
}
return 0;
extern "C" int PKGMGR_MDPARSER_PLUGIN_UNINSTALL(
const char* pkgid, const char* appid, GList* metadata) {
+ std::string root_path = GetThemeFilePath(pkgid);
+ if (root_path.empty())
+ return -1;
+
for (__metadata_t* md : GListRange<__metadata_t*>(metadata)) {
if (!strcmp(md->key, kThemeMetadataKey)) {
- UninstallTheme(appid, md->value);
+ UninstallTheme(appid, (root_path + md->value));
}
}
return 0;