Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
bitmask-vpn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leap
bitmask-vpn
Commits
eb97dc51
Unverified
Commit
eb97dc51
authored
4 years ago
by
Kali Kaneko
Browse files
Options
Downloads
Patches
Plain Diff
[refactor] use qt argument parsing
parent
cf5ed56c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!102
Feat/rest api
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
gui/backend.go
+10
-0
10 additions, 0 deletions
gui/backend.go
gui/handlers.cpp
+10
-0
10 additions, 0 deletions
gui/handlers.cpp
gui/handlers.h
+2
-0
2 additions, 0 deletions
gui/handlers.h
gui/main.cpp
+20
-11
20 additions, 11 deletions
gui/main.cpp
pkg/backend/api.go
+15
-0
15 additions, 0 deletions
pkg/backend/api.go
with
57 additions
and
11 deletions
gui/backend.go
+
10
−
0
View file @
eb97dc51
...
...
@@ -12,6 +12,16 @@ import (
"0xacab.org/leap/bitmask-vpn/pkg/backend"
)
//export GetVersion
func
GetVersion
()
*
C
.
char
{
return
(
*
C
.
char
)(
backend
.
GetVersion
())
}
//export GetAppName
func
GetAppName
()
*
C
.
char
{
return
(
*
C
.
char
)(
backend
.
GetAppName
())
}
//export SwitchOn
func
SwitchOn
()
{
backend
.
SwitchOn
()
...
...
This diff is collapsed.
Click to expand it.
gui/handlers.cpp
+
10
−
0
View file @
eb97dc51
...
...
@@ -10,6 +10,16 @@ Backend::Backend(QObject *parent) : QObject(parent)
{
}
QString
Backend
::
getAppName
()
{
return
QString
(
GetAppName
());
}
QString
Backend
::
getVersion
()
{
return
QString
(
GetVersion
());
}
void
Backend
::
switchOn
()
{
SwitchOn
();
...
...
This diff is collapsed.
Click to expand it.
gui/handlers.h
+
2
−
0
View file @
eb97dc51
...
...
@@ -30,6 +30,8 @@ signals:
void
quitDone
();
public
slots
:
QString
getAppName
();
QString
getVersion
();
void
switchOn
();
void
switchOff
();
void
unblock
();
...
...
This diff is collapsed.
Click to expand it.
gui/main.cpp
+
20
−
11
View file @
eb97dc51
#include
<csignal>
#include
<string>
#include
<QApplication>
#include
<QSystemTrayIcon>
#include
<QTimer>
#include
<QTranslator>
#include
<QtQml>
#include
<QQmlApplicationEngine>
#include
<QCommandLineParser>
#include
<QQuickWindow>
#include
<QSystemTrayIcon>
#include
<QtQml>
#include
"handlers.h"
#include
"qjsonmodel.h"
...
...
@@ -42,18 +40,30 @@ void signalHandler(int) {
int
main
(
int
argc
,
char
**
argv
)
{
signal
(
SIGINT
,
signalHandler
);
bool
debugQml
=
getEnv
(
"DEBUG_QML_DATA"
)
==
"yes"
;
if
(
argc
>
1
&&
strcmp
(
argv
[
1
],
"install-helpers"
)
==
0
)
{
Backend
backend
;
QApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
);
QApplication
::
setApplicationName
(
backend
.
getAppName
());
QApplication
::
setApplicationVersion
(
backend
.
getVersion
());
QApplication
app
(
argc
,
argv
);
QCommandLineParser
parser
;
parser
.
setApplicationDescription
(
backend
.
getAppName
()
+
": a fast and secure VPN. Powered by Bitmask."
);
parser
.
addHelpOption
();
parser
.
addVersionOption
();
parser
.
process
(
app
);
const
QStringList
args
=
parser
.
positionalArguments
();
if
(
args
.
at
(
0
)
==
"install-helpers"
)
{
qDebug
()
<<
"Will try to install helpers with sudo"
;
InstallHelpers
();
exit
(
0
);
}
QApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
);
QApplication
app
(
argc
,
argv
);
if
(
!
QSystemTrayIcon
::
isSystemTrayAvailable
())
{
qDebug
()
<<
"No systray icon available. Things might not work for now, sorry..."
;
}
...
...
@@ -72,7 +82,6 @@ int main(int argc, char **argv) {
/* the backend handler has slots for calling back to Go when triggered by
signals in Qml. */
Backend
backend
;
ctx
->
setContextProperty
(
"backend"
,
&
backend
);
/* set the json model, load the qml */
...
...
This diff is collapsed.
Click to expand it.
pkg/backend/api.go
+
15
−
0
View file @
eb97dc51
...
...
@@ -9,6 +9,7 @@ import (
"unsafe"
"0xacab.org/leap/bitmask-vpn/pkg/bitmask"
"0xacab.org/leap/bitmask-vpn/pkg/config/version"
"0xacab.org/leap/bitmask-vpn/pkg/pickle"
)
...
...
@@ -74,3 +75,17 @@ func EnableMockBackend() {
log
.
Println
(
"[+] Mocking ui interaction on port 8080.
\n
Try 'curl localhost:8080/{on|off|failed}' to toggle status."
)
go
enableMockBackend
()
}
/* these two are a bit redundant since we already add them to ctx. however, we
want to have them available before everything else, to be able to parse cli
arguments. In the long run, we probably want to move all vendoring to qt, so
this probably should not live in the backend. */
func
GetVersion
()
*
C
.
char
{
return
C
.
CString
(
version
.
VERSION
)
}
func
GetAppName
()
*
C
.
char
{
p
:=
bitmask
.
GetConfiguredProvider
()
return
C
.
CString
(
p
.
AppName
)
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment