added prefs_list and prefs_store commands
(prefs_del, prefs_put are not implemented yet)
This commit is contained in:
parent
5aec18639d
commit
37780f6b72
|
@ -150,6 +150,29 @@ sent using this account'), False),
|
||||||
(_('account'), _('if specified, file will be sent \
|
(_('account'), _('if specified, file will be sent \
|
||||||
using this account'), False)
|
using this account'), False)
|
||||||
]
|
]
|
||||||
|
],
|
||||||
|
'prefs_list': [
|
||||||
|
_('List all preferences and their values'),
|
||||||
|
[ ]
|
||||||
|
],
|
||||||
|
'prefs_put': [
|
||||||
|
_('Set value of \'key\' to \'value\'. If there is no such key, \
|
||||||
|
new item in the preferences is inserted.'),
|
||||||
|
[
|
||||||
|
(_('key=value'), _('\'key\' is the name of the preference, \
|
||||||
|
\'value\' is the value to set it to'), True)
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'prefs_del': [
|
||||||
|
_('Delete a preference item'),
|
||||||
|
[
|
||||||
|
(_('key'), _('name of the preference to be deleted'), True)
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'prefs_store': [
|
||||||
|
_('Write the current state of Gajim preferences to the \
|
||||||
|
.config file'),
|
||||||
|
[ ]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
if self.argv_len < 2 or \
|
if self.argv_len < 2 or \
|
||||||
|
@ -204,6 +227,12 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
accounts = self.unrepr(single_res)
|
accounts = self.unrepr(single_res)
|
||||||
for account_dict in accounts:
|
for account_dict in accounts:
|
||||||
print self.print_info(0, account_dict)
|
print self.print_info(0, account_dict)
|
||||||
|
elif self.command == 'prefs_list':
|
||||||
|
prefs_dict = self.unrepr(res)
|
||||||
|
pref_keys = prefs_dict[0].keys()
|
||||||
|
pref_keys.sort()
|
||||||
|
for pref_key in pref_keys:
|
||||||
|
print pref_key, '=', prefs_dict[0 ][pref_key]
|
||||||
elif res:
|
elif res:
|
||||||
print res
|
print res
|
||||||
|
|
||||||
|
@ -251,16 +280,19 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
arguments_str = self.make_arguments_row(command_props[1])
|
arguments_str = self.make_arguments_row(command_props[1])
|
||||||
str = _('Usage: %s %s %s \n\t') % (BASENAME, command,
|
str = _('Usage: %s %s %s \n\t') % (BASENAME, command,
|
||||||
arguments_str)
|
arguments_str)
|
||||||
str += command_props[0] + '\n\n' + _('Arguments:') + '\n'
|
if len(command_props[1]) > 0:
|
||||||
for argument in command_props[1]:
|
str += command_props[0] + '\n\n' + _('Arguments:') + '\n'
|
||||||
str += ' ' + argument[0] + ' - ' + argument[1] + '\n'
|
for argument in command_props[1]:
|
||||||
|
str += ' ' + argument[0] + ' - ' + argument[1] + '\n'
|
||||||
return str
|
return str
|
||||||
send_error(_('%s not found') % command)
|
send_error(_('%s not found') % command)
|
||||||
|
|
||||||
def compose_help(self):
|
def compose_help(self):
|
||||||
''' print usage, and list available commands '''
|
''' print usage, and list available commands '''
|
||||||
str = _('Usage: %s command [arguments]\nCommand is one of:\n' ) % BASENAME
|
str = _('Usage: %s command [arguments]\nCommand is one of:\n' ) % BASENAME
|
||||||
for command in self.commands.keys():
|
commands = self.commands.keys()
|
||||||
|
commands.sort()
|
||||||
|
for command in commands:
|
||||||
str += ' ' + command
|
str += ' ' + command
|
||||||
for argument in self.commands[command][1]:
|
for argument in self.commands[command][1]:
|
||||||
str += ' '
|
str += ' '
|
||||||
|
@ -488,7 +520,7 @@ Type "%s help %s" for more info') % (args[argv_len][0], BASENAME, self.command))
|
||||||
res = self.method(sys.argv[2], sys.argv[3], sys.argv[4],
|
res = self.method(sys.argv[2], sys.argv[3], sys.argv[4],
|
||||||
sys.argv[5])
|
sys.argv[5])
|
||||||
return res
|
return res
|
||||||
except:
|
except Exception, e:
|
||||||
send_error(_('Service not available'))
|
send_error(_('Service not available'))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,11 @@ class SignalObject(DbusPrototype):
|
||||||
self.open_chat,
|
self.open_chat,
|
||||||
self.send_message,
|
self.send_message,
|
||||||
self.contact_info,
|
self.contact_info,
|
||||||
self.send_file
|
self.send_file,
|
||||||
|
self.prefs_list,
|
||||||
|
self.prefs_store,
|
||||||
|
self.prefs_del,
|
||||||
|
self.prefs_put,
|
||||||
])
|
])
|
||||||
|
|
||||||
def raise_signal(self, signal, arg):
|
def raise_signal(self, signal, arg):
|
||||||
|
@ -359,6 +363,33 @@ class SignalObject(DbusPrototype):
|
||||||
else:
|
else:
|
||||||
win.window.focus(long(time()))
|
win.window.focus(long(time()))
|
||||||
|
|
||||||
|
def prefs_list(self, *args):
|
||||||
|
prefs_dict = {}
|
||||||
|
def get_prefs(data, name, path, value):
|
||||||
|
if value is None:
|
||||||
|
return
|
||||||
|
key = ""
|
||||||
|
if path is not None:
|
||||||
|
for node in path:
|
||||||
|
key += node + "->"
|
||||||
|
key += name
|
||||||
|
prefs_dict[key] = unicode(value[1])
|
||||||
|
gajim.config.foreach(get_prefs)
|
||||||
|
return repr(prefs_dict)
|
||||||
|
|
||||||
|
def prefs_store(self, *args):
|
||||||
|
try:
|
||||||
|
self.plugin.save_config()
|
||||||
|
except Exception, e:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def prefs_del(self, *args):
|
||||||
|
return ['Not implemented yet']
|
||||||
|
|
||||||
|
def prefs_put(self, *args):
|
||||||
|
return ['Not implemented yet']
|
||||||
|
|
||||||
def _is_first(self):
|
def _is_first(self):
|
||||||
if self.first_show:
|
if self.first_show:
|
||||||
self.first_show = False
|
self.first_show = False
|
||||||
|
@ -424,6 +455,10 @@ class SignalObject(DbusPrototype):
|
||||||
send_message = method(INTERFACE)(send_message)
|
send_message = method(INTERFACE)(send_message)
|
||||||
send_file = method(INTERFACE)(send_file)
|
send_file = method(INTERFACE)(send_file)
|
||||||
VcardInfo = signal(INTERFACE)(VcardInfo)
|
VcardInfo = signal(INTERFACE)(VcardInfo)
|
||||||
|
prefs_list = method(INTERFACE)(prefs_list)
|
||||||
|
prefs_put = method(INTERFACE)(prefs_put)
|
||||||
|
prefs_del = method(INTERFACE)(prefs_del)
|
||||||
|
prefs_store = method(INTERFACE)(prefs_store)
|
||||||
|
|
||||||
class SessionBusNotPresent(Exception):
|
class SessionBusNotPresent(Exception):
|
||||||
''' This exception indicates that there is no session daemon '''
|
''' This exception indicates that there is no session daemon '''
|
||||||
|
|
Loading…
Reference in New Issue