Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int main(int argc, char *argv[])
}

QStringList argList;
argList << QString::number(QCoreApplication::applicationPid()) << QDBusConnection::systemBus().baseService();
argList << QDBusConnection::systemBus().baseService();
qDebug() << "Starting deepin-diskmanager-authenticateProxy with args:" << argList;
proc.startDetached("deepin-diskmanager-authenticateProxy", argList);

Expand Down
37 changes: 14 additions & 23 deletions service/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,15 @@
#include "log.h"

#include <QCoreApplication>
#include <DLog>

Check warning on line 9 in service/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <DLog> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 9 in service/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DLog> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusConnection>

Check warning on line 10 in service/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 10 in service/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusError>

Check warning on line 11 in service/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDBusError> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 11 in service/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusError> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusServiceWatcher>

Check warning on line 12 in service/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QDBusServiceWatcher> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 12 in service/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusServiceWatcher> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QThread>

Check warning on line 13 in service/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: <QThread> not found. Please note: Cppcheck does not need standard library headers to get proper results.

Check warning on line 13 in service/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QThread> not found. Please note: Cppcheck does not need standard library headers to get proper results.

const QString DiskManagerServiceName = "com.deepin.diskmanager";
const QString DiskManagerPath = "/com/deepin/diskmanager";

void checkFrontEndQuit(uint frontEndPid)
{
qDebug() << "checkFrontEndQuit" << frontEndPid;
QString frontEndExe = QString("/proc/%1/exe").arg(frontEndPid);
QFileInfo info(frontEndExe);

if (QFileInfo(info.symLinkTarget()).fileName() != "deepin-diskmanager") {
qWarning() << "Front-end process has quit";
QCoreApplication::exit(0);
}
}

int main(int argc, char *argv[])
{
//set env otherwise utils excutecmd excute command failed
Expand All @@ -40,20 +29,17 @@
PATH += ":/sbin";
qputenv("PATH", PATH.toLatin1());

uint frontEndPid;
QString frontEndDBusName;
if (argc < 3) {
if (argc < 2) {
qCritical() << "Invalid arguments count:" << argc;
return 1;
} else {
qDebug() << "Arguments count:" << argc;
QString frontEndPidString(argv[1]);
frontEndPid = frontEndPidString.toUInt();
if (frontEndPid == 0) {
qCritical() << "Invalid front-end PID:" << frontEndPid;
frontEndDBusName = QString(argv[1]);
if (frontEndDBusName.isEmpty()) {
qCritical() << "Invalid front-end DBus name";
return 1;
}
frontEndDBusName = QString(argv[2]);
}

QCoreApplication a(argc, argv);
Expand Down Expand Up @@ -96,11 +82,16 @@
exit(0x0002);
}

QTimer timer;
QObject::connect(&timer, &QTimer::timeout, [frontEndPid] {
checkFrontEndQuit(frontEndPid);
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(
frontEndDBusName,
QDBusConnection::systemBus(),
QDBusServiceWatcher::WatchForUnregistration,
&a
);
QObject::connect(watcher, &QDBusServiceWatcher::serviceUnregistered, [](const QString &name) {
qWarning() << "Front-end service unregistered:" << name;
QCoreApplication::exit(0);
});
timer.start(1000);

return a.exec();
}
Loading