mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Migrate to cmake and refine the code structure (#92)
* migrate to cmake * move the 3rd party libs * organize 3rdparty * update the 3rd party version * refine the CMakeLists.txt * update install command * update install command * update install command * update install command * update dependency * update the dependency * update the dependency * remove CPM.cmake * remove QtCreator project file * update cmake file * improve cmake file * add cmakew * use wget * remove echo * update the doc * remove the screenshot * update the doc * update the install steps * check the openconnect version * update the doc * update install scripts * fix install scripts * improve message * improve message * improve install scripts * improve the version check * improve the version check * improve install script * add version * organize includes * add version bump * update CI * update CI * add the release flag * update message
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
#include "gpservice.h"
|
||||
#include "gpservice_adaptor.h"
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QRegularExpression>
|
||||
#include <QtCore/QRegularExpressionMatch>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QtDBus>
|
||||
#include <QDateTime>
|
||||
#include <QVariant>
|
||||
#include "gpservice.h"
|
||||
#include "gpserviceadaptor.h"
|
||||
|
||||
GPService::GPService(QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -104,19 +106,49 @@ void GPService::connect(QString server, QString username, QString passwd, QStrin
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isValidVersion(bin)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList args;
|
||||
args << QCoreApplication::arguments().mid(1)
|
||||
<< "--protocol=gp"
|
||||
<< splitCommand(extraArgs)
|
||||
<< "-u" << username
|
||||
<< "-C" << passwd
|
||||
<< server;
|
||||
<< "--protocol=gp"
|
||||
<< splitCommand(extraArgs)
|
||||
<< "-u" << username
|
||||
<< "-C" << passwd
|
||||
<< server;
|
||||
|
||||
log("Start process with arugments: " + args.join(" "));
|
||||
|
||||
openconnect->start(bin, args);
|
||||
}
|
||||
|
||||
bool GPService::isValidVersion(QString &bin) {
|
||||
QProcess p;
|
||||
p.start(bin, QStringList("--version"));
|
||||
p.waitForFinished();
|
||||
QString output = p.readAllStandardError() + p.readAllStandardOutput();
|
||||
|
||||
QRegularExpression re("v(\\d+).*?(\\s|\\n)");
|
||||
QRegularExpressionMatch match = re.match(output);
|
||||
|
||||
if (match.hasMatch()) {
|
||||
log("Output of `openconnect --version`: " + output);
|
||||
|
||||
QString fullVersion = match.captured(0);
|
||||
QString majorVersion = match.captured(1);
|
||||
|
||||
if (majorVersion.toInt() < 8) {
|
||||
emit error("The OpenConnect version must greater than v8.0.0, but got " + fullVersion);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
log("Failed to parse the OpenConnect version from " + output);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GPService::disconnect()
|
||||
{
|
||||
if (openconnect->state() != QProcess::NotRunning) {
|
||||
|
Reference in New Issue
Block a user