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>
|
<node>
|
||||||
<interface name="org.desktopspec.ApplicationManager1">
|
<interface name="org.desktopspec.ApplicationManager1">
|
||||||
<property type="ao" access="read" name="List" />
|
<property type="ao" access="read" name="List" />
|
||||||
<method name="UpdateApplicationInfo">
|
<method name="ReloadApplications">
|
||||||
<arg type="as" name="app_ids" direction="in" />
|
|
||||||
<annotation
|
<annotation
|
||||||
name="org.freedesktop.DBus.Description"
|
name="org.freedesktop.DBus.Description"
|
||||||
value="This method is used to update the desktop file cache when needed.
|
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
|
void ApplicationManager1Service::scanApplications() noexcept
|
||||||
{
|
{
|
||||||
QList<DesktopFile> fileList{};
|
|
||||||
const auto &desktopFileDirs = getDesktopFileDirs();
|
const auto &desktopFileDirs = getDesktopFileDirs();
|
||||||
|
|
||||||
applyIteratively(QList<QDir>(desktopFileDirs.cbegin(), desktopFileDirs.cend()), [this](const QFileInfo &info) -> bool {
|
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,
|
void ApplicationManager1Service::updateApplication(const QSharedPointer<ApplicationService> &destApp,
|
||||||
const DesktopFile &desktopFile) noexcept
|
const DesktopFile &desktopFile) noexcept
|
||||||
{
|
{
|
||||||
|
// TODO: add propertyChanged
|
||||||
if (auto app = m_applicationList.find(destApp->applicationPath()); app == m_applicationList.cend()) {
|
if (auto app = m_applicationList.find(destApp->applicationPath()); app == m_applicationList.cend()) {
|
||||||
return;
|
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) {
|
const auto &desktopFileDirs = getDesktopFileDirs();
|
||||||
DesktopErrorCode err{DesktopErrorCode::NotFound};
|
|
||||||
auto file = DesktopFile::searchDesktopFileById(appId, err);
|
applyIteratively(QList<QDir>(desktopFileDirs.cbegin(), desktopFileDirs.cend()), [this](const QFileInfo &info) -> bool {
|
||||||
auto destApp = std::find_if(m_applicationList.cbegin(),
|
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(),
|
m_applicationList.cend(),
|
||||||
[&appId](const QSharedPointer<ApplicationService> &app) { return appId == app->id(); });
|
[&file](const QSharedPointer<ApplicationService> &app) { return file.desktopId() == app->id(); });
|
||||||
|
|
||||||
if (err == DesktopErrorCode::NotFound) {
|
if (err == DesktopErrorCode::NotFound) {
|
||||||
if (destApp != m_applicationList.cend()) {
|
if (destApp != m_applicationList.cend()) {
|
||||||
removeOneApplication(destApp.key());
|
removeOneApplication(destApp.key());
|
||||||
}
|
}
|
||||||
continue;
|
qWarning() << "failed to search File:" << err << "skip.";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destApp != m_applicationList.cend()) {
|
if (destApp != m_applicationList.cend()) {
|
||||||
updateApplication(destApp.value(), file.value());
|
updateApplication(destApp.value(), file);
|
||||||
continue;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
addApplication(std::move(file).value());
|
addApplication(std::move(file));
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectMap ApplicationManager1Service::GetManagedObjects() const
|
ObjectMap ApplicationManager1Service::GetManagedObjects() const
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
QString Identify(const QDBusUnixFileDescriptor &pidfd, QDBusObjectPath &application, QDBusObjectPath &application_instance);
|
QString Identify(const QDBusUnixFileDescriptor &pidfd, QDBusObjectPath &application, QDBusObjectPath &application_instance);
|
||||||
void UpdateApplicationInfo(const QStringList &appIdList);
|
void ReloadApplications();
|
||||||
[[nodiscard]] ObjectMap GetManagedObjects() const;
|
[[nodiscard]] ObjectMap GetManagedObjects() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
Loading…
Reference in New Issue
Block a user