mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-21 19:30:26 +08:00
parent
f1f832cd01
commit
6642c332cb
@ -1 +1 @@
|
||||
1282
|
||||
1285
|
||||
|
@ -56,7 +56,7 @@ namespace Qv2ray
|
||||
LOG(MODULE_PROXY, "InternetQueryOption failed,GLE=" + to_string(GetLastError()));
|
||||
|
||||
if (Option[4].Value.pszValue != nullptr)
|
||||
LOG(MODULE_PROXY, Option[4].Value.pszValue);
|
||||
LOG(MODULE_PROXY, QString::fromStdWString(Option[4].Value.pszValue).toStdString());
|
||||
|
||||
INTERNET_VERSION_INFO Version;
|
||||
nSize = sizeof(INTERNET_VERSION_INFO);
|
||||
|
@ -34,18 +34,25 @@ namespace Qv2ray
|
||||
}
|
||||
QString GetAnswerToRequest(const QString &pchRequest)
|
||||
{
|
||||
auto vinstance = mwInstance->vinstance;
|
||||
auto instance = MainWindow::mwInstance;
|
||||
|
||||
if (instance == nullptr || instance->vinstance == nullptr) {
|
||||
LOG(MODULE_PLUGIN, "MainWindow != nullptr Assertion failed!")
|
||||
return "{}";
|
||||
}
|
||||
|
||||
auto vinstance = instance->vinstance;
|
||||
//
|
||||
auto req = pchRequest.trimmed();
|
||||
config = GetGlobalConfig();
|
||||
QString reply = "{}";
|
||||
|
||||
if (req == "START") {
|
||||
emit mwInstance->Connect();
|
||||
emit instance->Connect();
|
||||
} else if (req == "STOP") {
|
||||
emit mwInstance->DisConnect();
|
||||
emit instance->DisConnect();
|
||||
} else if (req == "RESTART") {
|
||||
emit mwInstance->ReConnect();
|
||||
emit instance->ReConnect();
|
||||
}
|
||||
|
||||
auto BarConfig = config.toolBarConfig;
|
||||
@ -82,13 +89,13 @@ namespace Qv2ray
|
||||
|
||||
case 104: {
|
||||
// Current Connection Name
|
||||
CL.Message = mwInstance->CurrentConnectionName.toStdString();
|
||||
CL.Message = instance->CurrentConnectionName.toStdString();
|
||||
break;
|
||||
}
|
||||
|
||||
case 105: {
|
||||
// Current Connection Status
|
||||
switch (mwInstance->vinstance->ConnectionStatus) {
|
||||
switch (instance->vinstance->ConnectionStatus) {
|
||||
case STARTED: {
|
||||
CL.Message = QObject::tr("Connected").toStdString();
|
||||
break;
|
||||
|
@ -88,18 +88,22 @@ namespace Qv2ray
|
||||
}
|
||||
|
||||
auto req = QString::fromStdWString(pchRequest);
|
||||
auto replyQString = isExiting ? "{}" : GetAnswerToRequest(req);
|
||||
//
|
||||
// REPLY as std::string
|
||||
std::string pchReply = replyQString.toUtf8().constData();
|
||||
cbReplyBytes = static_cast<DWORD>(pchReply.length() + 1) * sizeof(CHAR);
|
||||
//cbReplyBytes = static_cast<DWORD>(replyQString.length() + 1) * sizeof(TCHAR);
|
||||
//
|
||||
fSuccess = WriteFile(hPipe, pchReply.c_str(), cbReplyBytes, &cbWritten, nullptr);
|
||||
QString replyQString = "{}";
|
||||
|
||||
if (!fSuccess || cbReplyBytes != cbWritten) {
|
||||
LOG(MODULE_PLUGIN, "InstanceThread WriteFile failed, GLE=" + to_string(GetLastError()))
|
||||
break;
|
||||
if (!isExiting) {
|
||||
replyQString = GetAnswerToRequest(req);
|
||||
//
|
||||
// REPLY as std::string
|
||||
std::string pchReply = replyQString.toUtf8().constData();
|
||||
cbReplyBytes = static_cast<DWORD>(pchReply.length() + 1) * sizeof(CHAR);
|
||||
//cbReplyBytes = static_cast<DWORD>(replyQString.length() + 1) * sizeof(TCHAR);
|
||||
//
|
||||
fSuccess = WriteFile(hPipe, pchReply.c_str(), cbReplyBytes, &cbWritten, nullptr);
|
||||
|
||||
if (!fSuccess || cbReplyBytes != cbWritten) {
|
||||
LOG(MODULE_PLUGIN, "InstanceThread WriteFile failed, GLE=" + to_string(GetLastError()))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,13 @@
|
||||
} \
|
||||
} \
|
||||
|
||||
MainWindow *MainWindow::mwInstance = nullptr;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent):
|
||||
QMainWindow(parent), vinstance(), uploadList(), downloadList(), HTTPRequestHelper(),
|
||||
hTray(new QSystemTrayIcon(this)), vCoreLogHighlighter(), qvAppLogHighlighter()
|
||||
{
|
||||
mwInstance = this;
|
||||
MainWindow::mwInstance = this;
|
||||
auto conf = GetGlobalConfig();
|
||||
vinstance = new ConnectionInstance();
|
||||
connect(vinstance, &ConnectionInstance::onProcessOutputReadyRead, this, &MainWindow::UpdateVCoreLog);
|
||||
|
@ -78,6 +78,7 @@ class MainWindow : public QMainWindow, Ui::MainWindow
|
||||
void on_masterLogBrowser_textChanged();
|
||||
|
||||
public:
|
||||
static MainWindow *mwInstance;
|
||||
CONFIGROOT CurrentFullConfig;
|
||||
QString CurrentConnectionName = "";
|
||||
ConnectionInstance *vinstance;
|
||||
@ -126,6 +127,4 @@ class MainWindow : public QMainWindow, Ui::MainWindow
|
||||
int currentLogBrowserId = 0;
|
||||
};
|
||||
|
||||
static const MainWindow *mwInstance;
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
Reference in New Issue
Block a user