/
ssucoreconfig.h
113 lines (101 loc) · 3.44 KB
/
ssucoreconfig.h
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
/**
* @file ssucoreconfig.h
* @copyright 2013 Jolla Ltd.
* @author Bernd Wachter <bwachter@lart.info>
* @date 2013
*/
#ifndef _SSUCORECONFIG_H
#define _SSUCORECONFIG_H
#include <QObject>
#include "ssusettings.h"
#include "ssu.h"
#ifndef SSU_CONFIGURATION
/// Path to the main SSU configuration file
#define SSU_CONFIGURATION "/etc/ssu/ssu.ini"
#endif
#ifndef SSU_DEFAULT_CONFIGURATION
/// Path to the main SSU configuration file
#define SSU_DEFAULT_CONFIGURATION "/usr/share/ssu/ssu-defaults.ini"
#endif
class SsuCoreConfig: public SsuSettings {
Q_OBJECT
public:
static SsuCoreConfig *instance();
/**
* 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);
/**
* Return the URL for which credentials scope is valid
*/
QString credentialsUrl(QString scope);
/**
* Get the current flavour when RnD repositories are used
* @return current flavour (usually something like testing, release, ..)
*/
Q_INVOKABLE QString flavour();
/**
* Get the current mode bits for the device
*/
Q_INVOKABLE int deviceMode();
/**
* Get the current domain used in registration
* Internally - in the domain is replaced by :, if you need
* to print the domain name set pretty to true
* @return domain, or "" if not set
*/
Q_INVOKABLE QString domain(bool pretty=false);
/**
* 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 the release version string for either a release, or a RnD snapshot
*/
Q_INVOKABLE QString release(bool rnd=false);
/**
* Set mode bits for the device
*/
Q_INVOKABLE void setDeviceMode(int mode, int editMode=Ssu::Replace);
/**
* 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);
/**
* Set the domain string (usually something like nemo, jolla, ..)
*/
Q_INVOKABLE void setDomain(QString domain);
/**
* 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:
SsuCoreConfig(): SsuSettings(SSU_CONFIGURATION, QSettings::IniFormat, SSU_DEFAULT_CONFIGURATION) {};
SsuCoreConfig(const SsuCoreConfig &); // hide copy constructor
static SsuCoreConfig *ssuCoreConfig;
};
#endif