Mercurial > trustbridge
comparison ui/processhelp_linux.cpp @ 1371:23df332b2a4c
(issue179) Read install signature timestamp from config
This also changes the way the sigDt is propgated to the
MainWindow. It no longer uses the settings but hands
it over as a parameter directly.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 24 Nov 2014 15:48:49 +0100 |
parents | 2a1aa9df8f11 |
children | 96f640c88d10 |
comparison
equal
deleted
inserted
replaced
1370:289cb3554c55 | 1371:23df332b2a4c |
---|---|
7 */ | 7 */ |
8 #ifndef WIN32 | 8 #ifndef WIN32 |
9 | 9 |
10 #include "processhelp.h" | 10 #include "processhelp.h" |
11 #include "linuxlockfile.h" | 11 #include "linuxlockfile.h" |
12 #include "util.h" | |
12 | 13 |
13 #include <fcntl.h> | 14 #include <fcntl.h> |
14 #include <semaphore.h> | 15 #include <semaphore.h> |
15 | 16 |
16 #include <QDebug> | 17 #include <QDebug> |
17 #include <QDir> | 18 #include <QDir> |
18 #include <QStandardPaths> | 19 #include <QStandardPaths> |
20 #include <QApplication> | |
19 | 21 |
20 int lockFileFD = -1; | 22 int lockFileFD = -1; |
21 | 23 |
22 const QList<int> ProcessHelp::getProcessesIdForName(const QString &processName) { | 24 const QList<int> ProcessHelp::getProcessesIdForName(const QString &processName) { |
23 // TODO (issue39) | 25 // TODO (issue39) |
45 | 47 |
46 void ProcessHelp::cleanUp() { | 48 void ProcessHelp::cleanUp() { |
47 close_lockfile(lockFileFD); | 49 close_lockfile(lockFileFD); |
48 } | 50 } |
49 | 51 |
52 QDateTime ProcessHelp::getSigDtFromInstSettings() { | |
53 QString pathCandidate; | |
54 QDateTime retval; | |
55 if (is_system_install()) { | |
56 pathCandidate = "/etc/" + qApp->applicationName() + "/" + | |
57 qApp->applicationName() + "-inst.cfg"; | |
58 } else { | |
59 qDebug() << "Application name is : " << qApp->applicationName(); | |
60 pathCandidate = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + | |
61 + "/" + qApp->organizationName() + "/" + qApp->applicationName() + "-inst.cfg"; | |
62 } | |
63 QFileInfo fi(pathCandidate); | |
64 if (!fi.isReadable()) { | |
65 qDebug() << "Failed to find install config: " << pathCandidate; | |
66 return retval; | |
67 } | |
68 QFile instcfg(pathCandidate); | |
69 if (!instcfg.open(QIODevice::ReadOnly)) { | |
70 qDebug() << "Failed to open install config"; | |
71 return retval; | |
72 } | |
73 QByteArray data; | |
74 int readLines = 0; | |
75 while (readLines < 100) { | |
76 readLines++; | |
77 data = instcfg.readLine(); | |
78 if (data.isEmpty()) { | |
79 qDebug() << "Failed to read install config"; | |
80 break; | |
81 } | |
82 QString line = QString::fromLocal8Bit(data); | |
83 if (line.startsWith("SIG_DATE=")) { | |
84 bool ok = false; | |
85 QString sigDate = line.replace("SIG_DATE=",""); | |
86 long sigSecs = sigDate.toLong(&ok); | |
87 if (!ok) { | |
88 qDebug() << "Failed to convert sig date to long"; | |
89 } | |
90 retval = QDateTime::fromTime_t(sigSecs); | |
91 break; | |
92 } | |
93 } | |
94 qDebug() << "Sig time is: " << retval; | |
95 instcfg.close(); | |
96 return retval; | |
97 } | |
50 #endif /* Not WIN32 */ | 98 #endif /* Not WIN32 */ |