aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core')
-rw-r--r--src-qt5/core/libLumina/LUtils.pri13
-rw-r--r--src-qt5/core/libLumina/LuminaOS.h2
-rw-r--r--src-qt5/core/libLumina/OSInterface-template.cpp100
-rw-r--r--src-qt5/core/libLumina/OSInterface.h136
4 files changed, 248 insertions, 3 deletions
diff --git a/src-qt5/core/libLumina/LUtils.pri b/src-qt5/core/libLumina/LUtils.pri
index d5941a41..6ce0839c 100644
--- a/src-qt5/core/libLumina/LUtils.pri
+++ b/src-qt5/core/libLumina/LUtils.pri
@@ -3,7 +3,7 @@
include("$${PWD}/../../OS-detect.pri")
-QT *= concurrent
+QT *= concurrent network
#Setup any special defines (qmake -> C++)
GIT_VERSION=$$system(git describe --always)
@@ -15,7 +15,9 @@ GIT_VERSION=$$system(git describe --always)
#DEFINES += BUILD_DATE='"\\\"$$system(date)\\\""'
#LuminaOS files
-HEADERS *= $${PWD}/LuminaOS.h
+HEADERS *= $${PWD}/LuminaOS.h \
+ $${PWD}/OSInterface.h
+
# LuminaOS support functions (or fall back to generic one)
exists($${PWD}/LuminaOS-$${LINUX_DISTRO}.cpp){
SOURCES *= $${PWD}/LuminaOS-$${LINUX_DISTRO}.cpp
@@ -24,6 +26,13 @@ exists($${PWD}/LuminaOS-$${LINUX_DISTRO}.cpp){
}else{
SOURCES *= $${PWD}/LuminaOS-template.cpp
}
+exists($${PWD}/OSInterface-$${LINUX_DISTRO}.cpp){
+ SOURCES *= $${PWD}/OSInterface-$${LINUX_DISTRO}.cpp
+}else:exists($${PWD}/OSInterface-$${OS}.cpp){
+ SOURCES *= $${PWD}/OSInterface-$${OS}.cpp
+}else{
+ SOURCES *= $${PWD}/OSInterface-template.cpp
+}
#LUtils Files
SOURCES *= $${PWD}/LUtils.cpp
diff --git a/src-qt5/core/libLumina/LuminaOS.h b/src-qt5/core/libLumina/LuminaOS.h
index 96a587a8..e7a72129 100644
--- a/src-qt5/core/libLumina/LuminaOS.h
+++ b/src-qt5/core/libLumina/LuminaOS.h
@@ -1,6 +1,6 @@
//===========================================
// Lumina-DE source code
-// Copyright (c) 2014-16, Ken Moore
+// Copyright (c) 2014-17, Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
diff --git a/src-qt5/core/libLumina/OSInterface-template.cpp b/src-qt5/core/libLumina/OSInterface-template.cpp
new file mode 100644
index 00000000..62915f2f
--- /dev/null
+++ b/src-qt5/core/libLumina/OSInterface-template.cpp
@@ -0,0 +1,100 @@
+//===========================================
+// Lumina desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include <OSInterface.h>
+
+//===========
+// PUBLIC
+//===========
+
+//Simple functions used to determine if the current OS supports using this class, and what levels of support
+QList<OSInterface::Interface> OSInterface::supportedNotifications(){
+ //Which interfaces provide change notifications
+ return QList< OSInterface::Interface >();
+}
+
+QList<OSInterface::Interface> OSInterface::supportedStatus(){
+ //Which interfaces are available for "status" requests
+ return QList< OSInterface::Interface >();
+}
+
+QList<OSInterface::Interface> OSInterface::supportedModify(){
+ //Which interfaces are available for "modify" requests
+ return QList< OSInterface::Interface >();
+}
+
+//Start/stop interface watchers/notifications (each only called once per session)
+void OSInterface::start(){
+ //nothing to do
+}
+
+void OSInterface::stop(){
+ //nothing to do
+}
+
+//Generic status update
+QList<QVariant> OSInterface::status(OSInterface::Interface){
+ // ==== Interface status output lists ====
+ // Battery: [ float (percent charge), bool (is Charging), double (seconds remaining) ];
+ // Volume: [int (percent volume) ]
+ // Devices: [ QStringList[ name, mountpoint, type (optional)] ] (List length depends on number of devices)
+ // Network: [bool (network access available)]
+ // PowerOff: [bool (can power off system)]
+ // Reboot: [bool (can reboot system)]
+ // Suspend: [bool (can suspend system)]
+ // Updates: [bool (is updating), bool (reboot required)]
+ // ==========
+ return QList<QVariant>();
+}
+
+//Individual Interface interactions
+bool OSInterface::modify(OSInterface::Interface, QList<QVariant> args){ //returns: success/failure
+ // ==== Interface modification argument lists ====
+ // Battery: <NO MODIFICATION>
+ // Volume: [int (set percent volume) ]
+ // Devices: <NO MODIFICATION>
+ // Network: <NO MODIFICATION>
+ // PowerOff: [bool (skip updates - optional)]
+ // Reboot: [bool (skip updates - optional)]
+ // Suspend: [] (No input arguments)
+ // Updates: <NO MODIFICATION>
+ // ==========
+ return false;
+}
+
+//=================
+// PRIVATE SLOTS
+//=================
+//FileSystemWatcher slots
+void OSInterface::watcherFileChanged(QString){
+
+}
+
+void OSInterface::watcherDirChanged(QString){
+
+}
+
+//IO Device slots
+void OSInterface::iodeviceReadyRead(){
+
+}
+
+void OSInterface::iodeviceAboutToClose(){
+
+}
+
+//NetworkAccessManager slots
+void OSInterface::netAccessChanged(QNetworkAccessManager::NetworkAccessibility){
+
+}
+
+void OSInterface::netRequestFinished(QNetworkReply*){
+
+}
+
+void OSInterface::netSslErrors(QNetworkReply*, const QList<QSslError>&){
+
+}
diff --git a/src-qt5/core/libLumina/OSInterface.h b/src-qt5/core/libLumina/OSInterface.h
new file mode 100644
index 00000000..acbd5c38
--- /dev/null
+++ b/src-qt5/core/libLumina/OSInterface.h
@@ -0,0 +1,136 @@
+//===========================================
+// Lumina desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is the main interface for any OS-specific system calls
+// To port Lumina to a different operating system, just create a file
+// called "OSInterface-<Operating System>.cpp"
+//===========================================
+#ifndef _LUMINA_LIBRARY_OS_INTERFACE_H
+#define _LUMINA_LIBRARY_OS_INTERFACE_H
+
+#include <QString>
+#include <QStringList>
+#include <QList>
+#include <QObject>
+#include <QVariant>
+#include <QHash>
+
+#include <QIODevice>
+#include <QFileSystemWatcher>
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <QSslError>
+
+class OSInterface : public QObject{
+ Q_OBJECT
+
+public:
+ enum Interface{ Battery, Volume, Devices, Network, PowerOff, Reboot, Suspend, Updates };
+
+private slots:
+ //FileSystemWatcher slots
+ void watcherFileChanged(QString);
+ void watcherDirChanged(QString);
+ //IO Device slots
+ void iodeviceReadyRead();
+ void iodeviceAboutToClose();
+ //NetworkAccessManager slots
+ void netAccessChanged(QNetworkAccessManager::NetworkAccessibility);
+ void netRequestFinished(QNetworkReply*);
+ void netSslErrors(QNetworkReply*, const QList<QSslError>&);
+
+private:
+ //Internal persistant data storage, OS-specific usage implementation
+ QHash< OSInterface::Interface, QList<QVariant> > INFO;
+
+ // ============
+ // Internal possibilities for watching the system (OS-Specific usage/implementation)
+ // ============
+ //File System Watcher
+ QFileSystemWatcher *watcher;
+ //IO Device (QLocalSocket, QTcpConnection, QFile, etc)
+ QIODevice *iodevice;
+ //Network Access Manager (check network connectivity, etc)
+ QNetworkAccessManager *netman;
+
+ //Simplifications for connecting the various watcher objects to their respective slots
+ void connectWatcher(){
+ if(watcher==0){ return; }
+ connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherFileChanged(QString)) );
+ connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(watcherDirChanged(QString)) );
+ }
+ void connectIodevice(){
+ if(iodevice==0){ return; }
+ connect(iodevice, SIGNAL(readyRead()), this, SLOT(iodeviceReadyRead()) );
+ }
+ void connectNetman(){
+ if(netman==0){ return; }
+ connect(netman, SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)), this, SLOT(netAccessChanged(QNetworkAccessManager::NetworkAccessibility)) );
+ connect(netman, SIGNAL(requestFinished(QNetworkReply*)), this, SLOT(netRequestFinished(QNetworkReply*)) );
+ connect(netman, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT(netSslErrors(QNetworkReply*, const QList<QSslError>&)) );
+ }
+
+public:
+ OSInterface(QObject *parent = 0) : QObject(parent){
+ watcher = 0;
+ iodevice = 0;
+ netman = 0;
+ }
+ ~OSInterface(){
+ if(watcher!=0){
+ QStringList paths; paths << watcher->files() << watcher->directories();
+ if(!paths.isEmpty()){ watcher->removePaths(paths); }
+ watcher->deleteLater();
+ }
+ if(iodevice!=0){
+ if(iodevice->isOpen()){ iodevice->close(); }
+ iodevice->deleteLater();
+ }
+ if(netman!=0){
+ netman->deleteLater();
+ }
+ }
+
+ //Simple functions used to determine if the current OS supports using this class, and what levels of support
+ QList<OSInterface::Interface> supportedNotifications(); //Which interfaces provide change notifications
+ QList<OSInterface::Interface> supportedStatus(); //Which interfaces are available for "status" requests
+ QList<OSInterface::Interface> supportedModify(); //Which interfaces are available for "modify" requests
+
+ //Start/stop interface watchers/notifications (each only called once per session)
+ void start();
+ void stop();
+
+ //Generic status update
+ QList<QVariant> status(OSInterface::Interface);
+ // ==== Interface status output lists ====
+ // Battery: [ float (percent charge), bool (is Charging), double (seconds remaining) ];
+ // Volume: [int (percent volume) ]
+ // Devices: [ QStringList[ name, mountpoint, type (optional)] ] (List length depends on number of devices)
+ // Network: [bool (network access available)]
+ // PowerOff: [bool (can power off system)]
+ // Reboot: [bool (can reboot system)]
+ // Suspend: [bool (can suspend system)]
+ // Updates: [bool (is updating), bool (reboot required)]
+ // ==========
+
+ //Individual Interface interactions
+ bool modify(OSInterface::Interface, QList<QVariant> args); //returns: success/failure
+ // ==== Interface modification argument lists ====
+ // Battery: <NO MODIFICATION>
+ // Volume: [int (set percent volume) ]
+ // Devices: <NO MODIFICATION>
+ // Network: <NO MODIFICATION>
+ // PowerOff: [bool (skip updates - optional)]
+ // Reboot: [bool (skip updates - optional)]
+ // Suspend: [] (No input arguments)
+ // Updates: <NO MODIFICATION>
+ // ==========
+
+signals:
+ void interfaceChanged(OSInterface::Interface);
+
+};
+#endif
bgstack15