Skip to content

Latest commit

 

History

History
233 lines (186 loc) · 4.3 KB

ssud.cpp

File metadata and controls

233 lines (186 loc) · 4.3 KB
 
1
2
3
4
5
6
7
8
9
10
11
/**
* @file ssud.cpp
* @copyright 2013 Jolla Ltd.
* @author Bernd Wachter <bwachter@lart.info>
* @date 2013
*/
#include "ssud.h"
#include "ssuadaptor.h"
#include "libssu/ssudeviceinfo.h"
Sep 4, 2013
Sep 4, 2013
12
#include "libssu/ssurepomanager.h"
13
14
15
16
17
18
#include <QDBusConnection>
const char *Ssud::SERVICE_NAME = "org.nemo.ssu";
const char *Ssud::OBJECT_PATH = "/org/nemo/ssu";
May 24, 2017
May 24, 2017
19
20
Ssud::Ssud(QObject *parent)
: QObject(parent)
Oct 10, 2016
Oct 10, 2016
21
22
23
24
25
{
QDBusConnection connection = QDBusConnection::systemBus();
if (!connection.registerObject(OBJECT_PATH, this)) {
qFatal("Cannot register object at %s", OBJECT_PATH);
}
Oct 10, 2016
Oct 10, 2016
27
28
29
if (!connection.registerService(SERVICE_NAME)) {
qFatal("Cannot register D-Bus service at %s", SERVICE_NAME);
}
Sep 23, 2016
Sep 23, 2016
30
Oct 10, 2016
Oct 10, 2016
31
32
// prepare for controlled suicide on boredom
const int AUTOCLOSE_TIMEOUT_MS = 180 * 1000;
Oct 24, 2013
Oct 24, 2013
33
Oct 10, 2016
Oct 10, 2016
34
35
autoclose.setSingleShot(true);
autoclose.setInterval(AUTOCLOSE_TIMEOUT_MS);
Oct 24, 2013
Oct 24, 2013
36
Oct 10, 2016
Oct 10, 2016
37
38
connect(&autoclose, SIGNAL(timeout()),
this, SLOT(quit()));
Oct 24, 2013
Oct 24, 2013
39
Oct 10, 2016
Oct 10, 2016
40
new SsuAdaptor(this);
Oct 10, 2016
Oct 10, 2016
42
43
44
45
46
47
connect(&ssu, SIGNAL(done()),
this, SIGNAL(done()));
connect(&ssu, SIGNAL(credentialsChanged()),
this, SIGNAL(credentialsChanged()));
connect(&ssu, SIGNAL(registrationStatusChanged()),
this, SIGNAL(registrationStatusChanged()));
Oct 24, 2013
Oct 24, 2013
48
Oct 10, 2016
Oct 10, 2016
49
50
// a cry for help everytime we do something to prevent suicide
autoclose.start();
51
52
}
Oct 10, 2016
Oct 10, 2016
53
54
Ssud::~Ssud()
{
55
56
}
Oct 10, 2016
Oct 10, 2016
57
58
59
QString Ssud::deviceModel()
{
SsuDeviceInfo deviceInfo;
Oct 10, 2016
Oct 10, 2016
61
62
autoclose.start();
return deviceInfo.deviceModel();
Sep 4, 2013
Sep 4, 2013
63
64
}
Oct 10, 2016
Oct 10, 2016
65
66
67
QString Ssud::deviceFamily()
{
SsuDeviceInfo deviceInfo;
Sep 4, 2013
Sep 4, 2013
68
Oct 10, 2016
Oct 10, 2016
69
70
autoclose.start();
return deviceInfo.deviceFamily();
Sep 4, 2013
Sep 4, 2013
71
}
Oct 10, 2016
Oct 10, 2016
73
74
75
QString Ssud::deviceUid()
{
SsuDeviceInfo deviceInfo;
Oct 10, 2016
Oct 10, 2016
77
78
autoclose.start();
return deviceInfo.deviceUid();
Sep 4, 2013
Sep 4, 2013
79
80
}
Oct 10, 2016
Oct 10, 2016
81
82
83
QString Ssud::deviceVariant()
{
SsuDeviceInfo deviceInfo;
Sep 4, 2013
Sep 4, 2013
84
Oct 10, 2016
Oct 10, 2016
85
86
autoclose.start();
return deviceInfo.deviceVariant();
Sep 4, 2013
Sep 4, 2013
87
}
Oct 10, 2016
Oct 10, 2016
89
90
91
QString Ssud::displayName(int type)
{
SsuDeviceInfo deviceInfo;
Oct 24, 2013
Oct 24, 2013
92
Oct 10, 2016
Oct 10, 2016
93
94
autoclose.start();
return deviceInfo.displayName(type);
Oct 24, 2013
Oct 24, 2013
95
96
}
Oct 10, 2016
Oct 10, 2016
97
98
99
100
bool Ssud::error()
{
autoclose.start();
return ssu.error();
101
102
}
Oct 10, 2016
Oct 10, 2016
103
104
105
106
QString Ssud::lastError()
{
autoclose.start();
return ssu.lastError();
107
108
}
Oct 10, 2016
Oct 10, 2016
109
110
111
void Ssud::quit()
{
QCoreApplication::quit();
112
113
}
Oct 10, 2016
Oct 10, 2016
114
115
116
117
bool Ssud::isRegistered()
{
autoclose.start();
return ssu.isRegistered();
Sep 4, 2013
Sep 4, 2013
118
119
}
Oct 10, 2016
Oct 10, 2016
120
121
122
123
124
void Ssud::registerDevice(const QString &username, const QString &password)
{
autoclose.stop();
ssu.sendRegistration(username, password);
autoclose.start();
125
126
}
Oct 10, 2016
Oct 10, 2016
127
128
129
130
void Ssud::unregisterDevice()
{
autoclose.start();
ssu.unregister();
Sep 4, 2013
Sep 4, 2013
132
Oct 10, 2016
Oct 10, 2016
133
134
QString Ssud::domain()
{
Oct 30, 2015
Oct 30, 2015
135
136
137
autoclose.start();
return ssu.domain();
}
Sep 4, 2013
Sep 4, 2013
138
Jan 10, 2018
Jan 10, 2018
139
140
// called by DBus Adaptor, return integer instead of enum Ssu::DeviceModeFlags
int Ssud::deviceMode()
Oct 10, 2016
Oct 10, 2016
141
142
143
{
autoclose.start();
return ssu.deviceMode();
Sep 4, 2013
Sep 4, 2013
144
145
}
Oct 10, 2016
Oct 10, 2016
146
147
148
void Ssud::setDeviceMode(int mode)
{
setDeviceMode(mode, Ssu::Replace);
Aug 24, 2015
Aug 24, 2015
149
150
}
Oct 10, 2016
Oct 10, 2016
151
152
153
154
155
void Ssud::setDeviceMode(int mode, int editMode)
{
ssu.setDeviceMode(
Ssu::DeviceModeFlags(mode),
Ssu::EditMode(editMode)
Aug 24, 2015
Aug 24, 2015
156
);
Sep 4, 2013
Sep 4, 2013
157
Oct 10, 2016
Oct 10, 2016
158
159
160
SsuRepoManager repoManager;
repoManager.update();
autoclose.start();
Sep 4, 2013
Sep 4, 2013
161
162
}
Oct 10, 2016
Oct 10, 2016
163
164
165
166
QString Ssud::flavour()
{
autoclose.start();
return ssu.flavour();
Sep 4, 2013
Sep 4, 2013
167
168
}
Oct 10, 2016
Oct 10, 2016
169
170
171
void Ssud::setFlavour(const QString &flavour)
{
ssu.setFlavour(flavour);
Sep 4, 2013
Sep 4, 2013
172
Oct 10, 2016
Oct 10, 2016
173
174
175
SsuRepoManager repoManager;
repoManager.update();
autoclose.start();
Sep 4, 2013
Sep 4, 2013
176
177
178
}
Oct 10, 2016
Oct 10, 2016
179
180
181
182
QString Ssud::release(bool rnd)
{
autoclose.start();
return ssu.release(rnd);
Sep 4, 2013
Sep 4, 2013
183
184
}
Oct 10, 2016
Oct 10, 2016
185
186
187
void Ssud::setRelease(const QString &release, bool rnd)
{
ssu.setRelease(release, rnd);
Sep 4, 2013
Sep 4, 2013
188
Oct 10, 2016
Oct 10, 2016
189
190
191
SsuRepoManager repoManager;
repoManager.update();
autoclose.start();
Sep 4, 2013
Sep 4, 2013
192
193
}
Oct 10, 2016
Oct 10, 2016
194
195
196
void Ssud::modifyRepo(int action, const QString &repo)
{
SsuRepoManager repoManager;
Sep 4, 2013
Sep 4, 2013
197
Oct 10, 2016
Oct 10, 2016
198
autoclose.stop();
Oct 24, 2013
Oct 24, 2013
199
Oct 10, 2016
Oct 10, 2016
200
switch (action) {
Sep 4, 2013
Sep 4, 2013
201
case Add:
Oct 10, 2016
Oct 10, 2016
202
203
repoManager.add(repo);
break;
Sep 4, 2013
Sep 4, 2013
204
case Remove:
Oct 10, 2016
Oct 10, 2016
205
206
repoManager.remove(repo);
break;
Sep 4, 2013
Sep 4, 2013
207
case Disable:
Oct 10, 2016
Oct 10, 2016
208
209
repoManager.disable(repo);
break;
Sep 4, 2013
Sep 4, 2013
210
case Enable:
Oct 10, 2016
Oct 10, 2016
211
212
213
repoManager.enable(repo);
break;
}
Sep 4, 2013
Sep 4, 2013
214
Oct 10, 2016
Oct 10, 2016
215
216
repoManager.update();
autoclose.start();
Sep 4, 2013
Sep 4, 2013
217
218
}
Oct 10, 2016
Oct 10, 2016
219
220
221
222
223
224
void Ssud::addRepo(const QString &repo, const QString &url)
{
SsuRepoManager repoManager;
repoManager.add(repo, url);
repoManager.update();
autoclose.start();
Sep 4, 2013
Sep 4, 2013
225
226
}
Oct 10, 2016
Oct 10, 2016
227
228
229
230
231
232
void Ssud::updateRepos()
{
SsuRepoManager repoManager;
autoclose.stop();
repoManager.update();
autoclose.start();
Sep 4, 2013
Sep 4, 2013
233
}