refact: use standard DBus interface

Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
ComixHe 2023-09-12 10:04:41 +08:00 committed by Comix
parent 6a95a97599
commit 7b527c609b
2 changed files with 3 additions and 18 deletions

View File

@ -80,7 +80,7 @@ ApplicationManager1Service::ApplicationManager1Service(std::unique_ptr<Identifie
auto sessionId = getCurrentSessionId(); auto sessionId = getCurrentSessionId();
if (flag.open(QFile::ReadOnly | QFile::ExistingOnly)) { if (flag.open(QFile::ReadOnly | QFile::ExistingOnly)) {
auto content = flag.readAll(); auto content = flag.read(sessionId.size());
if (!content.isEmpty() and !sessionId.isEmpty() and content == sessionId) { if (!content.isEmpty() and !sessionId.isEmpty() and content == sessionId) {
return; return;
} }
@ -88,7 +88,7 @@ ApplicationManager1Service::ApplicationManager1Service(std::unique_ptr<Identifie
} }
if (flag.open(QFile::WriteOnly | QFile::Truncate)) { if (flag.open(QFile::WriteOnly | QFile::Truncate)) {
flag.write(sessionId); flag.write(sessionId, sessionId.size());
} }
scanAutoStart(); scanAutoStart();

View File

@ -47,22 +47,7 @@ void PropertiesForwarder::PropertyChanged()
auto value = sig.read(sender); auto value = sig.read(sender);
auto childs = sender->children(); auto childs = sender->children();
QString interface; auto msg = QDBusMessage::createSignal(m_path, "org.freedesktop.DBus.Properties", "PropertiesChanged");
for (const auto &adaptor : childs) {
if (adaptor->inherits("QDBusAbstractAdaptor")) {
const auto *adaptorMo = adaptor->metaObject();
if (adaptorMo->indexOfProperty(propName) != -1) {
interface = getDBusInterface(adaptor->metaObject()->metaType());
break;
}
}
};
if (interface.isEmpty()) {
return;
}
auto msg = QDBusMessage::createSignal(m_path, interface, "PropertiesChanged");
msg << QString{ApplicationInterface}; msg << QString{ApplicationInterface};
msg << QVariantMap{{QString{propName}, value}}; msg << QVariantMap{{QString{propName}, value}};
msg << QStringList{}; msg << QStringList{};