mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
Long live FsdClient
This commit is contained in:
@@ -10,8 +10,11 @@
|
||||
#include "blackcore/context/contextnetworkempty.h"
|
||||
#include "blackcore/context/contextnetworkimpl.h"
|
||||
#include "blackcore/context/contextnetworkproxy.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
|
||||
@@ -31,5 +34,38 @@ namespace BlackCore
|
||||
return new CContextNetworkEmpty(runtime);
|
||||
}
|
||||
}
|
||||
|
||||
const QList<QCommandLineOption> &IContextNetwork::getCmdLineOptions()
|
||||
{
|
||||
static const QList<QCommandLineOption> e;
|
||||
static const QList<QCommandLineOption> opts
|
||||
{
|
||||
QCommandLineOption({ "idAndKey", "clientIdAndKey" },
|
||||
QCoreApplication::translate("CContextNetwork", "Client id and key pair separated by ':', e.g. <id>:<key>."), "clientIdAndKey")
|
||||
};
|
||||
|
||||
// only in not officially shipped versions
|
||||
return (CBuildConfig::isLocalDeveloperDebugBuild()) ? opts : e;
|
||||
}
|
||||
|
||||
bool IContextNetwork::getCmdLineClientIdAndKey(int &id, QString &key)
|
||||
{
|
||||
// init values
|
||||
id = 0;
|
||||
key = "";
|
||||
|
||||
// split parser values
|
||||
if (IContextNetwork::getCmdLineOptions().isEmpty()) { return false; } // no such option, avoid warnings
|
||||
const QString clientIdAndKey = sApp->getParserValue("clientIdAndKey").toLower();
|
||||
if (clientIdAndKey.isEmpty() || !clientIdAndKey.contains(':')) { return false; }
|
||||
const QStringList stringList = clientIdAndKey.split(':');
|
||||
const QString clientIdAsString = stringList[0];
|
||||
bool ok = true;
|
||||
id = clientIdAsString.toInt(&ok, 0); // base 0 means C convention
|
||||
if (!ok || id == 0) { return false; }
|
||||
key = stringList[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namesapce
|
||||
} // namesapce
|
||||
|
||||
Reference in New Issue
Block a user