mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 10:50:23 +08:00
refactor: stage 3.3 changed/optimized include structure
This commit is contained in:
parent
1afa087166
commit
8b9bca51f5
@ -1 +1 @@
|
|||||||
3387
|
3400
|
||||||
|
@ -118,7 +118,7 @@ Qv2rayAddSource(components, plugins/toolbar, QvToolbar, cpp, hpp)
|
|||||||
#Qv2rayAddSource(components, plugins/toolbar, QvToolbar_win, cpp)
|
#Qv2rayAddSource(components, plugins/toolbar, QvToolbar_win, cpp)
|
||||||
Qv2rayAddSource(components, proxy, QvProxyConfigurator, cpp, hpp)
|
Qv2rayAddSource(components, proxy, QvProxyConfigurator, cpp, hpp)
|
||||||
Qv2rayAddSource(components, tcping, QvTCPing, cpp, hpp)
|
Qv2rayAddSource(components, tcping, QvTCPing, cpp, hpp)
|
||||||
Qv2rayAddSource(core, config, ConfigBackend, cpp)
|
Qv2rayAddSource(core, config, ConfigBackend, cpp, hpp)
|
||||||
Qv2rayAddSource(core, config, ConfigUpgrade, cpp)
|
Qv2rayAddSource(core, config, ConfigUpgrade, cpp)
|
||||||
Qv2rayAddSource(core, connection, ConnectionConfig_Convertion, cpp)
|
Qv2rayAddSource(core, connection, ConnectionConfig_Convertion, cpp)
|
||||||
Qv2rayAddSource(core, connection, ConnectionConfig_Generation, cpp)
|
Qv2rayAddSource(core, connection, ConnectionConfig_Generation, cpp)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
#include <QApplication>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -96,4 +97,10 @@ namespace Qv2ray
|
|||||||
{
|
{
|
||||||
// Extra header for QvConfigUpgrade.cpp
|
// Extra header for QvConfigUpgrade.cpp
|
||||||
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root);
|
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root);
|
||||||
|
|
||||||
|
inline void ExitQv2ray()
|
||||||
|
{
|
||||||
|
isExiting = true;
|
||||||
|
QApplication::quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "CommandArgs.hpp"
|
#include "CommandArgs.hpp"
|
||||||
#include <QCommandLineParser>
|
#include "base/Qv2rayBase.hpp"
|
||||||
|
|
||||||
namespace Qv2ray::common
|
namespace Qv2ray::common
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "base/Qv2rayBase.hpp"
|
|
||||||
|
#include <QCommandLineParser>
|
||||||
|
|
||||||
namespace Qv2ray::common
|
namespace Qv2ray::common
|
||||||
{
|
{
|
||||||
enum CommandLineParseResult {
|
enum CommandLineParseResult {
|
||||||
|
@ -58,3 +58,5 @@ namespace Qv2ray::common
|
|||||||
QNetworkAccessManager accessManager;
|
QNetworkAccessManager accessManager;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace Qv2ray::common;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "common/QvHelpers.hpp"
|
#include "common/QvHelpers.hpp"
|
||||||
#include "common/CommandArgs.hpp"
|
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
|
|
||||||
namespace Qv2ray::common
|
namespace Qv2ray::common
|
||||||
@ -191,16 +190,6 @@ namespace Qv2ray::common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QFastAppendTextDocument(const QString &message, QTextDocument *doc)
|
|
||||||
{
|
|
||||||
QTextCursor cursor(doc);
|
|
||||||
cursor.movePosition(QTextCursor::End);
|
|
||||||
cursor.beginEditBlock();
|
|
||||||
cursor.insertBlock();
|
|
||||||
cursor.insertHtml(message);
|
|
||||||
cursor.endEditBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList ConvertQStringList(const QList<string> &stdListString)
|
QStringList ConvertQStringList(const QList<string> &stdListString)
|
||||||
{
|
{
|
||||||
QStringList listQt;
|
QStringList listQt;
|
||||||
|
@ -34,7 +34,6 @@ namespace Qv2ray::common
|
|||||||
//
|
//
|
||||||
QString FormatBytes(long long bytes);
|
QString FormatBytes(long long bytes);
|
||||||
void DeducePossibleFileName(const QString &baseDir, QString *fileName, const QString &extension);
|
void DeducePossibleFileName(const QString &baseDir, QString *fileName, const QString &extension);
|
||||||
void QFastAppendTextDocument(const QString &message, QTextDocument *doc);
|
|
||||||
QStringList ConvertQStringList(const QList<string> &stdListString);
|
QStringList ConvertQStringList(const QList<string> &stdListString);
|
||||||
std::list<string> ConvertStdStringList(const QStringList &qStringList);
|
std::list<string> ConvertStdStringList(const QStringList &qStringList);
|
||||||
//
|
//
|
||||||
|
@ -6,4 +6,5 @@ namespace Qv2ray::components::autolaunch
|
|||||||
void SetLaunchAtLoginStatus(bool enable);
|
void SetLaunchAtLoginStatus(bool enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace Qv2ray::components;
|
||||||
using namespace Qv2ray::components::autolaunch;
|
using namespace Qv2ray::components::autolaunch;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "qhttprequest.h"
|
#include "qhttprequest.h"
|
||||||
#include "qhttpresponse.h"
|
#include "qhttpresponse.h"
|
||||||
#include "core/CoreUtils.hpp"
|
#include "core/CoreUtils.hpp"
|
||||||
|
#include "common/QvHelpers.hpp"
|
||||||
|
|
||||||
namespace Qv2ray::components::pac
|
namespace Qv2ray::components::pac
|
||||||
{
|
{
|
||||||
@ -13,8 +14,13 @@ namespace Qv2ray::components::pac
|
|||||||
}
|
}
|
||||||
PACServer::~PACServer()
|
PACServer::~PACServer()
|
||||||
{
|
{
|
||||||
pacServer->close();
|
if (isStarted) {
|
||||||
delete pacServer;
|
pacServer->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pacServer != nullptr) {
|
||||||
|
delete pacServer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void PACServer::SetProxyString(const QString &proxyString)
|
void PACServer::SetProxyString(const QString &proxyString)
|
||||||
{
|
{
|
||||||
|
@ -27,4 +27,5 @@ namespace Qv2ray::components::pac
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace Qv2ray::components;
|
||||||
using namespace Qv2ray::components::pac;
|
using namespace Qv2ray::components::pac;
|
||||||
|
@ -51,5 +51,7 @@ namespace Qv2ray::components::plugins
|
|||||||
QString GetAnswerToRequest(const QString &pchRequest);
|
QString GetAnswerToRequest(const QString &pchRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace Qv2ray::components;
|
||||||
using namespace Qv2ray::components::plugins::Toolbar;
|
using namespace Qv2ray::components::plugins::Toolbar;
|
||||||
|
|
||||||
|
@ -8,4 +8,5 @@ namespace Qv2ray::components::proxy
|
|||||||
bool SetSystemProxy(const QString &address, int port, bool usePAC);
|
bool SetSystemProxy(const QString &address, int port, bool usePAC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace Qv2ray::components;
|
||||||
using namespace Qv2ray::components::proxy;
|
using namespace Qv2ray::components::proxy;
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "common/QvHelpers.hpp"
|
#include "base/Qv2rayBase.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace Qv2ray::components::tcping
|
namespace Qv2ray::components::tcping
|
||||||
{
|
{
|
||||||
|
@ -1,42 +1,9 @@
|
|||||||
#include "CoreUtils.hpp"
|
#include "CoreUtils.hpp"
|
||||||
|
#include "common/QvHelpers.hpp"
|
||||||
#include "QApplication"
|
#include "QApplication"
|
||||||
|
|
||||||
namespace Qv2ray::core
|
namespace Qv2ray::core
|
||||||
{
|
{
|
||||||
void SaveGlobalConfig(Qv2rayConfig conf)
|
|
||||||
{
|
|
||||||
GlobalConfig = conf;
|
|
||||||
QFile config(QV2RAY_CONFIG_FILE);
|
|
||||||
QString str = StructToJsonString(conf);
|
|
||||||
StringToFile(&str, &config);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetConfigDirPath(const QString &path)
|
|
||||||
{
|
|
||||||
Qv2rayConfigPath = path;
|
|
||||||
|
|
||||||
if (!path.endsWith("/")) {
|
|
||||||
Qv2rayConfigPath += "/";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadGlobalConfig()
|
|
||||||
{
|
|
||||||
QFile file(QV2RAY_CONFIG_FILE);
|
|
||||||
file.open(QFile::ReadOnly);
|
|
||||||
QTextStream stream(&file);
|
|
||||||
auto str = stream.readAll();
|
|
||||||
auto config = StructFromJsonString<Qv2rayConfig>(str);
|
|
||||||
SaveGlobalConfig(config);
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExitQv2ray()
|
|
||||||
{
|
|
||||||
isExiting = true;
|
|
||||||
QApplication::quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
tuple<QString, int, QString> GetConnectionInfo(const CONFIGROOT &root)
|
tuple<QString, int, QString> GetConnectionInfo(const CONFIGROOT &root)
|
||||||
{
|
{
|
||||||
bool validOutboundFound = false;
|
bool validOutboundFound = false;
|
||||||
@ -63,7 +30,7 @@ namespace Qv2ray::core
|
|||||||
// Set initial values.
|
// Set initial values.
|
||||||
*host = QObject::tr("N/A");
|
*host = QObject::tr("N/A");
|
||||||
*port = 0;
|
*port = 0;
|
||||||
*protocol = out["protocol"].toString(QObject::tr("N/A"));
|
*protocol = out["protocol"].toString(QObject::tr("N/A")).toLower();
|
||||||
|
|
||||||
if (*protocol == "vmess") {
|
if (*protocol == "vmess") {
|
||||||
auto Server = StructFromJsonString<VMessServerObject>(JsonToString(out["settings"].toObject()["vnext"].toArray().first().toObject()));
|
auto Server = StructFromJsonString<VMessServerObject>(JsonToString(out["settings"].toObject()["vnext"].toArray().first().toObject()));
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "base/Qv2rayBase.hpp"
|
#include "base/Qv2rayBase.hpp"
|
||||||
#include "common/QvHelpers.hpp"
|
#include "core/config/ConfigBackend.hpp"
|
||||||
|
|
||||||
namespace Qv2ray::core
|
namespace Qv2ray::core
|
||||||
{
|
{
|
||||||
void SaveGlobalConfig(Qv2rayConfig conf);
|
|
||||||
void LoadGlobalConfig();
|
|
||||||
void SetConfigDirPath(const QString &path);
|
|
||||||
//
|
|
||||||
inline QString getTag(const INBOUND &in)
|
inline QString getTag(const INBOUND &in)
|
||||||
{
|
{
|
||||||
return in["tag"].toString();
|
return in["tag"].toString();
|
||||||
@ -19,7 +15,11 @@ namespace Qv2ray::core
|
|||||||
return in["tag"].toString();
|
return in["tag"].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExitQv2ray();
|
inline QString getTag(const RuleObject &in)
|
||||||
|
{
|
||||||
|
return in.QV2RAY_RULE_TAG;
|
||||||
|
}
|
||||||
|
|
||||||
tuple<QString, int, QString> GetConnectionInfo(const CONFIGROOT &alias);
|
tuple<QString, int, QString> GetConnectionInfo(const CONFIGROOT &alias);
|
||||||
bool GetOutboundData(const OUTBOUND &out, QString *host, int *port, QString *protocol);
|
bool GetOutboundData(const OUTBOUND &out, QString *host, int *port, QString *protocol);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
#include "ConfigBackend.hpp"
|
||||||
|
#include "common/QvHelpers.hpp"
|
||||||
|
|
||||||
|
namespace Qv2ray::core::config
|
||||||
|
{
|
||||||
|
void SaveGlobalConfig(Qv2rayConfig conf)
|
||||||
|
{
|
||||||
|
GlobalConfig = conf;
|
||||||
|
QFile config(QV2RAY_CONFIG_FILE);
|
||||||
|
QString str = StructToJsonString(conf);
|
||||||
|
StringToFile(&str, &config);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetConfigDirPath(const QString &path)
|
||||||
|
{
|
||||||
|
Qv2rayConfigPath = path;
|
||||||
|
|
||||||
|
if (!path.endsWith("/")) {
|
||||||
|
Qv2rayConfigPath += "/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadGlobalConfig()
|
||||||
|
{
|
||||||
|
QFile file(QV2RAY_CONFIG_FILE);
|
||||||
|
file.open(QFile::ReadOnly);
|
||||||
|
QTextStream stream(&file);
|
||||||
|
auto str = stream.readAll();
|
||||||
|
auto config = StructFromJsonString<Qv2rayConfig>(str);
|
||||||
|
SaveGlobalConfig(config);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Qv2ray::core::config;
|
11
src/core/config/ConfigBackend.hpp
Normal file
11
src/core/config/ConfigBackend.hpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "base/Qv2rayBase.hpp"
|
||||||
|
|
||||||
|
namespace Qv2ray::core::config
|
||||||
|
{
|
||||||
|
void SaveGlobalConfig(Qv2rayConfig conf);
|
||||||
|
void SetConfigDirPath(const QString &path);
|
||||||
|
void LoadGlobalConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Qv2ray::core;
|
||||||
|
using namespace Qv2ray::core::config;
|
@ -71,5 +71,5 @@ namespace Qv2ray::core::connection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace Qv2ray::core;
|
||||||
using namespace Qv2ray::core::connection;
|
using namespace Qv2ray::core::connection;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include "common/QvHelpers.hpp"
|
||||||
#include "QvKernelInteractions.hpp"
|
#include "QvKernelInteractions.hpp"
|
||||||
#include "core/connection/ConnectionConfigOperations.hpp"
|
#include "core/connection/ConnectionConfigOperations.hpp"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include "core/CoreUtils.hpp"
|
#include "base/Qv2rayBase.hpp"
|
||||||
#ifdef WITH_LIB_GRPCPP
|
#ifdef WITH_LIB_GRPCPP
|
||||||
#include <grpc++/grpc++.h>
|
#include <grpc++/grpc++.h>
|
||||||
#include "libs/gen/v2ray_api_commands.pb.h"
|
#include "libs/gen/v2ray_api_commands.pb.h"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "w_InboundEditor.hpp"
|
#include "w_InboundEditor.hpp"
|
||||||
#include "core/CoreUtils.hpp"
|
#include "core/CoreUtils.hpp"
|
||||||
|
#include "common/QvHelpers.hpp"
|
||||||
#include "core/connection/ConnectionConfigOperations.hpp"
|
#include "core/connection/ConnectionConfigOperations.hpp"
|
||||||
|
|
||||||
static bool isLoading = false;
|
static bool isLoading = false;
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
||||||
|
#include "common/QvHelpers.hpp"
|
||||||
#include "common/HTTPRequestHelper.hpp"
|
#include "common/HTTPRequestHelper.hpp"
|
||||||
|
#include "core/config/ConfigBackend.hpp"
|
||||||
#include "core/kernel/QvKernelInteractions.hpp"
|
#include "core/kernel/QvKernelInteractions.hpp"
|
||||||
#include "core/connection/ConnectionConfigOperations.hpp"
|
#include "core/connection/ConnectionConfigOperations.hpp"
|
||||||
#include "components/plugins/toolbar/QvToolbar.hpp"
|
#include "components/plugins/toolbar/QvToolbar.hpp"
|
||||||
@ -26,7 +28,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
|||||||
networkToolbarPage->setEnabled(StartupOption.enableToolbarPlguin);
|
networkToolbarPage->setEnabled(StartupOption.enableToolbarPlguin);
|
||||||
|
|
||||||
if (!StartupOption.enableToolbarPlguin) {
|
if (!StartupOption.enableToolbarPlguin) {
|
||||||
networkToolbarInfoLabel->setText(tr("Qv2ray Network Toolbar is disabled and still under test. Add --withNetworkToolbar to enable."));
|
networkToolbarInfoLabel->setText(tr("Qv2ray Network Toolbar is disabled and still under test. Add --withToolbarPlugin to enable."));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We add locales
|
// We add locales
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <ui_w_PreferencesWindow.h>
|
#include <ui_w_PreferencesWindow.h>
|
||||||
#include "common/QvHelpers.hpp"
|
#include "base/Qv2rayBase.hpp"
|
||||||
|
|
||||||
class PreferencesWindow : public QDialog, private Ui::PreferencesWindow
|
class PreferencesWindow : public QDialog, private Ui::PreferencesWindow
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#include "w_SubscriptionManager.hpp"
|
#include "w_SubscriptionManager.hpp"
|
||||||
|
#include "common/QvHelpers.hpp"
|
||||||
|
#include "core/CoreUtils.hpp"
|
||||||
#include "core/connection/ConnectionConfigOperations.hpp"
|
#include "core/connection/ConnectionConfigOperations.hpp"
|
||||||
|
|
||||||
SubscribeEditor::SubscribeEditor(QWidget *parent) :
|
SubscribeEditor::SubscribeEditor(QWidget *parent) :
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "core/CoreUtils.hpp"
|
#include "base/Qv2rayBase.hpp"
|
||||||
#include "common/HTTPRequestHelper.hpp"
|
#include "common/HTTPRequestHelper.hpp"
|
||||||
|
|
||||||
#include "ui_w_SubscriptionManager.h"
|
#include "ui_w_SubscriptionManager.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user