-
Notifications
You must be signed in to change notification settings - Fork 6
/
appsettings.cpp
200 lines (174 loc) · 5.67 KB
/
appsettings.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/****************************************************************************
**
** Copyright (C) 2012-2013 Andreas Jakl.
** All rights reserved.
** Contact: Andreas Jakl ([email protected])
**
** This file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
****************************************************************************/
#include "appsettings.h"
AppSettings::AppSettings(QObject *parent) :
QObject(parent),
m_logNdefToFile(true),
m_logNdefDir(DEFAULT_NDEF_LOG_DIR),
m_deleteTagBeforeWriting(false),
#if defined(MEEGO_EDITION_HARMATTAN) && !defined(USE_SNEP)
m_useSnep(false), // MeeGo: not allowed to use SNEP port
#else
m_useSnep(true),
#endif
m_useConnectionLess(false),
m_nfcUri(LLCP_CONNECTIONORIENTED_SERVICENAME),
m_nfcPort(LLCP_CONNECTIONLESS_PORT),
m_sendThroughServerSocket(false),
m_connectClientSocket(true),
m_connectServerSocket(true)
{
loadSettings();
}
void AppSettings::setUseConnectionLess(const bool useConnectionLess)
{
if (useConnectionLess != m_useConnectionLess) {
m_useConnectionLess = useConnectionLess;
}
}
bool AppSettings::useConnectionLess() const
{
return m_useConnectionLess;
}
void AppSettings::setNfcUri(const QString &nfcUri)
{
if (nfcUri != m_nfcUri) {
m_nfcUri = nfcUri;
}
}
QString AppSettings::nfcUri() const
{
return m_nfcUri;
}
void AppSettings::setNfcPort(const int nfcPort)
{
if (nfcPort != m_nfcPort) {
m_nfcPort = nfcPort;
}
}
int AppSettings::nfcPort() const
{
return m_nfcPort;
}
void AppSettings::setSendThroughServerSocket(const bool sendThroughServerSocket)
{
if (sendThroughServerSocket != m_sendThroughServerSocket) {
m_sendThroughServerSocket = sendThroughServerSocket;
}
}
bool AppSettings::sendThroughServerSocket() const
{
return m_sendThroughServerSocket;
}
void AppSettings::setConnectClientSocket(const bool connectClientSocket)
{
if (connectClientSocket != m_connectClientSocket) {
m_connectClientSocket = connectClientSocket;
}
}
bool AppSettings::connectClientSocket() const
{
return m_connectClientSocket;
}
void AppSettings::setConnectServerSocket(const bool connectServerSocket)
{
if (connectServerSocket != m_connectServerSocket) {
m_connectServerSocket = connectServerSocket;
}
}
bool AppSettings::connectServerSocket() const
{
return m_connectServerSocket;
}
void AppSettings::setLogNdefToFile(const bool logNdefToFile)
{
if (logNdefToFile != m_logNdefToFile) {
m_logNdefToFile = logNdefToFile;
}
}
bool AppSettings::logNdefToFile() const
{
return m_logNdefToFile;
}
void AppSettings::setLogNdefDir(const QString &logNdefDir)
{
if (logNdefDir != m_logNdefDir) {
m_logNdefDir = logNdefDir;
}
}
QString AppSettings::logNdefDir() const
{
return m_logNdefDir;
}
QString AppSettings::logNdefDir(const bool collected)
{
return m_logNdefDir + (collected ? COLLECTED_LOG_DIR : SAVED_LOG_DIR);
}
void AppSettings::setDeleteTagBeforeWriting(const bool deleteTagBeforeWriting)
{
if (deleteTagBeforeWriting != m_deleteTagBeforeWriting) {
m_deleteTagBeforeWriting = deleteTagBeforeWriting;
}
}
bool AppSettings::deleteTagBeforeWriting() const
{
return m_deleteTagBeforeWriting;
}
void AppSettings::setUseSnep(const bool useSnep)
{
if (useSnep != m_useSnep) {
m_useSnep = useSnep;
}
}
bool AppSettings::useSnep() const
{
return m_useSnep;
}
void AppSettings::saveSettings()
{
QSettings settings(SETTINGS_ORG, SETTINGS_APP, this);
settings.setValue("settingsversion", SETTINGS_VERSION);
settings.setValue("logNdefToFile", m_logNdefToFile);
settings.setValue("logNdefDir", m_logNdefDir);
settings.setValue("deleteTags", m_deleteTagBeforeWriting);
settings.setValue("useSnep", m_useSnep);
settings.setValue("useConnectionLess", m_useConnectionLess);
settings.setValue("nfcUri", m_nfcUri);
settings.setValue("nfcPort", m_nfcPort);
settings.setValue("sendThroughServerSocket", m_sendThroughServerSocket);
settings.setValue("connectClientSocket", m_connectClientSocket);
settings.setValue("connectServerSocket", m_connectServerSocket);
}
void AppSettings::loadSettings()
{
QSettings settings(SETTINGS_ORG, SETTINGS_APP, this);
if (settings.value("settingsversion", -1) == SETTINGS_VERSION) {
// Only load settings from version SETTINGS_VERSION with this code
m_logNdefToFile = settings.value("logNdefToFile", true).toBool();
m_logNdefDir = settings.value("logNdefDir", DEFAULT_NDEF_LOG_DIR).toString();
m_deleteTagBeforeWriting = settings.value("deleteTags", false).toBool();
#if defined(MEEGO_EDITION_HARMATTAN) && !defined(USE_SNEP)
m_useSnep = settings.value("useSnep", false).toBool(); // MeeGo: not allowed to use SNEP port
#else
m_useSnep = settings.value("useSnep", true).toBool();
#endif
m_useConnectionLess = settings.value("useConnectionLess", true).toBool();
m_nfcUri = settings.value("nfcUri", LLCP_CONNECTIONORIENTED_SERVICENAME).toString();
m_nfcPort = settings.value("nfcPort", LLCP_CONNECTIONLESS_PORT).toInt();
m_sendThroughServerSocket = settings.value("sendThroughServerSocket", true).toBool();
m_connectClientSocket = settings.value("connectClientSocket", true).toBool();
m_connectServerSocket = settings.value("connectServerSocket", true).toBool();
}
}