Add installer
This commit is contained in:
parent
c9bc8aa8c1
commit
a2a5cafc5f
73 changed files with 4354 additions and 488 deletions
|
|
@ -1,76 +0,0 @@
|
|||
QT += widgets core gui network xml
|
||||
|
||||
TARGET = AmneziaVPN
|
||||
TEMPLATE = app
|
||||
#CONFIG += console
|
||||
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
HEADERS += \
|
||||
core/router.h \
|
||||
debug.h \
|
||||
defines.h \
|
||||
runguard.h \
|
||||
ui/Controls/SlidingStackedWidget.h \
|
||||
ui/mainwindow.h \
|
||||
|
||||
SOURCES += \
|
||||
core/router.cpp \
|
||||
debug.cpp \
|
||||
main.cpp \
|
||||
runguard.cpp \
|
||||
ui/Controls/SlidingStackedWidget.cpp \
|
||||
ui/mainwindow.cpp \
|
||||
|
||||
|
||||
FORMS += ui/mainwindow.ui
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
||||
TRANSLATIONS = \
|
||||
translations/amneziavpn.en.ts \
|
||||
translations/amneziavpn.ru.ts
|
||||
|
||||
win32 {
|
||||
|
||||
OTHER_FILES += platform_win/vpnclient.rc
|
||||
RC_FILE = platform_win/vpnclient.rc
|
||||
|
||||
HEADERS +=
|
||||
SOURCES +=
|
||||
|
||||
#CONFIG -= embed_manifest_exe
|
||||
#DEFINES += _CRT_SECURE_NO_WARNINGS VPNCLIENT_TAPSIGNED
|
||||
#QMAKE_LFLAGS += /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\"
|
||||
|
||||
VERSION = 1.1.1.1
|
||||
QMAKE_TARGET_COMPANY = "AmneziaVPN"
|
||||
QMAKE_TARGET_PRODUCT = "AmneziaVPN"
|
||||
|
||||
#CONFIG -= embed_manifest_exe
|
||||
|
||||
LIBS += \
|
||||
-luser32 \
|
||||
-lrasapi32 \
|
||||
-lshlwapi \
|
||||
-liphlpapi \
|
||||
-lws2_32 \
|
||||
-liphlpapi \
|
||||
-lgdi32
|
||||
|
||||
#LIBS += -L$$PWD/../../../../../../../OpenSSL-Win32/lib/ -llibcrypto
|
||||
|
||||
#MT_PATH = \"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/bin/x64/mt.exe\"
|
||||
#WIN_PWD = $$replace(PWD, /, \\)
|
||||
#OUT_PWD_WIN = $$replace(OUT_PWD, /, \\)
|
||||
|
||||
#!win32-g++: QMAKE_POST_LINK = "$$MT_PATH -manifest $$quote($$WIN_PWD\\platform_win\\$$basename(TARGET).exe.manifest) -outputresource:$$quote($$OUT_PWD_WIN\\$(DESTDIR_TARGET);1)"
|
||||
# else: QMAKE_POST_LINK = "$$MT_PATH -manifest $$PWD/platform_win/$$basename(TARGET).exe.manifest -outputresource:$$OUT_PWD/$(DESTDIR_TARGET)"
|
||||
|
||||
}
|
||||
|
||||
|
||||
macx {
|
||||
ICON = $$PWD/images/app.icns
|
||||
}
|
||||
67
client/client.pro
Normal file
67
client/client.pro
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
QT += widgets core gui network xml
|
||||
|
||||
TARGET = AmneziaVPN
|
||||
TEMPLATE = app
|
||||
#CONFIG += console
|
||||
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
HEADERS += \
|
||||
core/router.h \
|
||||
debug.h \
|
||||
defines.h \
|
||||
runguard.h \
|
||||
ui/Controls/SlidingStackedWidget.h \
|
||||
ui/mainwindow.h \
|
||||
|
||||
SOURCES += \
|
||||
core/router.cpp \
|
||||
debug.cpp \
|
||||
main.cpp \
|
||||
runguard.cpp \
|
||||
ui/Controls/SlidingStackedWidget.cpp \
|
||||
ui/mainwindow.cpp \
|
||||
|
||||
|
||||
FORMS += ui/mainwindow.ui
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
||||
TRANSLATIONS = \
|
||||
translations/amneziavpn.en.ts \
|
||||
translations/amneziavpn.ru.ts
|
||||
|
||||
CONFIG(release, debug|release) {
|
||||
DESTDIR = $$PWD/../../AmneziaVPN-build/client/release
|
||||
MOC_DIR = $$DESTDIR
|
||||
OBJECTS_DIR = $$DESTDIR
|
||||
RCC_DIR = $$DESTDIR
|
||||
}
|
||||
|
||||
win32 {
|
||||
OTHER_FILES += platform_win/vpnclient.rc
|
||||
RC_FILE = platform_win/vpnclient.rc
|
||||
|
||||
HEADERS +=
|
||||
SOURCES +=
|
||||
|
||||
VERSION = 1.1.1.1
|
||||
QMAKE_TARGET_COMPANY = "AmneziaVPN"
|
||||
QMAKE_TARGET_PRODUCT = "AmneziaVPN"
|
||||
|
||||
LIBS += \
|
||||
-luser32 \
|
||||
-lrasapi32 \
|
||||
-lshlwapi \
|
||||
-liphlpapi \
|
||||
-lws2_32 \
|
||||
-liphlpapi \
|
||||
-lgdi32
|
||||
|
||||
#LIBS += -L$$PWD/../../../../../../../OpenSSL-Win32/lib/ -llibcrypto
|
||||
}
|
||||
|
||||
macx {
|
||||
ICON = $$PWD/images/app.icns
|
||||
}
|
||||
132
client/debug.cpp
132
client/debug.cpp
|
|
@ -1,126 +1,68 @@
|
|||
#include "debug.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QUrl>
|
||||
|
||||
#define LOGS_DIR "logs"
|
||||
#define CLIENT_LOG_SUFFIX "amneziavpn.log"
|
||||
#define MAX_LOG_FILES 5
|
||||
#define FORMAT_STRING "yyyy-MM-dd--hh-mm-ss"
|
||||
#include "debug.h"
|
||||
#include "defines.h"
|
||||
|
||||
QFile Debug::m_clientLog;
|
||||
QTextStream Debug::m_clientLogTextStream;
|
||||
QString Debug::m_clientLogName;
|
||||
QFile Debug::m_file;
|
||||
QTextStream Debug::m_textStream;
|
||||
QString Debug::m_logFileName;
|
||||
|
||||
void debugMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
void debugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
// Skip Qt warnings
|
||||
if (msg.contains("known incorrect sRGB profile")) return;
|
||||
if (msg.contains("libpng warning")) return;
|
||||
if (msg.contains("Unknown property ffont")) return;
|
||||
if (msg.simplified().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Debug::m_clientLogTextStream << qFormatLogMessage(type, context, msg) << endl << flush;
|
||||
// Temporally disabled
|
||||
if (msg.startsWith("Unknown property") || msg.startsWith("Could not create pixmap")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Debug::m_textStream << qFormatLogMessage(type, context, msg) << endl << flush;
|
||||
}
|
||||
|
||||
bool Debug::init()
|
||||
{
|
||||
QString path = qApp->applicationDirPath();
|
||||
QString path = logsDir();
|
||||
QDir appDir(path);
|
||||
|
||||
// init function is called before exec application, so data location folder may not exist
|
||||
if (!appDir.exists())
|
||||
{
|
||||
qWarning() << "Debug: init: log directory doesn't exist or mkpath command error:" << path;
|
||||
if (!appDir.mkpath(path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!appDir.exists(LOGS_DIR) && !appDir.mkdir(LOGS_DIR))
|
||||
{
|
||||
qWarning() << "Debug: init: log directory doesn't exist or mkdir command error:" << path << LOGS_DIR;
|
||||
return false;
|
||||
}
|
||||
m_logFileName = QString("%1.log").arg(APPLICATION_NAME);
|
||||
|
||||
if (!appDir.cd(LOGS_DIR))
|
||||
{
|
||||
qWarning() << "Debug: init: cd command error:" << path << LOGS_DIR;
|
||||
return false;
|
||||
}
|
||||
|
||||
//delete older log files
|
||||
auto clientLogsCount = 0;
|
||||
QFileInfoList logDirList = appDir.entryInfoList(
|
||||
QDir::Files | QDir::NoDotAndDotDot,
|
||||
QDir::Time);
|
||||
for (auto fileInfo : logDirList)
|
||||
{
|
||||
if ((fileInfo.completeSuffix() == CLIENT_LOG_SUFFIX &&
|
||||
++clientLogsCount > MAX_LOG_FILES))
|
||||
{
|
||||
appDir.remove(fileInfo.filePath());
|
||||
}
|
||||
}
|
||||
|
||||
//prepare log file names
|
||||
auto currentDateTime = QDateTime::currentDateTime().toString(FORMAT_STRING);
|
||||
|
||||
m_clientLogName = QString("%1.%2").arg(currentDateTime).arg(CLIENT_LOG_SUFFIX);
|
||||
return init(appDir);
|
||||
}
|
||||
|
||||
bool Debug::init(QDir& appDir)
|
||||
{
|
||||
Q_UNUSED(appDir)
|
||||
qSetMessagePattern("[%{time}|%{type}] %{message}");
|
||||
|
||||
#ifndef QT_DEBUG
|
||||
m_clientLog.setFileName(appDir.filePath(m_clientLogName));
|
||||
if (!m_clientLog.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
||||
qWarning() << "Debug::init - failed to open m_clientLog file:" << m_clientLogName;
|
||||
m_file.setFileName(appDir.filePath(m_logFileName));
|
||||
if (!m_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
qWarning() << "Cannot open log file:" << m_logFileName;
|
||||
return false;
|
||||
}
|
||||
m_clientLog.setTextModeEnabled(true);
|
||||
m_clientLogTextStream.setDevice(&m_clientLog);
|
||||
m_file.setTextModeEnabled(true);
|
||||
m_textStream.setDevice(&m_file);
|
||||
qInstallMessageHandler(debugMessageHandler);
|
||||
#else
|
||||
#ifdef DEBUG_OUTPUT_TWO_DIRECTIONAL
|
||||
m_clientLog.setFileName(appDir.filePath(m_clientLogName));
|
||||
if (!m_clientLog.open(QIODevice::WriteOnly | QIODevice::Append))
|
||||
return false;
|
||||
m_clientLog.setTextModeEnabled(true);
|
||||
m_clientLogTextStream.setDevice(&m_clientLog);
|
||||
defaultMessageHandler = qInstallMessageHandler(debugMessageHandler);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString Debug::getPathToClientLog()
|
||||
QString Debug::logsDir()
|
||||
{
|
||||
QString path = qApp->applicationDirPath();
|
||||
QDir appDir(path);
|
||||
if (!appDir.exists(LOGS_DIR) || !appDir.cd(LOGS_DIR))
|
||||
{
|
||||
qWarning() << "Debug: log directory doesn't exist or cd command error:" << path;
|
||||
return "";
|
||||
}
|
||||
|
||||
return appDir.filePath(m_clientLogName);
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/logs";
|
||||
}
|
||||
|
||||
QString Debug::getPathToLogsDir()
|
||||
bool Debug::openLogsFolder()
|
||||
{
|
||||
QString path = qApp->applicationDirPath();
|
||||
QDir appDir(path);
|
||||
if (!appDir.exists(LOGS_DIR) || !appDir.cd(LOGS_DIR))
|
||||
{
|
||||
qWarning() << "Debug: log directory doesn't exist or cd command error" << path;
|
||||
return "";
|
||||
QString path = logsDir();
|
||||
#ifdef Q_OS_WIN
|
||||
path = "file:///" + path;
|
||||
#endif
|
||||
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(path))) {
|
||||
qWarning() << "Can't open url:" << path;
|
||||
return false;
|
||||
}
|
||||
return appDir.absolutePath();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,19 +9,16 @@
|
|||
class Debug
|
||||
{
|
||||
public:
|
||||
static QString logsDir();
|
||||
static bool init();
|
||||
static QString getPathToClientLog();
|
||||
static QString getPathToLogsDir();
|
||||
static bool openLogsFolder();
|
||||
|
||||
private:
|
||||
static bool init(QDir& appDir);
|
||||
static QFile m_file;
|
||||
static QTextStream m_textStream;
|
||||
static QString m_logFileName;
|
||||
|
||||
private:
|
||||
static QFile m_clientLog;
|
||||
static QTextStream m_clientLogTextStream;
|
||||
static QString m_clientLogName;
|
||||
|
||||
friend void debugMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
friend void debugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
|
||||
};
|
||||
|
||||
#endif // DEBUG_H
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define DEFINES_H
|
||||
|
||||
#define APPLICATION_NAME "AmneziaVPN"
|
||||
#define SERVICE_NAME "AmneziaVPN-service"
|
||||
#define ORGANIZATION_NAME "AmneziaVPN.ORG"
|
||||
|
||||
#endif // DEFINES_H
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ int main(int argc, char *argv[])
|
|||
app.setApplicationName(APPLICATION_NAME);
|
||||
app.setOrganizationName(ORGANIZATION_NAME);
|
||||
app.setApplicationDisplayName(APPLICATION_NAME);
|
||||
app.setApplicationVersion("1.0.0.0");
|
||||
|
||||
//app.setQuitOnLastWindowClosed(false);
|
||||
|
||||
|
|
@ -60,17 +59,8 @@ int main(int argc, char *argv[])
|
|||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
|
||||
QCommandLineOption debugToConsoleOption("d", QCoreApplication::translate("main", "Output to console instead log file"));
|
||||
parser.addOption(debugToConsoleOption);
|
||||
parser.process(app); // Process the actual command line arguments given by the user
|
||||
|
||||
bool debugToConsole = parser.isSet(debugToConsoleOption);
|
||||
|
||||
qDebug() << "Set output to console: " << debugToConsole;
|
||||
if (!debugToConsole) {
|
||||
if (!Debug::init()) {
|
||||
qCritical() << "Initialization of debug subsystem failed";
|
||||
}
|
||||
if (!Debug::init()) {
|
||||
qCritical() << "Initialization of debug subsystem failed";
|
||||
}
|
||||
|
||||
QFont f("Lato Regular", 10);
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity name="amneziavpn.amneziavpn" version="0.0.0.1" processorArchitecture="x86" type="win32" />
|
||||
<description>amneziavpn</description>
|
||||
<!-- Identify the application security requirements. -->
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel
|
||||
level="requireAdministrator"
|
||||
uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
#include <QKeyEvent>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "debug.h"
|
||||
#include "defines.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
|
|
@ -5,13 +10,71 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Post initialization
|
||||
// Post initialization
|
||||
ui->widget_tittlebar->hide();
|
||||
ui->stackedWidget_main->setCurrentIndex(2);
|
||||
|
||||
connect(ui->pushButton_blocked_list, SIGNAL(clicked(bool)), this, SLOT(onPushButtonBlockedListClicked(bool)));
|
||||
connect(ui->pushButton_connect, SIGNAL(clicked(bool)), this, SLOT(onPushButtonConnectClicked(bool)));
|
||||
connect(ui->pushButton_settings, SIGNAL(clicked(bool)), this, SLOT(onPushButtonSettingsClicked(bool)));
|
||||
|
||||
connect(ui->pushButton_back_from_sites, SIGNAL(clicked(bool)), this, SLOT(onPushButtonBackFromSitesClicked(bool)));
|
||||
connect(ui->pushButton_back_from_settings, SIGNAL(clicked(bool)), this, SLOT(onPushButtonBackFromSettingsClicked(bool)));
|
||||
|
||||
setFixedSize(width(),height());
|
||||
|
||||
qDebug() << APPLICATION_NAME;
|
||||
qDebug() << "Started";
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
|
||||
qDebug() << "Closed";
|
||||
}
|
||||
|
||||
void MainWindow::goToIndex(int index)
|
||||
{
|
||||
ui->stackedWidget_main->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch (event->key()) {
|
||||
case Qt::Key_L:
|
||||
if (!Debug::openLogsFolder()) {
|
||||
QMessageBox::warning(this, APPLICATION_NAME, tr("Cannot open logs folder!"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onPushButtonBackFromSettingsClicked(bool)
|
||||
{
|
||||
goToIndex(2);
|
||||
}
|
||||
|
||||
void MainWindow::onPushButtonBackFromSitesClicked(bool)
|
||||
{
|
||||
goToIndex(2);
|
||||
}
|
||||
|
||||
void MainWindow::onPushButtonBlockedListClicked(bool)
|
||||
{
|
||||
goToIndex(3);
|
||||
}
|
||||
|
||||
void MainWindow::onPushButtonSettingsClicked(bool)
|
||||
{
|
||||
goToIndex(4);
|
||||
}
|
||||
|
||||
void MainWindow::onPushButtonConnectClicked(bool)
|
||||
{
|
||||
qDebug() << "onPushButtonConnectClicked";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,19 @@ public slots:
|
|||
|
||||
|
||||
private slots:
|
||||
void onPushButtonBlockedListClicked(bool clicked);
|
||||
void onPushButtonConnectClicked(bool clicked);
|
||||
void onPushButtonSettingsClicked(bool clicked);
|
||||
|
||||
void onPushButtonBackFromSettingsClicked(bool clicked);
|
||||
void onPushButtonBackFromSitesClicked(bool clicked);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
||||
private:
|
||||
void goToIndex(int index);
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -268,6 +268,9 @@ QStackedWidget QWidget {
|
|||
}
|
||||
</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_connect_server">
|
||||
<widget class="QLabel" name="label_23">
|
||||
<property name="geometry">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue