swift
Loading...
Searching...
No Matches
contextnetwork.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
7#include "core/application.h"
11#include "misc/dbusserver.h"
12
13using namespace swift::config;
14using namespace swift::core;
15using namespace swift::misc;
16
17namespace swift::core::context
18{
20 CDBusServer *server, QDBusConnection &connection)
21 {
22 switch (mode)
23 {
24 case CCoreFacadeConfig::Local: return new CContextNetwork(mode, runtime);
26 {
27 auto *context = new CContextNetwork(mode, runtime);
28 context->registerWithDBus(ObjectPath(), server);
29 return context;
30 }
32 return new CContextNetworkProxy(CDBusServer::coreServiceName(connection), connection, mode, runtime);
34 default: return new CContextNetworkEmpty(runtime);
35 }
36 }
37
38#ifdef SWIFT_VATSIM_SUPPORT
39 bool IContextNetwork::getEnvironmentClientIdAndKey(int &id, QString &key)
40 {
41 // init values
42 id = 0;
43 key = "";
44
45 // only allow overwrite via environment variable in dev builds
47 {
48 return false;
49 }
50
51 const QString clientIdAsString = qEnvironmentVariable("SWIFT_VATSIM_CLIENT_ID");
52 bool ok = true;
53 id = clientIdAsString.toInt(&ok, 0); // base 0 means C convention
54 if (!ok || id == 0)
55 {
56 return false;
57 }
58 key = qEnvironmentVariable("SWIFT_VATSIM_CLIENT_KEY").toLower();
59 return !key.isEmpty();
60 }
61#endif
62
63} // namespace swift::core::context
static bool isLocalDeveloperDebugBuild()
Local build for developers.
ContextMode
How to handle a given context.
@ NotUsed
during shutdown or not used at all
@ Local
context runs in same process
@ Remote
context runs in a different process.
@ LocalInDBusServer
context runs in same process.
The class providing facades (the contexts) for all DBus relevant operations.
Definition corefacade.h:57
Empty context, used during shutdown/initialization.
Network context implementation.
static const QString & ObjectPath()
DBus object path.
static IContextNetwork * create(CCoreFacade *parent, CCoreFacadeConfig::ContextMode mode, swift::misc::CDBusServer *server, QDBusConnection &connection)
Factory method.
IContextNetwork(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime)
Constructor.
Custom DBusServer.
Definition dbusserver.h:34
static const QString & coreServiceName()
Default service name.
Backend services of the swift project, like dealing with the network or the simulators.
Definition actionbind.cpp:7
Free functions in swift::misc.
bool isEmpty() const const
int toInt(bool *ok, int base) const const
QString toLower() const const