App refactoring finished
This commit is contained in:
parent
3ce1ec708d
commit
aed688224b
7 changed files with 36 additions and 76 deletions
|
@ -36,15 +36,14 @@
|
|||
#include "ui/pages_logic/protocols/ShadowSocksLogic.h"
|
||||
|
||||
|
||||
AmneziaApplication::AmneziaApplication(int &argc, char *argv[], bool allowSecondary,
|
||||
SingleApplication::Options options, int timeout, const QString &userData):
|
||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||
QAPPLICATION_CLASS(argc, argv);
|
||||
#else
|
||||
SingleApplication(argc, argv, allowSecondary, options, timeout, userData)
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||
AmneziaApplication::AmneziaApplication(int &argc, char *argv[]):
|
||||
AMNEZIA_BASE_CLASS(argc, argv)
|
||||
#else
|
||||
AmneziaApplication::AmneziaApplication(int &argc, char *argv[], bool allowSecondary,
|
||||
SingleApplication::Options options, int timeout, const QString &userData):
|
||||
SingleApplication(argc, argv, allowSecondary, options, timeout, userData)
|
||||
#endif
|
||||
{
|
||||
setQuitOnLastWindowClosed(false);
|
||||
m_settings = std::shared_ptr<Settings>(new Settings);
|
||||
|
@ -59,6 +58,9 @@ AmneziaApplication::~AmneziaApplication()
|
|||
|
||||
QObject::disconnect(m_uiLogic, 0,0,0);
|
||||
delete m_uiLogic;
|
||||
|
||||
delete m_protocolProps;
|
||||
delete m_containerProps;
|
||||
}
|
||||
|
||||
void AmneziaApplication::init()
|
||||
|
@ -112,7 +114,7 @@ void AmneziaApplication::init()
|
|||
if (m_parser.isSet("a")) m_uiLogic->showOnStartup();
|
||||
else emit m_uiLogic->show();
|
||||
#else
|
||||
uiLogic->showOnStartup();
|
||||
m_uiLogic->showOnStartup();
|
||||
#endif
|
||||
|
||||
// TODO - fix
|
||||
|
@ -144,7 +146,6 @@ void AmneziaApplication::registerTypes()
|
|||
qRegisterMetaType<PageProtocolLogicBase *>("PageProtocolLogicBase *");
|
||||
|
||||
|
||||
|
||||
declareQmlPageEnum();
|
||||
declareQmlProtocolEnum();
|
||||
declareQmlContainerEnum();
|
||||
|
@ -152,11 +153,11 @@ void AmneziaApplication::registerTypes()
|
|||
qmlRegisterType<PageType>("PageType", 1, 0, "PageType");
|
||||
qmlRegisterType<QRCodeReader>("QRCodeReader", 1, 0, "QRCodeReader");
|
||||
|
||||
QScopedPointer<ContainerProps> containerProps(new ContainerProps);
|
||||
qmlRegisterSingletonInstance("ContainerProps", 1, 0, "ContainerProps", containerProps.get());
|
||||
m_containerProps = new ContainerProps;
|
||||
qmlRegisterSingletonInstance("ContainerProps", 1, 0, "ContainerProps", m_containerProps);
|
||||
|
||||
QScopedPointer<ProtocolProps> protocolProps(new ProtocolProps);
|
||||
qmlRegisterSingletonInstance("ProtocolProps", 1, 0, "ProtocolProps", protocolProps.get());
|
||||
m_protocolProps = new ProtocolProps;
|
||||
qmlRegisterSingletonInstance("ProtocolProps", 1, 0, "ProtocolProps", m_protocolProps);
|
||||
}
|
||||
|
||||
void AmneziaApplication::loadFonts()
|
||||
|
|
|
@ -13,13 +13,12 @@
|
|||
#include "ui/uilogic.h"
|
||||
#include "configurators/vpn_configurator.h"
|
||||
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
#define AMNEZIA_BASE_CLASS SingleApplication
|
||||
#define QAPPLICATION_CLASS QGuiApplication
|
||||
#include "singleapplication.h"
|
||||
//#undef QAPPLICATION_CLASS
|
||||
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
|
||||
#define AMNEZIA_BASE_CLASS QGuiApplication
|
||||
#else
|
||||
#define AMNEZIA_BASE_CLASS QApplication
|
||||
#define AMNEZIA_BASE_CLASS SingleApplication
|
||||
#define QAPPLICATION_CLASS QApplication
|
||||
#include "singleapplication.h"
|
||||
#endif
|
||||
|
||||
class AmneziaApplication : public AMNEZIA_BASE_CLASS
|
||||
|
@ -47,6 +46,9 @@ private:
|
|||
std::shared_ptr<VpnConfigurator> m_configurator;
|
||||
std::shared_ptr<ServerController> m_serverController;
|
||||
|
||||
ContainerProps* m_containerProps;
|
||||
ProtocolProps* m_protocolProps;
|
||||
|
||||
QTranslator* m_translator;
|
||||
QCommandLineParser m_parser;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ QT += widgets core gui network xml remoteobjects quick svg
|
|||
|
||||
TARGET = AmneziaVPN
|
||||
TEMPLATE = app
|
||||
#CONFIG += console
|
||||
|
||||
CONFIG += qtquickcompiler
|
||||
CONFIG += qzxing_multimedia \
|
||||
|
@ -287,7 +286,7 @@ android {
|
|||
}
|
||||
|
||||
ios {
|
||||
message("Client ios build")
|
||||
message("Client iOS build")
|
||||
CONFIG += static
|
||||
CONFIG += file_copies
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ SecureQSettings::SecureQSettings(const QString &organization, const QString &app
|
|||
|
||||
QVariant SecureQSettings::value(const QString &key, const QVariant &defaultValue) const
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
if (m_cache.contains(key)) {
|
||||
return m_cache.value(key);
|
||||
}
|
||||
|
@ -76,6 +78,8 @@ QVariant SecureQSettings::value(const QString &key, const QVariant &defaultValue
|
|||
|
||||
void SecureQSettings::setValue(const QString &key, const QVariant &value)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
if (encryptionRequired() && encryptedKeys.contains(key)) {
|
||||
if (!getEncKey().isEmpty() && !getEncIv().isEmpty()) {
|
||||
QByteArray decryptedValue;
|
||||
|
@ -103,6 +107,8 @@ void SecureQSettings::setValue(const QString &key, const QVariant &value)
|
|||
|
||||
void SecureQSettings::remove(const QString &key)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
m_settings.remove(key);
|
||||
m_cache.remove(key);
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <QSettings>
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
|
||||
|
||||
constexpr const char* settingsKeyTag = "settingsKeyTag";
|
||||
constexpr const char* settingsIvTag = "settingsIvTag";
|
||||
|
@ -40,6 +43,7 @@ private:
|
|||
|
||||
const QByteArray magicString { "EncData" }; // Magic keyword used for mark encrypted QByteArray
|
||||
|
||||
mutable QMutex mutex;
|
||||
};
|
||||
|
||||
#endif // SECUREQSETTINGS_H
|
||||
|
|
|
@ -295,60 +295,10 @@ void Settings::removeVpnSites(RouteMode mode, const QStringList &sites)
|
|||
setVpnSites(mode, sitesMap);
|
||||
}
|
||||
|
||||
//void Settings::addVpnForwardSite(const QString &site, const QString &ip)
|
||||
//{
|
||||
// auto sites = vpnForwardSites();
|
||||
// QStringList l = sites.value(site).toStringList();
|
||||
// if (!l.contains(ip)) {
|
||||
// l.append(ip);
|
||||
// setVpnForwardSites(sites);
|
||||
// }
|
||||
//}
|
||||
|
||||
//QStringList Settings::getVpnForwardIps() const
|
||||
//{
|
||||
// QStringList ips;
|
||||
// const QVariantMap &m = vpnForwardSites();
|
||||
// for (const QVariant &v : m) {
|
||||
// ips.append(v.toStringList());
|
||||
// }
|
||||
// ips.removeDuplicates();
|
||||
// return ips;
|
||||
//}
|
||||
|
||||
//void Settings::addVpnExceptSite(const QString &site, const QString &ip)
|
||||
//{
|
||||
// auto sites = vpnExceptSites();
|
||||
// QStringList l = sites.value(site).toStringList();
|
||||
// if (!l.contains(ip)) {
|
||||
// l.append(ip);
|
||||
// setVpnExceptSites(sites);
|
||||
// }
|
||||
//}
|
||||
|
||||
//QStringList Settings::getVpnExceptIps() const
|
||||
//{
|
||||
// QStringList ips;
|
||||
// const QVariantMap &m = vpnExceptSites();
|
||||
// for (const QVariant &v : m) {
|
||||
// ips.append(v.toStringList());
|
||||
// }
|
||||
// ips.removeDuplicates();
|
||||
// return ips;
|
||||
//}
|
||||
|
||||
QString Settings::primaryDns() const { return m_settings.value("Conf/primaryDns", cloudFlareNs1).toString(); }
|
||||
|
||||
QString Settings::secondaryDns() const { return m_settings.value("Conf/secondaryDns", cloudFlareNs2).toString(); }
|
||||
|
||||
//void Settings::setServerCredentials(const ServerCredentials &credentials)
|
||||
//{
|
||||
// setServerName(credentials.hostName);
|
||||
// setServerPort(credentials.port);
|
||||
// setUserName(credentials.userName);
|
||||
// setPassword(credentials.password);
|
||||
//}
|
||||
|
||||
ServerCredentials Settings::defaultServerCredentials() const
|
||||
{
|
||||
return serverCredentials(defaultServerIndex());
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QMutex>
|
||||
|
||||
#include "core/defs.h"
|
||||
#include "containers/containers_defs.h"
|
||||
|
@ -27,7 +26,6 @@ public:
|
|||
|
||||
ServerCredentials defaultServerCredentials() const;
|
||||
ServerCredentials serverCredentials(int index) const;
|
||||
//void setServerCredentials(const ServerCredentials &credentials);
|
||||
|
||||
QJsonArray serversArray() const { return QJsonDocument::fromJson(m_settings.value("Servers/serversList").toByteArray()).array(); }
|
||||
void setServersArray(const QJsonArray &servers) { m_settings.setValue("Servers/serversList", QJsonDocument(servers).toJson()); }
|
||||
|
@ -117,7 +115,7 @@ public:
|
|||
|
||||
private:
|
||||
SecureQSettings m_settings;
|
||||
QMutex m_mutex;
|
||||
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue