Skip to content

Latest commit

 

History

History
172 lines (160 loc) · 5.8 KB

ssu.h

File metadata and controls

172 lines (160 loc) · 5.8 KB
 
Oct 8, 2012
Oct 8, 2012
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
/**
* @file ssu.h
* @copyright 2012 Jolla Ltd.
* @author Bernd Wachter <bernd.wachter@jollamobile.com>
* @date 2012
*/
#ifndef _Ssu_H
#define _Ssu_H
#include <QObject>
#include <QSettings>
#include <QDebug>
#include <QtNetwork>
#include <QtXml/QDomDocument>
class Ssu: public QObject {
Q_OBJECT
public:
Ssu();
/**
* Find a username/password pair for the given scope
* @return a QPair with username and password, or an empty QPair if scope is invalid
*/
QPair<QString, QString> credentials(QString scope);
/**
* Get the scope for a repository, taking into account different scopes for
* release and RnD repositories
*
* Please note that variable scope is not yet implemented -- one default scope is
* read from the configuration file.
*
* @return a string containing the scope; it can be used to look up login credentials using credentials()
*/
QString credentialsScope(QString repoName, bool rndRepo=false);
Oct 24, 2012
Oct 24, 2012
39
40
41
42
/**
* Return the URL for which credentials scope is valid
*/
QString credentialsUrl(QString scope);
Oct 8, 2012
Oct 8, 2012
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
/**
* Try to find the device family for the system this is running on
*/
Q_INVOKABLE QString deviceFamily();
/**
* Try to find out ond what kind of system this is running
*/
Q_INVOKABLE QString deviceModel();
/**
* Calculate the device ID used in SSU requests
* @return QSystemDeviceInfo::imei(), if available, or QSystemDeviceInfo::uniqueDeviceID()
*/
Q_INVOKABLE QString deviceUid();
/**
* Returns if the last operation was successful
* @retval true last operation was successful
* @retval false last operation failed, you should check lastError() for details
*/
Q_INVOKABLE bool error();
/**
* Get the current flavour when RnD repositories are used
* @return current flavour (usually something like testing, release, ..)
*/
Q_INVOKABLE QString flavour();
/**
* Return devices RND registration status
* @retval true device is registered
* @retval false device is not registered
*/
Q_INVOKABLE bool isRegistered();
/**
* Return the date/time when the credentials to access internal
* SSU servers were updated the last time
*/
Q_INVOKABLE QDateTime lastCredentialsUpdate();
/**
* Return an error message for the last error encountered. The message
* will not be cleared, check error() to see if the last operation was
* successful.
*/
Q_INVOKABLE QString lastError();
/**
* Return the release version string for either a release, or a RnD snapshot
*/
Q_INVOKABLE QString release(bool rnd=false);
/**
* Resolve a repository url
* @return the repository URL on success, an empty string on error
*/
QString repoUrl(QString repoName, bool rndRepo=false, QHash<QString, QString> repoParameters=QHash<QString, QString>());
/**
* Set the flavour used when resolving RND repositories
*/
Q_INVOKABLE void setFlavour(QString flavour);
/**
* Set the release version string for either a release, or a RnD snapshot
*/
Q_INVOKABLE void setRelease(QString release, bool rnd=false);
/**
* Unregister a device. This will clean all registration data from a device,
* though will not touch the information on SSU server; the information there
* has to be manually cleaned for a device we don't own anymore, but will be
* overwritten next time the device gets registered
*/
Q_INVOKABLE void unregister();
/**
* Return configuration settings regarding ssl verification
* @retval true SSL verification must be used; that's the default if not configured
* @retval false SSL verification should be disabled
*/
Q_INVOKABLE bool useSslVerify();
private:
QString errorString;
Nov 4, 2012
Nov 4, 2012
117
QString cachedModel, cachedFamily;
Oct 8, 2012
Oct 8, 2012
118
119
bool errorFlag;
QNetworkAccessManager *manager;
Nov 4, 2012
Nov 4, 2012
120
int pendingRequests;
Nov 4, 2012
Nov 4, 2012
121
QSettings *settings, *repoSettings, *boardMappings;
Oct 8, 2012
Oct 8, 2012
122
123
124
bool registerDevice(QDomDocument *response);
bool setCredentials(QDomDocument *response);
bool verifyResponse(QDomDocument *response);
Nov 4, 2012
Nov 4, 2012
125
void storeAuthorizedKeys(QByteArray data);
Oct 8, 2012
Oct 8, 2012
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
private slots:
void requestFinished(QNetworkReply *reply);
/**
* Set errorString returned by lastError to errorMessage, set
* errorFlag returned by error() to true, and emit done()
*/
void setError(QString errorMessage);
public slots:
/**
* Attempt RND device registration, using @a username and @a password supplied
* @param username Jolla username
* @param password Jolla password
*
* When the operation has finished the done() signal will be sent. You can call
* error() to check if an error occured, and use lastError() to retrieve the last
* error message.
*/
void sendRegistration(QString username, QString password);
/**
* Try to update the RND repository credentials. The device needs to be registered
* for this to work. updateCredentials remembers the time of the last credentials
* update, and skips updating if only little time has elapsed since the last update.
* An update may be forced by setting @a force to true
* @param force force credentials updating
*
* When the operation has finished the done() signal will be sent. You can call
* error() to check if an error occured, and use lastError() to retrieve the last
* error message.
*/
void updateCredentials(bool force=false);
signals:
/**
* Emitted after an asynchronous operation finished
*/
void done();
// we don't get notifications from settings -> this won't work over different instances (yet)
void flavourChanged();
void releaseChanged();
void registrationStatusChanged();
void credentialsChanged();
};
#endif