}
inline bool CheckAppFilters(pkgmgrinfo_filter_x* filter,
- const std::shared_ptr<application_x>& info,
+ const std::shared_ptr<application_x>& app_info,
+ const std::shared_ptr<package_x>& pkg_info,
const std::unordered_map<std::string, std::string>& metadata_map) {
for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
auto* checker = FilterCheckerProvider::GetInst().
GetAppFilterChecker(node->prop);
- if (!checker->CheckFilter(node, info.get()))
+ if (!checker->CheckFilter(node, app_info.get(), pkg_info.get()))
return false;
}
bool pass = true;
if (!metadata_map.empty())
- pass = CheckMetadataFilter(info->metadata, metadata_map);
+ pass = CheckMetadataFilter(app_info->metadata, metadata_map);
return pass;
}
+std::shared_ptr<package_x> DBHandleProvider::GetPackageByApp(
+ const char* appid) {
+ auto it = pkg_map_.find(appid);
+ if (it == pkg_map_.end())
+ return nullptr;
+
+ return it->second;
+}
+
std::vector<std::shared_ptr<application_x>> DBHandleProvider::GetApplications(
pid_t pid, pkgmgrinfo_filter_x* filter,
const std::string& app) {
if (app.empty()) {
for (auto& info : app_map_) {
- if (CheckAppFilters(filter, info.second, metadata_map))
+ if (CheckAppFilters(filter, info.second,
+ GetPackageByApp(info.second->package), metadata_map))
ret.push_back(info.second);
}
} else {
auto map_it = app_map_.find(app);
if (map_it != app_map_.end() &&
- CheckAppFilters(filter, map_it->second, metadata_map))
+ CheckAppFilters(filter, map_it->second,
+ GetPackageByApp(map_it->second->package), metadata_map))
ret.push_back(map_it->second);
}
void AddApplication(std::string app, std::shared_ptr<application_x> info);
void InsertPID(pid_t pid);
bool ErasePID(pid_t pid);
+ std::shared_ptr<package_x> GetPackageByApp(const char* appid);
private:
static std::unordered_map<uid_t,
namespace database {
bool AppDisableAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->is_disabled != nullptr &&
- strcasecmp(node->value, info->is_disabled) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->is_disabled != nullptr &&
+ strcasecmp(node->value, app_info->is_disabled) == 0);
}
} // namespace database
public:
AppDisableAppFilterChecker() = default;
~AppDisableAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool AppIdAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->appid != nullptr &&
- strcmp(node->value, info->appid) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->appid != nullptr &&
+ strcmp(node->value, app_info->appid) == 0);
}
} // namespace database
public:
AppIdAppFilterChecker() = default;
~AppIdAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool AutoRestartAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->autorestart != nullptr &&
- strcasecmp(node->value, info->autorestart) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->autorestart != nullptr &&
+ strcasecmp(node->value, app_info->autorestart) == 0);
}
} // namespace database
public:
AutoRestartAppFilterChecker() = default;
~AutoRestartAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool CategoryAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- for (auto* it = info->category; it != nullptr; it = g_list_next(it)) {
+ application_x* app_info, package_x* pkg_info) {
+ for (auto* it = app_info->category; it != nullptr; it = g_list_next(it)) {
char* value = reinterpret_cast<char*>(it->data);
if (value != nullptr && strcmp(value, node->value) == 0) return true;
}
public:
CategoryAppFilterChecker() = default;
~CategoryAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool CheckStorageAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
+ application_x* app_info, package_x* pkg_info) {
return (node->value == nullptr || strcasecmp(node->value, "true") != 0 ||
- __appinfo_check_installed_storage(info) == PMINFO_R_OK);
+ __appinfo_check_installed_storage(app_info) == PMINFO_R_OK);
}
} // namespace database
public:
CheckStorageAppFilterChecker() = default;
~CheckStorageAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool ComponentAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->component != nullptr &&
- strcmp(node->value, info->component) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->component != nullptr &&
+ strcmp(node->value, app_info->component) == 0);
}
} // namespace database
public:
ComponentAppFilterChecker() = default;
~ComponentAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool DefaultAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
+ application_x* app_info, package_x* pkg_info) {
return true;
}
public:
DefaultAppFilterChecker() = default;
~DefaultAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool ExecAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->exec != nullptr &&
- strcmp(node->value, info->exec) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->exec != nullptr &&
+ strcmp(node->value, app_info->exec) == 0);
}
} // namespace database
public:
ExecAppFilterChecker() = default;
~ExecAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool HWAccelerationAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->hwacceleration != nullptr &&
- strcmp(node->value, info->hwacceleration) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->hwacceleration != nullptr &&
+ strcmp(node->value, app_info->hwacceleration) == 0);
}
} // namespace database
public:
HWAccelerationAppFilterChecker() = default;
~HWAccelerationAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool IconAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
+ application_x* app_info, package_x* pkg_info) {
if (node->value == nullptr)
return false;
- for (auto* it = info->icon; it; it = g_list_next(it)) {
+ for (auto* it = app_info->icon; it; it = g_list_next(it)) {
auto path = reinterpret_cast<icon_x*>(it->data)->text;
if (path != nullptr && strcmp(path, node->value) == 0)
return true;
public:
IconAppFilterChecker() = default;
~IconAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool LaunchConditionAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->launchcondition != nullptr &&
- strcmp(node->value, info->launchcondition) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->launchcondition != nullptr &&
+ strcmp(node->value, app_info->launchcondition) == 0);
}
} // namespace database
public:
LaunchConditionAppFilterChecker() = default;
~LaunchConditionAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool MimeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
+ application_x* app_info, package_x* pkg_info) {
if (node->value == nullptr)
return false;
- for (auto* it = info->appcontrol; it != nullptr; it = g_list_next(it)) {
+ for (auto* it = app_info->appcontrol; it != nullptr; it = g_list_next(it)) {
char* value = reinterpret_cast<appcontrol_x*>(it->data)->mime;
if (value != nullptr && strcmp(value, node->value) == 0)
return true;
public:
MimeAppFilterChecker() = default;
~MimeAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool MultipleAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->multiple != nullptr &&
- strcasecmp(node->value, info->multiple) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->multiple != nullptr &&
+ strcasecmp(node->value, app_info->multiple) == 0);
}
} // namespace database
public:
MultipleAppFilterChecker() = default;
~MultipleAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool NoDisplayAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->nodisplay != nullptr &&
- strcasecmp(node->value, info->nodisplay) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->nodisplay != nullptr &&
+ strcasecmp(node->value, app_info->nodisplay) == 0);
}
} // namespace database
public:
NoDisplayAppFilterChecker() = default;
~NoDisplayAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool OnBootAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->onboot != nullptr &&
- strcasecmp(node->value, info->onboot) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->onboot != nullptr &&
+ strcasecmp(node->value, app_info->onboot) == 0);
}
} // namespace database
public:
OnBootAppFilterChecker() = default;
~OnBootAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool OperationAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- for (auto* it = info->appcontrol; it != nullptr; it = g_list_next(it)) {
+ application_x* app_info, package_x* pkg_info) {
+ for (auto* it = app_info->appcontrol; it != nullptr; it = g_list_next(it)) {
char* value = reinterpret_cast<appcontrol_x*>(it->data)->operation;
if (value != nullptr && strcmp(value, node->value) == 0)
return true;
public:
OperationAppFilterChecker() = default;
~OperationAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool PkgDisableAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
+ application_x* app_info, package_x* pkg_info) {
return (node->value != nullptr && strcasecmp(node->value, "false") == 0);
}
public:
PkgDisableAppFilterChecker() = default;
~PkgDisableAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool PkgIdAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->package != nullptr &&
- strcmp(node->value, info->package) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->package != nullptr &&
+ strcmp(node->value, app_info->package) == 0);
}
} // namespace database
public:
PkgIdAppFilterChecker() = default;
~PkgIdAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool PrivilegeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- for (auto* it = info->privileges; it != nullptr; it = g_list_next(it)) {
+ application_x* app_info, package_x* pkg_info) {
+ for (auto* it = app_info->privileges; it != nullptr; it = g_list_next(it)) {
char* value = reinterpret_cast<privilege_x*>(it->data)->value;
if (value != nullptr && strcmp(value, node->value) == 0) return true;
}
public:
PrivilegeAppFilterChecker() = default;
~PrivilegeAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool ScreenReaderAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->screenreader != nullptr &&
- strcmp(node->value, info->screenreader) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->screenreader != nullptr &&
+ strcmp(node->value, app_info->screenreader) == 0);
}
} // namespace database
public:
ScreenReaderAppFilterChecker() = default;
~ScreenReaderAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool StorageAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->installed_storage != nullptr &&
- strcasecmp(node->value, info->installed_storage) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->installed_storage != nullptr &&
+ strcasecmp(node->value, app_info->installed_storage) == 0);
}
} // namespace database
public:
StorageAppFilterChecker() = default;
~StorageAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool SupportDisableAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->support_disable != nullptr &&
- strcasecmp(node->value, info->ui_gadget) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->support_disable != nullptr &&
+ strcasecmp(node->value, app_info->ui_gadget) == 0);
}
} // namespace database
public:
SupportDisableAppFilterChecker() = default;
~SupportDisableAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool SupportModeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->support_mode != nullptr &&
- strcmp(node->value, info->support_mode) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->support_mode != nullptr &&
+ strcmp(node->value, app_info->support_mode) == 0);
}
} // namespace database
public:
SupportModeAppFilterChecker() = default;
~SupportModeAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool TaskManageAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->taskmanage != nullptr &&
- strcasecmp(node->value, info->taskmanage) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->taskmanage != nullptr &&
+ strcasecmp(node->value, app_info->taskmanage) == 0);
}
} // namespace database
public:
TaskManageAppFilterChecker() = default;
~TaskManageAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool TypeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->type != nullptr &&
- strcmp(node->value, info->type) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->type != nullptr &&
+ strcmp(node->value, app_info->type) == 0);
}
} // namespace database
public:
TypeAppFilterChecker() = default;
~TypeAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool UIGadgetAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
- return (node->value != nullptr && info->ui_gadget != nullptr &&
- strcmp(node->value, info->ui_gadget) == 0);
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->ui_gadget != nullptr &&
+ strcmp(node->value, app_info->ui_gadget) == 0);
}
} // namespace database
public:
UIGadgetAppFilterChecker() = default;
~UIGadgetAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
namespace database {
bool URIAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
- application_x* info) {
+ application_x* app_info, package_x* pkg_info) {
if (node->value == nullptr)
return false;
- for (auto* it = info->appcontrol; it != nullptr; it = g_list_next(it)) {
+ for (auto* it = app_info->appcontrol; it != nullptr; it = g_list_next(it)) {
char* value = reinterpret_cast<appcontrol_x*>(it->data)->uri;
if (value != nullptr && strcmp(value, node->value) == 0)
return true;
public:
URIAppFilterChecker() = default;
~URIAppFilterChecker() = default;
- bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) override;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
};
} // namespace database
public:
IAppFilterChecker() = default;
virtual ~IAppFilterChecker() = default;
- virtual bool CheckFilter(pkgmgrinfo_node_x* node, application_x* info) = 0;
+ virtual bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) = 0;
};
} // namespace database