mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +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, proxy, QvProxyConfigurator, 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, connection, ConnectionConfig_Convertion, cpp)
|
||||
Qv2rayAddSource(core, connection, ConnectionConfig_Generation, cpp)
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
#include <QApplication>
|
||||
#include <QMap>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
@ -96,4 +97,10 @@ namespace Qv2ray
|
||||
{
|
||||
// Extra header for QvConfigUpgrade.cpp
|
||||
QJsonObject UpgradeConfig(int fromVersion, int toVersion, QJsonObject root);
|
||||
|
||||
inline void ExitQv2ray()
|
||||
{
|
||||
isExiting = true;
|
||||
QApplication::quit();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "CommandArgs.hpp"
|
||||
#include <QCommandLineParser>
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
|
||||
namespace Qv2ray::common
|
||||
{
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
|
||||
#include <QCommandLineParser>
|
||||
|
||||
namespace Qv2ray::common
|
||||
{
|
||||
enum CommandLineParseResult {
|
||||
|
@ -58,3 +58,5 @@ namespace Qv2ray::common
|
||||
QNetworkAccessManager accessManager;
|
||||
};
|
||||
}
|
||||
|
||||
using namespace Qv2ray::common;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "common/QvHelpers.hpp"
|
||||
#include "common/CommandArgs.hpp"
|
||||
#include <QQueue>
|
||||
|
||||
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 listQt;
|
||||
|
@ -34,7 +34,6 @@ namespace Qv2ray::common
|
||||
//
|
||||
QString FormatBytes(long long bytes);
|
||||
void DeducePossibleFileName(const QString &baseDir, QString *fileName, const QString &extension);
|
||||
void QFastAppendTextDocument(const QString &message, QTextDocument *doc);
|
||||
QStringList ConvertQStringList(const QList<string> &stdListString);
|
||||
std::list<string> ConvertStdStringList(const QStringList &qStringList);
|
||||
//
|
||||
|
@ -6,4 +6,5 @@ namespace Qv2ray::components::autolaunch
|
||||
void SetLaunchAtLoginStatus(bool enable);
|
||||
}
|
||||
|
||||
using namespace Qv2ray::components;
|
||||
using namespace Qv2ray::components::autolaunch;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "qhttprequest.h"
|
||||
#include "qhttpresponse.h"
|
||||
#include "core/CoreUtils.hpp"
|
||||
#include "common/QvHelpers.hpp"
|
||||
|
||||
namespace Qv2ray::components::pac
|
||||
{
|
||||
@ -13,8 +14,13 @@ namespace Qv2ray::components::pac
|
||||
}
|
||||
PACServer::~PACServer()
|
||||
{
|
||||
pacServer->close();
|
||||
delete pacServer;
|
||||
if (isStarted) {
|
||||
pacServer->close();
|
||||
}
|
||||
|
||||
if (pacServer != nullptr) {
|
||||
delete pacServer;
|
||||
}
|
||||
}
|
||||
void PACServer::SetProxyString(const QString &proxyString)
|
||||
{
|
||||
|
@ -27,4 +27,5 @@ namespace Qv2ray::components::pac
|
||||
};
|
||||
}
|
||||
|
||||
using namespace Qv2ray::components;
|
||||
using namespace Qv2ray::components::pac;
|
||||
|
@ -51,5 +51,7 @@ namespace Qv2ray::components::plugins
|
||||
QString GetAnswerToRequest(const QString &pchRequest);
|
||||
}
|
||||
}
|
||||
|
||||
using namespace Qv2ray::components;
|
||||
using namespace Qv2ray::components::plugins::Toolbar;
|
||||
|
||||
|
@ -8,4 +8,5 @@ namespace Qv2ray::components::proxy
|
||||
bool SetSystemProxy(const QString &address, int port, bool usePAC);
|
||||
}
|
||||
|
||||
using namespace Qv2ray::components;
|
||||
using namespace Qv2ray::components::proxy;
|
||||
|
@ -9,8 +9,7 @@
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include "common/QvHelpers.hpp"
|
||||
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
|
||||
namespace Qv2ray::components::tcping
|
||||
{
|
||||
|
@ -1,42 +1,9 @@
|
||||
#include "CoreUtils.hpp"
|
||||
#include "common/QvHelpers.hpp"
|
||||
#include "QApplication"
|
||||
|
||||
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)
|
||||
{
|
||||
bool validOutboundFound = false;
|
||||
@ -63,7 +30,7 @@ namespace Qv2ray::core
|
||||
// Set initial values.
|
||||
*host = QObject::tr("N/A");
|
||||
*port = 0;
|
||||
*protocol = out["protocol"].toString(QObject::tr("N/A"));
|
||||
*protocol = out["protocol"].toString(QObject::tr("N/A")).toLower();
|
||||
|
||||
if (*protocol == "vmess") {
|
||||
auto Server = StructFromJsonString<VMessServerObject>(JsonToString(out["settings"].toObject()["vnext"].toArray().first().toObject()));
|
||||
|
@ -1,14 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
#include "common/QvHelpers.hpp"
|
||||
#include "core/config/ConfigBackend.hpp"
|
||||
|
||||
namespace Qv2ray::core
|
||||
{
|
||||
void SaveGlobalConfig(Qv2rayConfig conf);
|
||||
void LoadGlobalConfig();
|
||||
void SetConfigDirPath(const QString &path);
|
||||
//
|
||||
inline QString getTag(const INBOUND &in)
|
||||
{
|
||||
return in["tag"].toString();
|
||||
@ -19,7 +15,11 @@ namespace Qv2ray::core
|
||||
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);
|
||||
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;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QDesktopServices>
|
||||
#include "common/QvHelpers.hpp"
|
||||
#include "QvKernelInteractions.hpp"
|
||||
#include "core/connection/ConnectionConfigOperations.hpp"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <QProcess>
|
||||
#include "core/CoreUtils.hpp"
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
#ifdef WITH_LIB_GRPCPP
|
||||
#include <grpc++/grpc++.h>
|
||||
#include "libs/gen/v2ray_api_commands.pb.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "w_InboundEditor.hpp"
|
||||
#include "core/CoreUtils.hpp"
|
||||
#include "common/QvHelpers.hpp"
|
||||
#include "core/connection/ConnectionConfigOperations.hpp"
|
||||
|
||||
static bool isLoading = false;
|
||||
|
@ -5,7 +5,9 @@
|
||||
#include <QStyle>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include "common/QvHelpers.hpp"
|
||||
#include "common/HTTPRequestHelper.hpp"
|
||||
#include "core/config/ConfigBackend.hpp"
|
||||
#include "core/kernel/QvKernelInteractions.hpp"
|
||||
#include "core/connection/ConnectionConfigOperations.hpp"
|
||||
#include "components/plugins/toolbar/QvToolbar.hpp"
|
||||
@ -26,7 +28,7 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
||||
networkToolbarPage->setEnabled(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
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <ui_w_PreferencesWindow.h>
|
||||
#include "common/QvHelpers.hpp"
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
|
||||
class PreferencesWindow : public QDialog, private Ui::PreferencesWindow
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "w_SubscriptionManager.hpp"
|
||||
#include "common/QvHelpers.hpp"
|
||||
#include "core/CoreUtils.hpp"
|
||||
#include "core/connection/ConnectionConfigOperations.hpp"
|
||||
|
||||
SubscribeEditor::SubscribeEditor(QWidget *parent) :
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include "core/CoreUtils.hpp"
|
||||
#include "base/Qv2rayBase.hpp"
|
||||
#include "common/HTTPRequestHelper.hpp"
|
||||
|
||||
#include "ui_w_SubscriptionManager.h"
|
||||
|
Loading…
Reference in New Issue
Block a user