1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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>&)) );
}
|