mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Ref T199, data directory will be tagged
A information JSON file will be written into the data directory. This can be used to display other swift versions.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "blackcore/setupreader.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackmisc/atomicfile.h"
|
||||
#include "blackmisc/applicationinfo.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
@@ -102,7 +103,7 @@ namespace BlackCore
|
||||
|
||||
CApplication::CApplication(const QString &applicationName, CApplicationInfo::Application application, bool init) :
|
||||
m_accessManager(new QNetworkAccessManager(this)),
|
||||
m_applicationInfo(application, QCoreApplication::applicationDirPath(), CBuildConfig::getVersionString(), CProcessInfo::currentProcess()),
|
||||
m_applicationInfo(application),
|
||||
m_cookieManager( {}, this), m_applicationName(applicationName), m_coreFacadeConfig(CCoreFacadeConfig::allEmpty())
|
||||
{
|
||||
Q_ASSERT_X(!sApp, Q_FUNC_INFO, "already initialized");
|
||||
@@ -131,6 +132,7 @@ namespace BlackCore
|
||||
m_alreadyRunning = CApplication::getRunningApplications().containsApplication(CApplication::getSwiftApplication());
|
||||
this->initParser();
|
||||
this->initLogging();
|
||||
this->tagApplicationDataDirectory();
|
||||
|
||||
//
|
||||
// cmd line arguments not yet parsed here
|
||||
@@ -221,16 +223,17 @@ namespace BlackCore
|
||||
this->gracefulShutdown();
|
||||
}
|
||||
|
||||
CApplicationInfo CApplication::getApplicationInfo() const
|
||||
const CApplicationInfo &CApplication::getApplicationInfo() const
|
||||
{
|
||||
return { CApplication::getSwiftApplication(), QCoreApplication::applicationFilePath(), CBuildConfig::getVersionString(), CProcessInfo::currentProcess() };
|
||||
static const CApplicationInfo a(CApplication::getSwiftApplication());
|
||||
return a;
|
||||
}
|
||||
|
||||
CApplicationInfoList CApplication::getRunningApplications()
|
||||
{
|
||||
CApplicationInfoList apps;
|
||||
apps.convertFromJsonNoThrow(CFileUtils::readLockedFileToString(swiftDataRoot() + "apps.json"), {}, {});
|
||||
apps.removeIf([](const CApplicationInfo & info) { return !info.processInfo().exists(); });
|
||||
apps.removeIf([](const CApplicationInfo & info) { return !info.getProcessInfo().exists(); });
|
||||
return apps;
|
||||
}
|
||||
|
||||
@@ -267,8 +270,6 @@ namespace BlackCore
|
||||
m_singleApplication = singleApplication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString CApplication::getExecutableForApplication(CApplicationInfo::Application application) const
|
||||
{
|
||||
QString search;
|
||||
@@ -1535,4 +1536,14 @@ namespace BlackCore
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
void CApplication::tagApplicationDataDirectory()
|
||||
{
|
||||
const QString d = CDirectoryUtils::normalizedApplicationDataDirectory();
|
||||
const QDir dir(d);
|
||||
if (!dir.exists() || !dir.isReadable()) { return; }
|
||||
const QString aiStr(this->getApplicationInfo().toJsonString());
|
||||
const QString filePath(CFileUtils::appendFilePaths(dir.path(), CApplicationInfo::fileName())); // will be overridden by next swift app
|
||||
CFileUtils::writeStringToFile(aiStr, filePath);
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace BlackCore
|
||||
virtual ~CApplication();
|
||||
|
||||
//! Application information
|
||||
BlackMisc::CApplicationInfo getApplicationInfo() const;
|
||||
const BlackMisc::CApplicationInfo &getApplicationInfo() const;
|
||||
|
||||
//! Information about all running apps (including this one only if exec() has already been called)
|
||||
static BlackMisc::CApplicationInfoList getRunningApplications();
|
||||
@@ -589,6 +589,9 @@ namespace BlackCore
|
||||
int maxRedirects,
|
||||
std::function<QNetworkReply *(QNetworkAccessManager &, const QNetworkRequest &)> requestOrPostMethod);
|
||||
|
||||
//! Write meta information into the application directory so other swift versions can display them
|
||||
void tagApplicationDataDirectory();
|
||||
|
||||
QNetworkAccessManager *m_accessManager = nullptr; //!< single network access manager
|
||||
BlackMisc::CApplicationInfo m_applicationInfo; //!< Application if specified
|
||||
QScopedPointer<CCoreFacade> m_coreFacade; //!< core facade if any
|
||||
|
||||
Reference in New Issue
Block a user