Skip to content
Snippets Groups Projects
Unverified Commit 339a30fd authored by Kali Kaneko's avatar Kali Kaneko
Browse files

[feat] reset error

parent 30587fb2
No related branches found
No related tags found
No related merge requests found
[default] [default]
provider = riseup provider = demolib
[riseup] [riseup]
......
...@@ -23,8 +23,8 @@ func GetAppName() *C.char { ...@@ -23,8 +23,8 @@ func GetAppName() *C.char {
} }
//export Login //export Login
func Login(username, password *C.char) { func Login(username, password string) {
backend.Login(C.GoString(username), C.GoString(password)) backend.Login(username, password)
} }
//export SwitchOn //export SwitchOn
...@@ -76,6 +76,11 @@ func RefreshContext() *C.char { ...@@ -76,6 +76,11 @@ func RefreshContext() *C.char {
return (*C.char)(backend.RefreshContext()) return (*C.char)(backend.RefreshContext())
} }
//export ResetError
func ResetError(errname string) {
backend.ResetError(errname)
}
//export InstallHelpers //export InstallHelpers
func InstallHelpers() { func InstallHelpers() {
backend.InstallHelpers() backend.InstallHelpers()
......
...@@ -6,6 +6,13 @@ ...@@ -6,6 +6,13 @@
#include "handlers.h" #include "handlers.h"
#include "lib/libgoshim.h" #include "lib/libgoshim.h"
GoString toGoStr(QString s)
{
char *c = s.toLocal8Bit().data();
return (GoString){c, (long int)strlen(c)};
}
Backend::Backend(QObject *parent) : QObject(parent) Backend::Backend(QObject *parent) : QObject(parent)
{ {
} }
...@@ -37,14 +44,12 @@ void Backend::donateAccepted() ...@@ -37,14 +44,12 @@ void Backend::donateAccepted()
void Backend::login(QString username, QString password) void Backend::login(QString username, QString password)
{ {
// TODO: there has to be a cleaner way to do the conversion Login(toGoStr(username), toGoStr(password));
char * u = new char [username.length()+1]; }
char * p = new char [password.length()+1];
strcpy(u, username.toStdString().c_str()); void Backend::resetError(QString errlabel)
strcpy(p, password.toStdString().c_str()); {
Login(u, p); ResetError(toGoStr(errlabel));
delete [] u;
delete [] p;
} }
void Backend::quit() void Backend::quit()
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include <QDebug> #include <QDebug>
#include <QObject> #include <QObject>
#include "qjsonmodel.h" #include "qjsonmodel.h"
#include "lib/libgoshim.h"
GoString toGoStr(QString s);
class QJsonWatch : public QObject { class QJsonWatch : public QObject {
...@@ -36,6 +39,7 @@ public slots: ...@@ -36,6 +39,7 @@ public slots:
void switchOff(); void switchOff();
void donateAccepted(); void donateAccepted();
void login(QString username, QString password); void login(QString username, QString password);
void resetError(QString errlabel);
void quit(); void quit();
}; };
......
...@@ -144,9 +144,7 @@ int main(int argc, char **argv) { ...@@ -144,9 +144,7 @@ int main(int argc, char **argv) {
/* if requested, enable web api for controlling the VPN */ /* if requested, enable web api for controlling the VPN */
if (webAPI) { if (webAPI) {
char* wp = webPort.toLocal8Bit().data(); EnableWebAPI(toGoStr(webPort));
GoString p = {wp, (long int)strlen(wp)};
EnableWebAPI(p);
}; };
/* kick off your shoes, put your feet up */ /* kick off your shoes, put your feet up */
......
...@@ -12,9 +12,8 @@ Dialog { ...@@ -12,9 +12,8 @@ Dialog {
} }
} }
// TODO implement cleanNotifications on backend
function _loginOk() { function _loginOk() {
loginDone = true; backend.resetError("bad_auth")
} }
visible: false visible: false
......
...@@ -85,6 +85,11 @@ func RefreshContext() *C.char { ...@@ -85,6 +85,11 @@ func RefreshContext() *C.char {
return C.CString(string(c)) return C.CString(string(c))
} }
func ResetError(errname string) {
log.Println("DEBUG: resetting error", errname)
resetErrors(errname)
}
func InstallHelpers() { func InstallHelpers() {
pickle.InstallHelpers() pickle.InstallHelpers()
} }
...@@ -105,7 +110,7 @@ func EnableWebAPI(port string) { ...@@ -105,7 +110,7 @@ func EnableWebAPI(port string) {
/* these two are a bit redundant since we already add them to ctx. however, we /* 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 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 arguments. In the long run, we probably want to move all vendoring to qt, so
this probably should not live in the backend. */ this probably should not live in the backend, see #326*/
func GetVersion() *C.char { func GetVersion() *C.char {
return C.CString(version.VERSION) return C.CString(version.VERSION)
......
...@@ -34,11 +34,19 @@ func initializeContext(opts *InitOpts) { ...@@ -34,11 +34,19 @@ func initializeContext(opts *InitOpts) {
func checkErrors(errCh chan string) { func checkErrors(errCh chan string) {
for { for {
err := <-errCh err := <-errCh
// TODO consider a queue instead
ctx.Errors = err ctx.Errors = err
go trigger(OnStatusChanged) go trigger(OnStatusChanged)
} }
} }
func resetErrors(errname string) {
if ctx.Errors == errname {
ctx.Errors = ""
log.Println("DEBUG: reset error", errname)
}
}
func initializeBitmask(errCh chan string, opts *InitOpts) { func initializeBitmask(errCh chan string, opts *InitOpts) {
if ctx == nil { if ctx == nil {
log.Println("bug: cannot initialize bitmask, ctx is nil!") log.Println("bug: cannot initialize bitmask, ctx is nil!")
......
// Code generated by go generate; DO NOT EDIT. // Code generated by go generate; DO NOT EDIT.
// This file was generated by vendorize.py // This file was generated by vendorize.py
// At 2020-08-19 17:38:43 // At 2020-08-20 13:39:50
package config package config
/* All these constants are defined in the vendor.conf file /* All these constants are defined in the vendor.conf file
*/ */
const ( const (
Provider = "riseup.net" Provider = "vpnlib.bitmask.net"
ApplicationName = "RiseupVPN" ApplicationName = "DemoLib"
BinaryName = "riseup-vpn" BinaryName = "demo-lib"
Auth = "anon" Auth = "sip"
DonateURL = "https://riseup.net/vpn/donate" DonateURL = ""
AskForDonations = "true" AskForDonations = "false"
HelpURL = "https://riseup.net/support" HelpURL = "https://libraryvpn.org/"
TosURL = "https://riseup.net/tos" TosURL = "https://libraryvpn.org/"
APIURL = "https://api.black.riseup.net/" APIURL = "https://api.vpnlib.bitmask.net:4430/"
GeolocationAPI = "https://api.black.riseup.net:9001/json" GeolocationAPI = "https://getmyip.vpnlib.bitmask.net/json"
) )
var Version string var Version string
...@@ -29,34 +29,11 @@ CaCert : a string containing a representation of the provider CA, used to ...@@ -29,34 +29,11 @@ CaCert : a string containing a representation of the provider CA, used to
*/ */
var CaCert = []byte(`-----BEGIN CERTIFICATE----- var CaCert = []byte(`-----BEGIN CERTIFICAT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MFbixQmc8bGyuakr23wjMvfO7eZUxBuWYR2SkcP26sozF9PF
tGhbZHQVGZUTVPyvwahMUEhbPGVerOW0IYpxkm0x/eaWdTc4vPpf/rIlgbAjarnJ
UN9SaWRlWKSdP4haujnzCoJbM7dU9bjvlGZNyXEekgeT0W2qFeGGp+yyUWw8tNsp
0BuC1b7uW/bBn/xKm319wXVDvBgZgcktMolak39V7DVO
-----END CERTIFICATE-----`) -----END CERTIFICATE-----`)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment