refact: method UpdateApplicationInfo change to ReloadApplications
Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
d198ecebc8
commit
4d6e399653
@ -2,8 +2,7 @@
|
||||
<node>
|
||||
<interface name="org.desktopspec.ApplicationManager1">
|
||||
<property type="ao" access="read" name="List" />
|
||||
<method name="UpdateApplicationInfo">
|
||||
<arg type="as" name="app_ids" direction="in" />
|
||||
<method name="ReloadApplications">
|
||||
<annotation
|
||||
name="org.freedesktop.DBus.Description"
|
||||
value="This method is used to update the desktop file cache when needed.
|
||||
|
@ -138,7 +138,6 @@ void ApplicationManager1Service::removeInstanceFromApplication(const QString &un
|
||||
|
||||
void ApplicationManager1Service::scanApplications() noexcept
|
||||
{
|
||||
QList<DesktopFile> fileList{};
|
||||
const auto &desktopFileDirs = getDesktopFileDirs();
|
||||
|
||||
applyIteratively(QList<QDir>(desktopFileDirs.cbegin(), desktopFileDirs.cend()), [this](const QFileInfo &info) -> bool {
|
||||
@ -307,6 +306,7 @@ QString ApplicationManager1Service::Identify(const QDBusUnixFileDescriptor &pidf
|
||||
void ApplicationManager1Service::updateApplication(const QSharedPointer<ApplicationService> &destApp,
|
||||
const DesktopFile &desktopFile) noexcept
|
||||
{
|
||||
// TODO: add propertyChanged
|
||||
if (auto app = m_applicationList.find(destApp->applicationPath()); app == m_applicationList.cend()) {
|
||||
return;
|
||||
}
|
||||
@ -329,29 +329,40 @@ void ApplicationManager1Service::updateApplication(const QSharedPointer<Applicat
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationManager1Service::UpdateApplicationInfo(const QStringList &appIdList)
|
||||
void ApplicationManager1Service::ReloadApplications()
|
||||
{
|
||||
for (const auto &appId : appIdList) {
|
||||
DesktopErrorCode err{DesktopErrorCode::NotFound};
|
||||
auto file = DesktopFile::searchDesktopFileById(appId, err);
|
||||
auto destApp = std::find_if(m_applicationList.cbegin(),
|
||||
m_applicationList.cend(),
|
||||
[&appId](const QSharedPointer<ApplicationService> &app) { return appId == app->id(); });
|
||||
const auto &desktopFileDirs = getDesktopFileDirs();
|
||||
|
||||
applyIteratively(QList<QDir>(desktopFileDirs.cbegin(), desktopFileDirs.cend()), [this](const QFileInfo &info) -> bool {
|
||||
DesktopErrorCode err{DesktopErrorCode::NoError};
|
||||
auto ret = DesktopFile::searchDesktopFileByPath(info.absoluteFilePath(), err);
|
||||
if (!ret.has_value()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto file = std::move(ret).value();
|
||||
|
||||
auto destApp =
|
||||
std::find_if(m_applicationList.cbegin(),
|
||||
m_applicationList.cend(),
|
||||
[&file](const QSharedPointer<ApplicationService> &app) { return file.desktopId() == app->id(); });
|
||||
|
||||
if (err == DesktopErrorCode::NotFound) {
|
||||
if (destApp != m_applicationList.cend()) {
|
||||
removeOneApplication(destApp.key());
|
||||
}
|
||||
continue;
|
||||
qWarning() << "failed to search File:" << err << "skip.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (destApp != m_applicationList.cend()) {
|
||||
updateApplication(destApp.value(), file.value());
|
||||
continue;
|
||||
updateApplication(destApp.value(), file);
|
||||
return false;
|
||||
}
|
||||
|
||||
addApplication(std::move(file).value());
|
||||
}
|
||||
addApplication(std::move(file));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
ObjectMap ApplicationManager1Service::GetManagedObjects() const
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
QString Identify(const QDBusUnixFileDescriptor &pidfd, QDBusObjectPath &application, QDBusObjectPath &application_instance);
|
||||
void UpdateApplicationInfo(const QStringList &appIdList);
|
||||
void ReloadApplications();
|
||||
[[nodiscard]] ObjectMap GetManagedObjects() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
Loading…
Reference in New Issue
Block a user