Skip to content

Commit

Permalink
feat: create pid file to cache folder
Browse files Browse the repository at this point in the history
Change-Id: I2a24f82b51709f700696f69e1d37a745df5ac05a
  • Loading branch information
justforlxz committed Feb 6, 2018
1 parent 564c008 commit e7204e6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "policykitlistener.h"

#include <QDebug>
#include <QDir>
#include <QFile>
#include <QStandardPaths>

DWIDGET_USE_NAMESPACE

Expand All @@ -35,12 +38,12 @@ int main(int argc, char *argv[])
{
DApplication::loadDXcbPlugin();
DApplication a(argc, argv);
a.setOrganizationName("deepin");
a.setApplicationName(APP_NAME);
a.setApplicationDisplayName(APP_DISPLAY_NAME);
a.setApplicationVersion("0.1");
a.setQuitOnLastWindowClosed(false);


if (!a.setSingleInstance(APP_NAME, DApplication::UserScope)) {
qWarning() << "polkit is running!";
return 0;
Expand All @@ -54,6 +57,21 @@ int main(int argc, char *argv[])
return -1;
}

// create PID file to ~/.cache/deepin/dde-polkit-agent
const QString cachePath = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first();

QDir dir(cachePath);
if (!dir.exists()) {
dir.mkpath(cachePath);
}

QFile PID(cachePath + QDir::separator() + "pid");
if (PID.open(QIODevice::WriteOnly)) {
QTextStream out(&PID);
out << getpid();
PID.close();
}

a.setTheme("light");
a.loadTranslator();

Expand Down

0 comments on commit e7204e6

Please sign in to comment.