guh - Developer documentation

GuhSettings Class

The settings class for guh. More...

Header: #include <GuhSettings>
Inherits:

Public Types

enum SettingsRole { SettingsRoleNone, SettingsRoleDevices, SettingsRoleRules, SettingsRolePlugins, SettingsRoleGlobal }

Public Functions

GuhSettings(const SettingsRole & role = SettingsRoleNone, QObject * parent = 0)
~GuhSettings()
QStringList allKeys() const
void beginGroup(const QString & prefix)
int beginReadArray(const QString & prefix)
void beginWriteArray(const QString & prefix)
QStringList childGroups() const
QStringList childKeys() const
void clear()
bool contains(const QString & key) const
void endArray()
void endGroup()
QString fileName() const
QString group() const
bool isWritable() const
void remove(const QString & key)
void setArrayIndex(int i)
void setValue(const QString & key, const QVariant & value)
SettingsRole settingsRole() const
QVariant value(const QString & key, const QVariant & defaultValue = QVariant()) const

Static Public Members

bool isRoot()
QString logPath()
QString settingsPath()
QString storagePath()
QString translationsPath()

Detailed Description

The settings class for guh.

Depending on how the guh server was started (which user started guhd), the setting have to be stored in different locations. This class represents a centralized mechanism to store settings of the system. The different settings are represented ba the SettingsRole and can be used everywhere in the project.

Member Type Documentation

enum GuhSettings::SettingsRole

Represents the role for the GuhSettings. Each role creates its own settings file.

ConstantValueDescription
GuhSettings::SettingsRoleNone0No role will be used. This sould not be used!
GuhSettings::SettingsRoleDevices1This role will create the devices.conf file and is used to store the configured Devices.
GuhSettings::SettingsRoleRules2This role will create the rules.conf file and is used to store the configured Rules.
GuhSettings::SettingsRolePlugins3This role will create the plugins.conf file and is used to store the Plugin configurations.
GuhSettings::SettingsRoleGlobal4This role will create the guhd.conf file and is used to store the global settings of the guh system. This settings file is read only.

Member Function Documentation

GuhSettings::GuhSettings(const SettingsRole & role = SettingsRoleNone, QObject * parent = 0)

Constructs a GuhSettings instance with the given role and parent.

GuhSettings::~GuhSettings()

Destructor of the GuhSettings.

QStringList GuhSettings::allKeys() const

Return a list of all settings keys.

void GuhSettings::beginGroup(const QString & prefix)

Begins a new group with the given prefix.

int GuhSettings::beginReadArray(const QString & prefix)

Adds prefix to the current group and starts reading from an array. Returns the size of the array.

void GuhSettings::beginWriteArray(const QString & prefix)

Adds prefix to the current group and starts writing an array of size size. If size is -1 (the default), it is automatically determined based on the indexes of the entries written.

QStringList GuhSettings::childGroups() const

Returns a list of all key top-level groups that contain keys that can be read using the GuhSettings object.

QStringList GuhSettings::childKeys() const

Returns a list of all top-level keys that can be read using the GuhSettings object.

void GuhSettings::clear()

Removes all entries in the primary location associated to this GuhSettings object.

bool GuhSettings::contains(const QString & key) const

Returns true if there exists a setting called key; returns false otherwise.

void GuhSettings::endArray()

End an array.

void GuhSettings::endGroup()

Resets the group to what it was before the corresponding beginGroup() call.

QString GuhSettings::fileName() const

Returns the path where settings written using this GuhSettings object are stored.

QString GuhSettings::group() const

Returns the current group.

[static] bool GuhSettings::isRoot()

Returns true if guhd is started as root.

bool GuhSettings::isWritable() const

Returns true if settings can be written using this GuhSettings object; returns false otherwise.

[static] QString GuhSettings::logPath()

Returns the path where the logging database will be stored.

See also guhserver::LogEngine.

void GuhSettings::remove(const QString & key)

Removes the setting key and any sub-settings of key.

void GuhSettings::setArrayIndex(int i)

Sets the current array index to i.

void GuhSettings::setValue(const QString & key, const QVariant & value)

Sets the value of setting key to value. If the key already exists, the previous value is overwritten.

See also value().

[static] QString GuhSettings::settingsPath()

Returns the path to the folder where the GuhSettings will be saved i.e. /etc/guh.

SettingsRole GuhSettings::settingsRole() const

Returns the SettingsRole of this GuhSettings.

[static] QString GuhSettings::storagePath()

Returns the default system sorage path i.e. /var/lib/guh.

[static] QString GuhSettings::translationsPath()

Returns the default system translation path /usr/share/guh/translations.

QVariant GuhSettings::value(const QString & key, const QVariant & defaultValue = QVariant()) const

Returns the value for setting key. If the setting doesn't exist, returns defaultValue.

See also setValue().