Skip to content

Commit

Permalink
Added support for cmd-remove in ssu-defaults.init
Browse files Browse the repository at this point in the history
Signed-off-by: Pekka Lundstrom <pekka.lundstrom@jollamobile.com>
  • Loading branch information
Pekka Lundstrom committed Jan 16, 2013
1 parent 8499335 commit e7832a7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libssu/ssu.cpp
Expand Up @@ -54,7 +54,17 @@ Ssu::Ssu(): QObject(){
defaultKeys = defaultSettings.allKeys();
defaultSettings.endGroup();
foreach (const QString &key, defaultKeys){
if (!settings->contains(key)){
// Default keys support both commands and new keys
if (key.compare("cmd-remove", Qt::CaseSensitive) == 0){
// Remove keys listed in value as string list
QStringList oldKeys = defaultSettings.value(currentSection + key).toStringList();
foreach (const QString &oldKey, oldKeys){
if (settings->contains(oldKey)){
settings->remove(oldKey);
qDebug() << "Removing old key:" << oldKey;
}
}
} else if (!settings->contains(key)){
// Add new keys..
settings->setValue(key, defaultSettings.value(currentSection + key));
qDebug() << "Adding new key: " << key;
Expand Down
9 changes: 9 additions & 0 deletions ssu-defaults.ini
@@ -1,3 +1,12 @@
# ssu configuration is located in /etc/ssu/ssu.ini
# When ssu is initialized configVersion number in that file is compared
# to configVersion in this file (/usr/share/ssu/ssu-defaults.ini).
# If this file has bigger version then upgrade takes place.
# Starting from next bigger version block new key/value pairs are read and added to
# the config (/etc/ssu/ssu.ini) assuming config doesn't have that key already.
# Old keys can be removed from the config with special key called "cmd-remove"
# Syntax cmd-remove=<old-key1>, <old-key2>, ...

[General]
configVersion=2

Expand Down

0 comments on commit e7832a7

Please sign in to comment.