/
ssudeviceinfo.h
140 lines (116 loc) · 4.46 KB
/
ssudeviceinfo.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
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
/**
* @file ssudeviceinfo.h
* @copyright 2013 2013 Jolla Ltd.
* @author Bernd Wachter <bwachter@lart.info>
* @date 2013
*/
#ifndef _SSUDEVICEINFO_H
#define _SSUDEVICEINFO_H
#include <QObject>
#include "ssu.h"
class SsuSettings;
class SsuDeviceInfo: public QObject
{
Q_OBJECT
public:
/**
* Initialize with device to override autodetection
*/
SsuDeviceInfo(const QString &model = QString());
virtual ~SsuDeviceInfo();
/**
* Return the list of adaptations used for the set model
*/
QStringList adaptationRepos();
/**
* Resolve adaptation-specific variables for adaptationName, and store them in storageHash
* Returns "adaptation" if a valid adaptation was found, adaptationName otherwise
*/
QString adaptationVariables(const QString &adaptationName, QHash<QString, QString> *storageHash);
/**
* Check if a given model is available in the deviceinfo database, either directly,
* or as variant. If no model is provided as argument the autodetected or previously
* set model is used.
*
* @attention This function temporarily changes the detected model, and
* therefore should not be used in a multithreaded environment, unless you
* like funny results.
*/
bool contains(const QString &model = QString());
/**
* Try to find the device family for the system this is running on.
*/
Q_INVOKABLE QString deviceFamily();
/**
* Try to find the device variant for the system this is running on.
* If the device is not a variant it will return an empty string. If
* fallback is set to true it return the device model in this case.
*/
Q_INVOKABLE QString deviceVariant(bool fallback = false);
/**
* 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 The first imei from oFono ModemManager API, if available, or WLAN mac address, or device uid fallback code similar to QDeviceInfo::uniqueDeviceID()
*/
Q_INVOKABLE QString deviceUid();
/**
* Return the list of repositories explicitely disabled for this device
* This does not include repositories only disabled in the user configuration.
*/
QStringList disabledRepos();
/**
* Return a string suitable for display in dialogs, ...
*
* See Ssu::DeviceTypes for supported types.
*
* If not configured the model name used by ssu will be returned instead
* for product and type.
* If no manufacturer is found UNKNOWN is returned.
* For an invalid type an empty string is returned.
*/
Q_INVOKABLE QString displayName(int type);
/**
* Return the complete list of repositories configured for a device.
* Depending on the filter options, all repostories (user and board),
* only board-specific, or only user-specific are returned.
* Disabled repositories are excluded depending on filter settings.
*/
QStringList repos(bool rnd = false, int filter = Ssu::NoFilter);
/**
* Override device model autodetection
*/
Q_INVOKABLE void setDeviceModel(const QString &model = QString());
/**
* Return a variable from the given variable section. 'var'- is automatically
* prepended to the section name if not specified already. Recursive search
* through several variable sections (specified in the section) is supported,
* returned will be the first occurence of the variable.
*/
QVariant variable(const QString §ion, const QString &key);
/**
* Return the requested variable section. 'var-' is automatically
* prepended to the section name if not specified already.
*/
void variableSection(const QString §ion, QHash<QString, QString> *storageHash);
/**
* Return a value from an adaptation section. Returns an empty string
* or a given default value if key does not exist.
*
* If a device is marked as variant, and the requested key exists in a
* dedicated device section the key from the device section will get
* returned, otherwise the one from the variant.
*/
QVariant value(const QString &key, const QVariant &value = QVariant());
private:
SsuSettings *boardMappings;
QString cachedFamily, cachedModel, cachedVariant;
void clearCache();
/**
* Return a map of key, value pairs parsed from /etc/hw-release
*/
QMap<QString, QString> hwRelease();
};
#endif