From a1c0fbb4b04582e29af89fdfd78c08cecf87c366 Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Fri, 9 Sep 2005 20:51:22 +0000 Subject: [PATCH] added prefs_put and prefs_del commands --- src/common/config.py | 8 ++++++-- src/remote_control.py | 26 +++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/common/config.py b/src/common/config.py index ea6f1bac4..85ffe7d12 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -418,13 +418,17 @@ class Config: return 'you already have added %s before' % name opt[1][name] = copy.deepcopy(opt[0]) - def del_per(self, typename, name): # per_group_of_option + def del_per(self, typename, name, subname = None): # per_group_of_option if not self.__options_per_key.has_key(typename): # raise RuntimeError, 'option %s does not exist' % typename return opt = self.__options_per_key[typename] - del opt[1][name] + if item is None: + del opt[1][name] + # if subname is specified, delete the item in the group. + elif opt[1][name].has_key(subname): + del opt[1][name][subname] def set_per(self, optname, key, subname, value): # per_group_of_option if not self.__options_per_key.has_key(optname): diff --git a/src/remote_control.py b/src/remote_control.py index 6c71a9d4a..76ff93768 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -371,7 +371,7 @@ class SignalObject(DbusPrototype): key = "" if path is not None: for node in path: - key += node + "->" + key += node + "#" key += name prefs_dict[key] = unicode(value[1]) gajim.config.foreach(get_prefs) @@ -385,10 +385,30 @@ class SignalObject(DbusPrototype): return True def prefs_del(self, *args): - return ['Not implemented yet'] + [key] = self._get_real_arguments(args, 1) + if not key: + return False + key_path = key.split('#', 2) + if len(key_path) != 3: + return False + if key_path[2] == '*': + gajim.config.del_per(key_path[0], key_path[1]) + else: + gajim.config.del_per(key_path[0], key_path[1], key_path[2]) + return True def prefs_put(self, *args): - return ['Not implemented yet'] + [key] = self._get_real_arguments(args, 1) + if not key: + return False + key_path = key.split('#', 2) + if len(key_path) < 3: + subname, value = key.split('=', 1) + gajim.config.set(subname, value) + return True + subname, value = key_path[2].split('=', 1) + gajim.config.set_per(key_path[0], key_path[1], subname, value) + return True def _is_first(self): if self.first_show: