mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-19 00:27:06 +00:00
feat(GODT-2666): feat(GODT-2667): introduce sessionID in bridge.
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
#include "Pch.h"
|
||||
#include "CommandLine.h"
|
||||
#include "Settings.h"
|
||||
#include <bridgepp/SessionID/SessionID.h>
|
||||
|
||||
|
||||
using namespace bridgepp;
|
||||
@ -142,5 +143,12 @@ CommandLineOptions parseCommandLine(int argc, char *argv[]) {
|
||||
|
||||
options.logLevel = parseLogLevel(argc, argv);
|
||||
|
||||
options.sessionID = parseGoCLIStringArgument(argc, argv, { "session-id" });
|
||||
if (options.sessionID.isEmpty()) {
|
||||
options.sessionID = newSessionID();
|
||||
options.bridgeArgs.append("--session-id");
|
||||
options.bridgeArgs.append(options.sessionID);
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@ struct CommandLineOptions {
|
||||
bridgepp::Log::Level logLevel { bridgepp::Log::defaultLevel }; ///< The log level
|
||||
bool noWindow { false }; ///< Should the application start without displaying the main window?
|
||||
bool useSoftwareRenderer { false }; ///< Should QML be renderer in software (i.e. without rendering hardware interface).
|
||||
QString sessionID; ///< The sessionID.
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
#include "LogUtils.h"
|
||||
#include "BuildConfig.h"
|
||||
#include <bridgepp/Log/LogUtils.h>
|
||||
#include <bridgepp/BridgeUtils.h>
|
||||
|
||||
|
||||
using namespace bridgepp;
|
||||
@ -28,7 +27,7 @@ using namespace bridgepp;
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return A reference to the log.
|
||||
//****************************************************************************************************************************************************
|
||||
Log &initLog() {
|
||||
Log &initLog(QString const &sessionID) {
|
||||
Log &log = app().log();
|
||||
log.registerAsQtMessageHandler();
|
||||
log.setEchoInConsole(true);
|
||||
@ -41,7 +40,7 @@ Log &initLog() {
|
||||
|
||||
// create new GUI log file
|
||||
QString error;
|
||||
if (!log.startWritingToFile(logsDir.absoluteFilePath(QString("gui_v%1_%2.log").arg(PROJECT_VER).arg(QDateTime::currentSecsSinceEpoch())), &error)) {
|
||||
if (!log.startWritingToFile(logsDir.absoluteFilePath(QString("%1_000_gui_v%2_%3.log").arg(sessionID, PROJECT_VER, PROJECT_TAG)), &error)) {
|
||||
log.error(error);
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
#include <bridgepp/Log/Log.h>
|
||||
|
||||
|
||||
bridgepp::Log &initLog(); ///< Initialize the application log.
|
||||
bridgepp::Log &initLog(QString const &sessionID); ///< Initialize the application log.
|
||||
|
||||
|
||||
#endif //BRIDGE_GUI_LOG_UTILS_H
|
||||
|
||||
@ -286,7 +286,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
initQtApplication();
|
||||
|
||||
Log &log = initLog();
|
||||
CommandLineOptions const cliOptions = parseCommandLine(argc, argv);
|
||||
Log &log = initLog(cliOptions.sessionID);
|
||||
|
||||
QLockFile lock(bridgepp::userCacheDir() + "/" + bridgeGUILock);
|
||||
if (!checkSingleInstance(lock)) {
|
||||
@ -294,8 +295,6 @@ int main(int argc, char *argv[]) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CommandLineOptions const cliOptions = parseCommandLine(argc, argv);
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
registerSecondInstanceHandler();
|
||||
setDockIconVisibleState(!cliOptions.noWindow);
|
||||
|
||||
Reference in New Issue
Block a user