aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/src-cpp/OSInterface_private.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-12-05 15:54:11 -0500
committerKen Moore <ken@ixsystems.com>2017-12-05 15:58:09 -0500
commitb99985a3d4aa953bd694228bc4b3fadbd158581c (patch)
treebb44677d1a31ee4442c92224c728cfb3e122a5c7 /src-qt5/src-cpp/OSInterface_private.cpp
parentMerge branch 'master' of github.com:trueos/lumina (diff)
downloadlumina-b99985a3d4aa953bd694228bc4b3fadbd158581c.tar.gz
lumina-b99985a3d4aa953bd694228bc4b3fadbd158581c.tar.bz2
lumina-b99985a3d4aa953bd694228bc4b3fadbd158581c.zip
Move the new OSInterface class over to the base-level src-cpp directory.
Also get it all prepped/staged to be used by QML objects (not finished yet)
Diffstat (limited to 'src-qt5/src-cpp/OSInterface_private.cpp')
-rw-r--r--src-qt5/src-cpp/OSInterface_private.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src-qt5/src-cpp/OSInterface_private.cpp b/src-qt5/src-cpp/OSInterface_private.cpp
new file mode 100644
index 00000000..bd2d17b5
--- /dev/null
+++ b/src-qt5/src-cpp/OSInterface_private.cpp
@@ -0,0 +1,56 @@
+//===========================================
+// Lumina desktop source code
+// Copyright (c) 2017, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// Internal, OS-agnostic functionality for managing the object itself
+//===========================================
+#include <OSInterface.h>
+
+OSInterface::OSInterface(QObject *parent) : QObject(parent){
+ watcher = 0;
+ iodevice = 0;
+ netman = 0;
+}
+
+OSInterface::~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();
+ }
+}
+
+OSInterface::OSInterface* instance(){
+ static OSInterface* m_os_object = 0;
+ if(m_os_object==0){
+ m_os_object = new OSInterface();
+ }
+ return m_os_object;
+}
+
+void OSInterface::connectWatcher(){
+ if(watcher==0){ return; }
+ connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherFileChanged(QString)) );
+ connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(watcherDirChanged(QString)) );
+}
+
+void OSInterface::connectIodevice(){
+ if(iodevice==0){ return; }
+ connect(iodevice, SIGNAL(readyRead()), this, SLOT(iodeviceReadyRead()) );
+}
+
+void OSInterface::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>&)) );
+}
bgstack15