mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
update packaging
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
TARGET = gpservice
|
||||
|
||||
QT += dbus
|
||||
#QT += dbus
|
||||
QT -= gui
|
||||
|
||||
CONFIG += c++11 console
|
||||
@@ -21,32 +21,32 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
HEADERS += \
|
||||
gpservice.h \
|
||||
# gpservice.h \
|
||||
sigwatch.h
|
||||
|
||||
SOURCES += \
|
||||
gpservice.cpp \
|
||||
# gpservice.cpp \
|
||||
main.cpp \
|
||||
sigwatch.cpp
|
||||
|
||||
DBUS_ADAPTORS += gpservice.xml
|
||||
#DBUS_ADAPTORS += gpservice.xml
|
||||
|
||||
# Default rules for deployment.
|
||||
target.path = /usr/bin
|
||||
INSTALLS += target
|
||||
|
||||
DISTFILES += \
|
||||
dbus/com.yuezk.qt.GPService.conf \
|
||||
dbus/com.yuezk.qt.GPService.service \
|
||||
systemd/gpservice.service
|
||||
#DISTFILES += \
|
||||
# dbus/com.yuezk.qt.GPService.conf \
|
||||
# dbus/com.yuezk.qt.GPService.service \
|
||||
# systemd/gpservice.service
|
||||
|
||||
dbus_config.path = /usr/share/dbus-1/system.d/
|
||||
dbus_config.files = dbus/com.yuezk.qt.GPService.conf
|
||||
#dbus_config.path = /usr/share/dbus-1/system.d/
|
||||
#dbus_config.files = dbus/com.yuezk.qt.GPService.conf
|
||||
|
||||
dbus_service.path = /usr/share/dbus-1/system-services/
|
||||
dbus_service.files = dbus/com.yuezk.qt.GPService.service
|
||||
#dbus_service.path = /usr/share/dbus-1/system-services/
|
||||
#dbus_service.files = dbus/com.yuezk.qt.GPService.service
|
||||
|
||||
systemd_service.path = /etc/systemd/system/
|
||||
systemd_service.files = systemd/gpservice.service
|
||||
#systemd_service.path = /etc/systemd/system/
|
||||
#systemd_service.files = systemd/gpservice.service
|
||||
|
||||
INSTALLS += dbus_config dbus_service systemd_service
|
||||
#INSTALLS += dbus_config dbus_service systemd_service
|
||||
|
@@ -5,6 +5,7 @@
|
||||
#include <QtDBus>
|
||||
#include <QDateTime>
|
||||
#include <QVariant>
|
||||
#include <QProcessEnvironment>
|
||||
|
||||
GPService::GPService(QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -99,22 +100,16 @@ void GPService::connect(QString server, QString username, QString passwd, QStrin
|
||||
return;
|
||||
}
|
||||
|
||||
log("Before findBinary");
|
||||
|
||||
// QString bin = findBinary();
|
||||
|
||||
// log("After findBinary");
|
||||
|
||||
// if (bin == nullptr) {
|
||||
// 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;
|
||||
// }
|
||||
QString bin = findBinary();
|
||||
if (bin == nullptr) {
|
||||
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;
|
||||
}
|
||||
|
||||
QStringList args;
|
||||
args << QCoreApplication::arguments().mid(1)
|
||||
<< "--protocol=gp"
|
||||
<< "-s" << qgetenv("VPNC_SCRIPT")
|
||||
<< splitCommand(extraArgs)
|
||||
<< "-u" << username
|
||||
<< "-C" << passwd
|
||||
@@ -122,7 +117,9 @@ void GPService::connect(QString server, QString username, QString passwd, QStrin
|
||||
|
||||
log("Start process with arugments: " + args.join(" "));
|
||||
|
||||
openconnect->start("openconnect", args);
|
||||
log("ENV for OC: " + openconnect->environment().join("\n"));
|
||||
log("ENV for gpservice: " + QProcessEnvironment::systemEnvironment().toStringList().join("\n"));
|
||||
openconnect->start(bin, args);
|
||||
}
|
||||
|
||||
void GPService::disconnect()
|
||||
|
@@ -1,26 +1,33 @@
|
||||
#include <QtDBus>
|
||||
#include "gpservice.h"
|
||||
//#include "gpservice.h"
|
||||
#include "singleapplication.h"
|
||||
#include "sigwatch.h"
|
||||
#include "iostream"
|
||||
|
||||
//#include <QtDBus>
|
||||
#include <QProcessEnvironment>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SingleApplication app(argc, argv);
|
||||
|
||||
if (!QDBusConnection::systemBus().isConnected()) {
|
||||
qWarning("Cannot connect to the D-Bus session bus.\n"
|
||||
"Please check your system settings and try again.\n");
|
||||
return 1;
|
||||
}
|
||||
// if (!QDBusConnection::systemBus().isConnected()) {
|
||||
// qWarning("Cannot connect to the D-Bus session bus.\n"
|
||||
// "Please check your system settings and try again.\n");
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
GPService service;
|
||||
// GPService service;
|
||||
|
||||
QString env = "ENV: " + QProcessEnvironment::systemEnvironment().toStringList().join("\n");
|
||||
std::cout << env.toStdString();
|
||||
|
||||
UnixSignalWatcher sigwatch;
|
||||
sigwatch.watchForSignal(SIGINT);
|
||||
sigwatch.watchForSignal(SIGTERM);
|
||||
sigwatch.watchForSignal(SIGQUIT);
|
||||
sigwatch.watchForSignal(SIGHUP);
|
||||
QObject::connect(&sigwatch, &UnixSignalWatcher::unixSignal, &service, &GPService::quit);
|
||||
// QObject::connect(&sigwatch, &UnixSignalWatcher::unixSignal, &service, &GPService::quit);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
Reference in New Issue
Block a user