-
Notifications
You must be signed in to change notification settings - Fork 51
/
proxyform.cpp
59 lines (56 loc) · 1.8 KB
/
proxyform.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "proxyform.h"
#include "ui_proxyform.h"
#include <QFileInfo>
#include "daye.h"
#include <QTextStream>
proxyForm::proxyForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::proxyForm)
{
ui->setupUi(this);
QFileInfo a("proxy.conf");
if(a.isFile())
{
QFile fileProxy("proxy.conf");
QString line;
char tmp[5000];
if(fileProxy.open(QIODevice::ReadOnly))
{
line=fileProxy.readLine();
fileProxy.close();
}
if(!line.isEmpty())
{
getStringBetweenAandB(line.toStdString().c_str(),"socks5Addr:\"","\"",tmp);
ui->lineEditAddr->setText(tmp);
getStringBetweenAandB(line.toStdString().c_str(),"socks5Port:\"","\"",tmp);
ui->lineEditPort->setText(tmp);
getStringBetweenAandB(line.toStdString().c_str(),"socks5User:\"","\"",tmp);
ui->lineEditUser->setText(tmp);
getStringBetweenAandB(line.toStdString().c_str(),"socks5Pass:\"","\"",tmp);
ui->lineEditPass->setText(tmp);
}
fileProxy.close();
}
}
proxyForm::~proxyForm()
{
delete ui;
}
void proxyForm::on_pushButton_2_clicked()
{
this->close();
}
void proxyForm::on_pushButton_clicked()
{
QFile fileProxy("proxy.conf");
QString writeData;
writeData=QString("\"socks5Addr:\"")+ui->lineEditAddr->text()+QString("\",")+QString("\"socks5Port:\"")+ui->lineEditPort->text()+QString("\",")+QString("\"socks5User:\"")+ui->lineEditUser->text()+QString("\",")+QString("\"socks5Pass:\"")+ui->lineEditPass->text()+QString("\"");
if(fileProxy.open(QIODevice::WriteOnly))
{
QTextStream in(&fileProxy);
in<<writeData;
fileProxy.close();
}
this->close();
}