Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[deviceinfo] Add model and manufacturer related properties. JB#42860
Allows lightweight access to model and manufacturer related information
without doing D-Bus IPC potentially requiring starting of SSU daemon.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Oct 31, 2018
1 parent 2b8b1c6 commit 26f2048
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/deviceinfo.cpp
Expand Up @@ -43,6 +43,11 @@ class DeviceInfoPrivate

QSet<DeviceInfo::Feature> m_features;
QSet<Qt::Key> m_keys;
QString m_model;
QString m_baseModel;
QString m_designation;
QString m_manufacturer;
QString m_prettyName;
};

DeviceInfoPrivate::DeviceInfoPrivate()
Expand All @@ -65,6 +70,13 @@ DeviceInfoPrivate::DeviceInfoPrivate()
free(keys);
}

/* Note: These queries always return non-null C string */
m_model = ssusysinfo_device_model(si);
m_baseModel = ssusysinfo_device_base_model(si);
m_designation = ssusysinfo_device_designation(si);
m_manufacturer = ssusysinfo_device_manufacturer(si);
m_prettyName = ssusysinfo_device_pretty_name(si);

ssusysinfo_delete(si);
}

Expand Down Expand Up @@ -95,3 +107,33 @@ bool DeviceInfo::hasHardwareKey(Qt::Key key) const
Q_D(const DeviceInfo);
return d->m_keys.contains(key);
}

QString DeviceInfo::model() const
{
Q_D(const DeviceInfo);
return d->m_model;
}

QString DeviceInfo::baseModel() const
{
Q_D(const DeviceInfo);
return d->m_baseModel;
}

QString DeviceInfo::designation() const
{
Q_D(const DeviceInfo);
return d->m_designation;
}

QString DeviceInfo::manufacturer() const
{
Q_D(const DeviceInfo);
return d->m_manufacturer;
}

QString DeviceInfo::prettyName() const
{
Q_D(const DeviceInfo);
return d->m_prettyName;
}
11 changes: 11 additions & 0 deletions src/deviceinfo.h
Expand Up @@ -43,6 +43,11 @@ class DeviceInfoPrivate;
class SYSTEMSETTINGS_EXPORT DeviceInfo: public QObject
{
Q_OBJECT
Q_PROPERTY(QString model READ model CONSTANT)
Q_PROPERTY(QString baseModel READ baseModel CONSTANT)
Q_PROPERTY(QString designation READ designation CONSTANT)
Q_PROPERTY(QString manufacturer READ manufacturer CONSTANT)
Q_PROPERTY(QString prettyName READ prettyName CONSTANT)

public:
enum Feature {
Expand Down Expand Up @@ -100,6 +105,12 @@ class SYSTEMSETTINGS_EXPORT DeviceInfo: public QObject
Q_INVOKABLE bool hasFeature(DeviceInfo::Feature feature) const;
Q_INVOKABLE bool hasHardwareKey(Qt::Key key) const;

QString model() const;
QString baseModel() const;
QString designation() const;
QString manufacturer() const;
QString prettyName() const;

private:

DeviceInfoPrivate *d_ptr;
Expand Down

0 comments on commit 26f2048

Please sign in to comment.