Torc
0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
torc
torclocalcontext.h
Go to the documentation of this file.
1
#ifndef TORCLOCALCONTEXT_H
2
#define TORCLOCALCONTEXT_H
3
4
// Qt
5
#include <QObject>
6
#include <QString>
7
#include <QReadWriteLock>
8
#include <QMutex>
9
10
// Torc
11
#include "
torclocaldefs.h
"
12
#include "
torcsetting.h
"
13
#include "
torcobservable.h
"
14
#include "
torcsqlitedb.h
"
15
#include "
torcadminthread.h
"
16
#include "
torccommandline.h
"
17
18
#ifdef Q_OS_LINUX
19
#include <unistd.h>
20
#endif
21
22
class
TorcAdminObject
;
23
class
TorcLanguage
;
24
25
class
Torc
26
{
27
Q_GADGET
28
29
public
:
30
enum
Actions
31
{
32
None
= 0,
33
Start
,
34
Stop
,
35
RestartTorc
,
36
UserChanged
,
37
TorcWillStop
,
// or restart etc
38
// Power management
39
Shutdown
= 1000,
40
Suspend
,
41
Hibernate
,
42
Restart
,
43
ShuttingDown
,
44
Suspending
,
45
Hibernating
,
46
Restarting
,
47
WokeUp
,
48
LowBattery
,
49
// these are issued directly to the power object
50
// when a delayed event is issued
51
ShutdownNow
,
52
SuspendNow
,
53
HibernateNow
,
54
RestartNow
,
55
// network
56
NetworkAvailable
= 2000,
57
NetworkUnavailable
,
58
NetworkChanged
,
59
NetworkHostNamesChanged
,
60
// service discovery
61
ServiceDiscovered
= 3000,
62
ServiceWentAway
,
63
// system time
64
SystemTimeChanged
= 4000,
65
// end of predefined
66
MaxTorc
= 60000,
67
// plugins etc
68
MaxUser
= 65535
69
};
70
71
Q_ENUM(
Actions
)
72
};
73
74
class
TorcLocalContext
:
public
QObject,
public
TorcObservable
75
{
76
Q_OBJECT
77
78
public
:
79
static
qint16 Create (
TorcCommandLine
* CommandLine,
bool
Init =
true
);
80
static
void
TearDown (
void
);
81
82
static
void
NotifyEvent (
int
Event);
83
QString GetSetting (
const
QString &Name,
const
QString &DefaultValue);
84
bool
GetSetting (
const
QString &Name,
bool
DefaultValue);
85
int
GetSetting (
const
QString &Name,
int
DefaultValue);
86
void
SetSetting (
const
QString &Name,
const
QString &Value);
87
void
SetSetting (
const
QString &Name,
bool
Value);
88
void
SetSetting (
const
QString &Name,
int
Value);
89
QString GetUuid (
void
)
const
;
90
TorcSetting
* GetRootSetting (
void
);
91
qint64 GetStartTime (
void
);
92
int
GetPriority (
void
);
93
94
QLocale GetLocale (
void
);
95
TorcLanguage
* GetLanguage (
void
);
96
void
CloseDatabaseConnections (
void
);
97
bool
QueueShutdownEvent (
int
Event);
98
void
SetShutdownDelay (uint Delay);
99
uint GetShutdownDelay (
void
);
100
101
public
slots:
102
void
RegisterQThread (
void
);
103
void
DeregisterQThread (
void
);
104
bool
event (QEvent *Event)
override
;
105
void
ShutdownTimeout (
void
);
106
107
private
:
108
explicit
TorcLocalContext
(
TorcCommandLine
* CommandLine);
109
~
TorcLocalContext
();
110
Q_DISABLE_COPY(
TorcLocalContext
)
111
112
bool
Init (
void
);
113
QString GetDBSetting (
const
QString &Name,
const
QString &DefaultValue);
114
void
SetDBSetting (
const
QString &Name,
const
QString &Value);
115
bool
HandleShutdown (
int
Event);
116
117
private
:
118
TorcSQLiteDB
*m_sqliteDB;
119
QString m_dbName;
120
QMap<QString,QString> m_localSettings;
121
QReadWriteLock m_localSettingsLock;
122
TorcAdminThread
*m_adminThread;
123
TorcLanguage
*m_language;
124
QString m_uuid;
125
uint m_shutdownDelay;
126
int
m_shutdownEvent;
127
qint64 m_startTime;
128
TorcSetting
*m_rootSetting;
129
};
130
131
extern
TorcLocalContext
*
gLocalContext
;
132
133
#endif // TORCLOCALCONTEXT_H
Torc::ServiceDiscovered
Definition:
torclocalcontext.h:61
TorcAdminThread
A simple thread to launch helper objects outside of the main loop.
Definition:
torcadminthread.h:12
Torc::MaxTorc
Definition:
torclocalcontext.h:66
Torc::Restarting
Definition:
torclocalcontext.h:46
Torc::Restart
Definition:
torclocalcontext.h:42
gLocalContext
TorcLocalContext * gLocalContext
Definition:
torclocalcontext.cpp:48
torcsetting.h
TorcLocalContext
TorcLocalContext is the core Torc object.
Definition:
torclocalcontext.h:74
TorcSetting
A wrapper around a database setting.
Definition:
torcsetting.h:15
TorcAdminObject
A factory class for automatically running objects outside of the main loop.
Definition:
torcadminthread.h:28
Torc::ServiceWentAway
Definition:
torclocalcontext.h:62
Torc::SuspendNow
Definition:
torclocalcontext.h:52
torcadminthread.h
TorcCommandLine
Torc command line handler.
Definition:
torccommandline.h:14
Torc::Stop
Definition:
torclocalcontext.h:34
torclocaldefs.h
Torc
Definition:
torclocalcontext.h:25
Torc::NetworkChanged
Definition:
torclocalcontext.h:58
TorcLanguage
A class to track and manage language and locale settings and available translations.
Definition:
torclanguage.h:17
Torc::NetworkHostNamesChanged
Definition:
torclocalcontext.h:59
torcobservable.h
Torc::NetworkUnavailable
Definition:
torclocalcontext.h:57
Torc::LowBattery
Definition:
torclocalcontext.h:48
Torc::Shutdown
Definition:
torclocalcontext.h:39
Torc::None
Definition:
torclocalcontext.h:32
Torc::ShuttingDown
Definition:
torclocalcontext.h:43
Torc::UserChanged
Definition:
torclocalcontext.h:36
Torc::RestartTorc
Definition:
torclocalcontext.h:35
Torc::MaxUser
Definition:
torclocalcontext.h:68
torcsqlitedb.h
Torc::Hibernate
Definition:
torclocalcontext.h:41
Torc::SystemTimeChanged
Definition:
torclocalcontext.h:64
Torc::Hibernating
Definition:
torclocalcontext.h:45
Torc::Start
Definition:
torclocalcontext.h:33
Torc::Suspending
Definition:
torclocalcontext.h:44
Torc::TorcWillStop
Definition:
torclocalcontext.h:37
Torc::RestartNow
Definition:
torclocalcontext.h:54
Torc::Actions
Actions
Definition:
torclocalcontext.h:30
Torc::NetworkAvailable
Definition:
torclocalcontext.h:56
torccommandline.h
Torc::HibernateNow
Definition:
torclocalcontext.h:53
TorcObservable
TorcObservable will send event notifcations to registered 'listeners'.
Definition:
torcobservable.h:10
Torc::ShutdownNow
Definition:
torclocalcontext.h:51
TorcSQLiteDB
SQLite implementation of TorcDB.
Definition:
torcsqlitedb.h:6
Torc::Suspend
Definition:
torclocalcontext.h:40
Torc::WokeUp
Definition:
torclocalcontext.h:47
Generated on Sat Jan 5 2019 21:54:03 for Torc by
1.8.11