ssu
Loading...
Searching...
No Matches
ssu.h
Go to the documentation of this file.
1
8
9/*
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#ifndef _Ssu_H
26#define _Ssu_H
27
28#include <QDateTime>
29#include <QObject>
30#include <QDebug>
31
32class QNetworkAccessManager;
33class QNetworkReply;
34class QDomDocument;
35
36class Ssu: public QObject
37{
38 Q_OBJECT
39
40 friend class UrlResolverTest;
41
42 Q_PROPERTY(bool registered READ isRegistered NOTIFY registrationStatusChanged)
43 Q_PROPERTY(DeviceModeFlags deviceMode READ deviceMode CONSTANT)
44 Q_PROPERTY(QString domain READ domain CONSTANT)
45public:
50 UserFilter = 0x1,
52 NoFilter = 0x3,
54 Available = 0x8,
55 };
56
75
76 Q_DECLARE_FLAGS(DeviceModeFlags, DeviceMode)
77 Q_FLAGS(DeviceModeFlags)
78
79
87
91 enum EditMode {
92 Replace = 0x1,
93 Add = 0x2,
94 Remove = 0x4,
95 };
96
101 Success = 0,
102 ErrUpdateMode = -10,
103 };
104
105 Ssu();
110 QPair<QString, QString> credentials(const QString &scope);
120 QString credentialsScope(const QString &repoName, bool rndRepo = false);
124 QString credentialsUrl(const QString &scope);
130 Q_INVOKABLE bool error();
136 Q_INVOKABLE QString lastError();
141 QString repoUrl(const QString &repoName, bool rndRepo = false,
142 QHash<QString, QString> repoParameters = QHash<QString, QString>(),
143 QHash<QString, QString> parametersOverride = QHash<QString, QString>());
150 Q_INVOKABLE void unregister();
151
152 // wrappers around SsuCoreConfig
153 // not all of those belong into SsuCoreConfig, but will go there
154 // in the first phase of refactoring
155
157 Q_INVOKABLE QString flavour();
159 Q_INVOKABLE DeviceModeFlags deviceMode();
161 Q_INVOKABLE QString domain();
163 Q_INVOKABLE QString brand();
165 Q_INVOKABLE bool isRegistered();
167 Q_INVOKABLE QDateTime lastCredentialsUpdate();
169 Q_INVOKABLE QString release(bool rnd = false);
171 Q_INVOKABLE void setDeviceMode(DeviceModeFlags mode, enum EditMode editMode = Replace);
173 Q_INVOKABLE void setFlavour(const QString &flavour);
175 Q_INVOKABLE void setRelease(const QString &release, bool rnd = false);
177 Q_INVOKABLE void setDomain(const QString &domain);
179 Q_INVOKABLE bool useSslVerify();
180
181 Q_INVOKABLE QStringList listDomains();
182 Q_INVOKABLE void setDomainConfig(const QString &domain, QVariantMap config);
183 Q_INVOKABLE QVariantMap getDomainConfig(const QString &domain);
184private:
185 QString errorString;
186 bool errorFlag;
187 QNetworkAccessManager *manager;
188 int pendingRequests;
189 bool registerDevice(QDomDocument *response);
190 bool setCredentials(QDomDocument *response);
191 bool verifyResponse(QDomDocument *response);
192 void storeAuthorizedKeys(const QByteArray &data);
193
194private slots:
195 void requestFinished(QNetworkReply *reply);
200 void setError(const QString &errorMessage);
201
202public slots:
212 void sendRegistration(const QString &username, const QString &password);
224 void updateCredentials(bool force = false);
229
230signals:
234 void done();
239 void credentialsChanged();
240};
241
242Q_DECLARE_OPERATORS_FOR_FLAGS(Ssu::DeviceModeFlags)
243
244#endif
Definition ssu.h:37
Q_INVOKABLE QDateTime lastCredentialsUpdate()
See SsuCoreConfig::lastCredentialsUpdate.
Definition ssu.cpp:185
QString repoUrl(const QString &repoName, bool rndRepo=false, QHash< QString, QString > repoParameters=QHash< QString, QString >(), QHash< QString, QString > parametersOverride=QHash< QString, QString >())
Definition ssu.cpp:312
void sendRegistration(const QString &username, const QString &password)
Definition ssu.cpp:409
void registrationStatusChanged()
DeviceMode
Definition ssu.h:67
@ DisableRepoManager
Disable automagic repository management.
Definition ssu.h:68
@ ReleaseMode
Enable Release mode.
Definition ssu.h:70
@ RndMode
Enable RnD mode for device.
Definition ssu.h:69
@ UpdateMode
Do repo isolation and similar bits important for updating devices.
Definition ssu.h:72
@ AppInstallMode
Do repo isolation, but keep store repository enabled.
Definition ssu.h:73
@ LenientMode
Disable strict mode (i.e., keep unmanaged repositories).
Definition ssu.h:71
EditMode
Definition ssu.h:91
@ Replace
Replace the old value with the new one.
Definition ssu.h:92
@ Add
Make sure the given value is set in the bitmask.
Definition ssu.h:93
@ Remove
Make sure the given value is not set in the bitmask.
Definition ssu.h:94
Q_INVOKABLE QString flavour()
See SsuCoreConfig::flavour.
Definition ssu.cpp:156
Q_INVOKABLE void setRelease(const QString &release, bool rnd=false)
See SsuCoreConfig::setRelease.
Definition ssu.cpp:209
QPair< QString, QString > credentials(const QString &scope)
Definition ssu.cpp:95
void done()
Q_INVOKABLE QString domain()
See SsuCoreConfig::domain; returns printable version.
DisplayType
Definition ssu.h:82
@ DeviceModel
Marketed device name, like Pogoblaster 3000. Board mappings key "prettyModel".
Definition ssu.h:84
@ DeviceDesignation
Type designation, like NCC-1701. Beard mappings key "deviceDesignation".
Definition ssu.h:85
@ DeviceManufacturer
Manufacturer, like ACME Corp. Board mappings key "deviceManufacturer".
Definition ssu.h:83
QString credentialsUrl(const QString &scope)
Definition ssu.cpp:144
void updateStoreCredentials()
Definition ssu.cpp:707
Q_INVOKABLE bool useSslVerify()
See SsuCoreConfig::useSslVerify.
Definition ssu.cpp:221
RepoFilter
Definition ssu.h:49
@ UserFilter
Only user configured repositories.
Definition ssu.h:50
@ NoFilter
All repositories (global | user).
Definition ssu.h:52
@ UserBlacklist
User blacklist applied.
Definition ssu.h:53
@ BoardFilter
Only global repositories.
Definition ssu.h:51
@ Available
Include all defined repos, including disabled.
Definition ssu.h:54
Q_INVOKABLE QString release(bool rnd=false)
See SsuCoreConfig::release.
Definition ssu.cpp:191
Q_INVOKABLE bool error()
Definition ssu.cpp:150
Q_INVOKABLE bool isRegistered()
See SsuCoreConfig::isRegistered.
Definition ssu.cpp:179
QString credentialsScope(const QString &repoName, bool rndRepo=false)
Definition ssu.cpp:101
Q_INVOKABLE void unregister()
Definition ssu.cpp:735
Q_INVOKABLE void setFlavour(const QString &flavour)
See SsuCoreConfig::setFlavour.
Definition ssu.cpp:203
void updateCredentials(bool force=false)
Definition ssu.cpp:625
Q_INVOKABLE void setDomain(const QString &domain)
See SsuCoreConfig::setDomain.
Definition ssu.cpp:215
ReturnValue
Definition ssu.h:100
Q_INVOKABLE void setDeviceMode(DeviceModeFlags mode, enum EditMode editMode=Replace)
See SsuCoreConfig::setDeviceMode.
Definition ssu.cpp:197
Q_INVOKABLE QString brand()
See SsuCoreConfig::brand.
Definition ssu.cpp:174
Q_INVOKABLE QString lastError()
Definition ssu.cpp:231
Q_INVOKABLE DeviceModeFlags deviceMode()
See SsuCoreConfig::deviceMode.