mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 10:50:23 +08:00
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#include "vmess.h"
|
|
#include "ui_vmess.h"
|
|
#pragma push_macro("slots")
|
|
#undef slots
|
|
#include "Python.h"
|
|
#pragma pop_macro("slots")
|
|
#include <QDebug>
|
|
#include "importconf.h"
|
|
#include<QFile>
|
|
|
|
vmess::vmess(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::vmess)
|
|
{
|
|
ui->setupUi(this);
|
|
}
|
|
|
|
vmess::~vmess()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void vmess::on_buttonBox_accepted()
|
|
{
|
|
QString vmess = ui->vmessTextEdit->toPlainText();
|
|
QString alias = ui->aliasLineEdit->text();
|
|
Py_Initialize();
|
|
if ( !Py_IsInitialized() ) {
|
|
qDebug() << "Python not initialized";
|
|
}
|
|
QString param = "--inbound socks:1080 " + vmess + " -o tmp.config.json";
|
|
PyRun_SimpleString("import sys");
|
|
PyRun_SimpleString("sys.path.append('./')");
|
|
PyObject *pModule = PyImport_ImportModule("vmess2json");
|
|
PyObject *pFunc = PyObject_GetAttrString(pModule, "main");
|
|
PyObject *arg = PyTuple_New(1);
|
|
PyObject *arg1 = Py_BuildValue("s", param.toStdString().c_str());
|
|
PyTuple_SetItem(arg, 0, arg1);
|
|
PyObject_CallObject(pFunc, arg);
|
|
Py_Finalize();
|
|
importConf *im = new importConf(this->parentWidget());
|
|
im->savefromFile("tmp.config.json", alias);
|
|
QFile::remove("tmp.config.json");
|
|
}
|