Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vpnConnected
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yunpeng.song
vpnConnected
Commits
29864ba9
Commit
29864ba9
authored
Mar 22, 2019
by
yunpeng.song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加全家vpn连接,启动时检查并停止所有vpn进程
parent
d9cdb41c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
3 deletions
+44
-3
mainwindow.cpp
+26
-1
mainwindow.h
+3
-0
mainwindow.ui
+15
-2
No files found.
mainwindow.cpp
View file @
29864ba9
...
@@ -11,6 +11,7 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -11,6 +11,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui
(
new
Ui
::
MainWindow
)
ui
(
new
Ui
::
MainWindow
)
{
{
ui
->
setupUi
(
this
);
ui
->
setupUi
(
this
);
_killVpnexe
();
//通过qprocess启动cmd
//通过qprocess启动cmd
_exe
.
setProgram
(
"cmd"
);
_exe
.
setProgram
(
"cmd"
);
connect
(
&
_exe
,
&
QProcess
::
readyRead
,
this
,
&
MainWindow
::
on_readStandardContent
);
connect
(
&
_exe
,
&
QProcess
::
readyRead
,
this
,
&
MainWindow
::
on_readStandardContent
);
...
@@ -43,7 +44,7 @@ void MainWindow::on_btn_connect_clicked()
...
@@ -43,7 +44,7 @@ void MainWindow::on_btn_connect_clicked()
_getVpnStatus
();
_getVpnStatus
();
if
(
!
_vpnStatus
)
if
(
!
_vpnStatus
)
{
{
QString
file
=
qApp
->
applicationDirPath
()
+
"/"
+
_setting
->
value
(
"info/fileName"
).
toString
();
QString
file
=
qApp
->
applicationDirPath
()
+
"/"
+
_setting
->
value
(
"info/
MCD
fileName"
).
toString
();
qDebug
()
<<
file
;
qDebug
()
<<
file
;
QByteArray
command
=
QString
(
"vpncli.exe -s <%1
\n
"
).
arg
(
file
).
toLocal8Bit
();
QByteArray
command
=
QString
(
"vpncli.exe -s <%1
\n
"
).
arg
(
file
).
toLocal8Bit
();
qDebug
()
<<
command
;
qDebug
()
<<
command
;
...
@@ -67,6 +68,7 @@ void MainWindow::on_readStandardContent()
...
@@ -67,6 +68,7 @@ void MainWindow::on_readStandardContent()
if
(
_isFirst
)
if
(
_isFirst
)
ui
->
textEdit
->
clear
();
ui
->
textEdit
->
clear
();
QString
content
=
QString
::
fromLocal8Bit
(
_exe
.
readAllStandardOutput
());
QString
content
=
QString
::
fromLocal8Bit
(
_exe
.
readAllStandardOutput
());
qDebug
()
<<
content
;
content
.
replace
(
"
\n
"
,
"
\r
"
);
content
.
replace
(
"
\n
"
,
"
\r
"
);
QStringList
list
=
content
.
split
(
'\r'
);
QStringList
list
=
content
.
split
(
'\r'
);
foreach
(
QString
str
,
list
)
foreach
(
QString
str
,
list
)
...
@@ -101,8 +103,31 @@ void MainWindow::_getVpnStatus()
...
@@ -101,8 +103,31 @@ void MainWindow::_getVpnStatus()
_exe
.
write
(
"vpncli.exe state
\n
"
);
_exe
.
write
(
"vpncli.exe state
\n
"
);
}
}
void
MainWindow
::
_killVpnexe
()
{
QProcess
process
;
process
.
execute
(
"TASKKILL /IM vpncli.exe /F"
);
process
.
execute
(
"TASKKILL /IM vpnui.exe /F"
);
process
.
close
();
}
void
MainWindow
::
on_btn_query_clicked
()
void
MainWindow
::
on_btn_query_clicked
()
{
{
_isFirst
=
true
;
_isFirst
=
true
;
_getVpnStatus
();
_getVpnStatus
();
}
}
void
MainWindow
::
on_pushButton_clicked
()
{
_isFirst
=
true
;
_getVpnStatus
();
if
(
!
_vpnStatus
)
{
QString
file
=
qApp
->
applicationDirPath
()
+
"/"
+
_setting
->
value
(
"info/QJfileName"
).
toString
();
qDebug
()
<<
file
;
QByteArray
command
=
QString
(
"vpncli.exe -s <%1
\n
"
).
arg
(
file
).
toLocal8Bit
();
qDebug
()
<<
command
;
//_exe.write("vpncli.exe -s < f:\\myfile.dat\n");
_exe
.
write
(
command
);
}
}
mainwindow.h
View file @
29864ba9
...
@@ -31,6 +31,8 @@ private slots:
...
@@ -31,6 +31,8 @@ private slots:
//查询状态
//查询状态
void
on_btn_query_clicked
();
void
on_btn_query_clicked
();
void
on_pushButton_clicked
();
private
:
private
:
bool
_isFirst
;
bool
_isFirst
;
SysTray
m_tray
;
SysTray
m_tray
;
...
@@ -40,6 +42,7 @@ private:
...
@@ -40,6 +42,7 @@ private:
bool
_vpnStatus
;
bool
_vpnStatus
;
//获取vpn状态
//获取vpn状态
void
_getVpnStatus
();
void
_getVpnStatus
();
void
_killVpnexe
();
};
};
#endif // MAINWINDOW_H
#endif // MAINWINDOW_H
mainwindow.ui
View file @
29864ba9
...
@@ -24,14 +24,14 @@
...
@@ -24,14 +24,14 @@
</rect>
</rect>
</property>
</property>
<property
name=
"text"
>
<property
name=
"text"
>
<string>
启动vpn
</string>
<string>
启动
麦当劳
vpn
</string>
</property>
</property>
</widget>
</widget>
<widget
class=
"QPushButton"
name=
"btn_disconnect"
>
<widget
class=
"QPushButton"
name=
"btn_disconnect"
>
<property
name=
"geometry"
>
<property
name=
"geometry"
>
<rect>
<rect>
<x>
30
</x>
<x>
30
</x>
<y>
12
0
</y>
<y>
24
0
</y>
<width>
111
</width>
<width>
111
</width>
<height>
41
</height>
<height>
41
</height>
</rect>
</rect>
...
@@ -82,6 +82,19 @@
...
@@ -82,6 +82,19 @@
<string>
查询状态
</string>
<string>
查询状态
</string>
</property>
</property>
</widget>
</widget>
<widget
class=
"QPushButton"
name=
"pushButton"
>
<property
name=
"geometry"
>
<rect>
<x>
30
</x>
<y>
120
</y>
<width>
111
</width>
<height>
41
</height>
</rect>
</property>
<property
name=
"text"
>
<string>
启动全家VPN
</string>
</property>
</widget>
</widget>
</widget>
<widget
class=
"QMenuBar"
name=
"menuBar"
>
<widget
class=
"QMenuBar"
name=
"menuBar"
>
<property
name=
"geometry"
>
<property
name=
"geometry"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment