Display error when OpenConnect was not found (#81)

This commit is contained in:
Kevin Yue 2021-08-21 19:32:13 +08:00 committed by GitHub
parent 6352e1fb2b
commit 9f9444a72b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 1 deletions

View File

@ -31,6 +31,7 @@ GPClient::GPClient(QWidget *parent)
vpn = new com::yuezk::qt::GPService("com.yuezk.qt.GPService", "/", QDBusConnection::systemBus(), this);
connect(vpn, &com::yuezk::qt::GPService::connected, this, &GPClient::onVPNConnected);
connect(vpn, &com::yuezk::qt::GPService::disconnected, this, &GPClient::onVPNDisconnected);
connect(vpn, &com::yuezk::qt::GPService::error, this, &GPClient::onVPNError);
connect(vpn, &com::yuezk::qt::GPService::logAvailable, this, &GPClient::onVPNLogAvailable);
// Initiallize the context menu of system tray.
@ -477,6 +478,12 @@ void GPClient::onVPNDisconnected()
}
}
void GPClient::onVPNError(QString errorMessage)
{
updateConnectionStatus(VpnStatus::disconnected);
openMessageBox("Failed to connect", errorMessage);
}
void GPClient::onVPNLogAvailable(QString log)
{
PLOGI << log;

View File

@ -45,6 +45,7 @@ private slots:
void onVPNConnected();
void onVPNDisconnected();
void onVPNError(QString errorMessage);
void onVPNLogAvailable(QString log);
private:

View File

@ -99,7 +99,8 @@ void GPService::connect(QString server, QString username, QString passwd, QStrin
QString bin = findBinary();
if (bin == nullptr) {
log("Could not found openconnect binary, make sure openconnect is installed, exiting.");
log("Could not find openconnect binary, make sure openconnect is installed, exiting.");
emit error("The OpenConect CLI was not found, make sure it has been installed!");
return;
}

View File

@ -31,6 +31,7 @@ public:
signals:
void connected();
void disconnected();
void error(QString errorMessage);
void logAvailable(QString log);
public slots:

View File

@ -8,6 +8,9 @@
<signal name="logAvailable">
<arg name="log" type="s" />
</signal>
<signal name="error">
<arg name="errorMessage" type="s" />
</signal>
<method name="connect">
<arg name="server" type="s" direction="in"/>
<arg name="username" type="s" direction="in"/>