added command account_info
This commit is contained in:
parent
d19ce874ee
commit
70191a1959
|
@ -142,6 +142,12 @@ class GajimRemote:
|
||||||
('jid', _('JID of the contact'), True)
|
('jid', _('JID of the contact'), True)
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
'account_info': [
|
||||||
|
_('Gets detailed info on a account'),
|
||||||
|
[
|
||||||
|
('account', _('Name of the account'), True)
|
||||||
|
]
|
||||||
|
],
|
||||||
'send_file': [
|
'send_file': [
|
||||||
_('Sends file to a contact'),
|
_('Sends file to a contact'),
|
||||||
[
|
[
|
||||||
|
@ -252,6 +258,9 @@ class GajimRemote:
|
||||||
if isinstance(res, list):
|
if isinstance(res, list):
|
||||||
for account in res:
|
for account in res:
|
||||||
print account
|
print account
|
||||||
|
elif self.command == 'account_info':
|
||||||
|
if res:
|
||||||
|
print self.print_info(0, self.unrepr(res)[0])
|
||||||
elif self.command == 'list_contacts':
|
elif self.command == 'list_contacts':
|
||||||
for single_res in res:
|
for single_res in res:
|
||||||
accounts = self.unrepr(single_res)
|
accounts = self.unrepr(single_res)
|
||||||
|
@ -382,10 +391,12 @@ class GajimRemote:
|
||||||
res = self.print_info(level+1, val)
|
res = self.print_info(level+1, val)
|
||||||
if res != '':
|
if res != '':
|
||||||
ret_str += '%s%s: \n%s' % (spacing, key, res)
|
ret_str += '%s%s: \n%s' % (spacing, key, res)
|
||||||
if isinstance(ret_str, unicode):
|
|
||||||
return ret_str.encode(locale.getpreferredencoding())
|
# utf-8 string come from gajim
|
||||||
else:
|
# FIXME: why we have strings instead of unicode?
|
||||||
return ret_str
|
if isinstance(ret_str, str):
|
||||||
|
ret_str = ret_str.decode('utf-8')
|
||||||
|
return ret_str.encode(locale.getpreferredencoding())
|
||||||
|
|
||||||
def unrepr(self, serialized_data):
|
def unrepr(self, serialized_data):
|
||||||
''' works the same as eval, but only for structural values,
|
''' works the same as eval, but only for structural values,
|
||||||
|
|
|
@ -95,6 +95,7 @@ class SignalObject(DbusPrototype):
|
||||||
self.show_next_unread,
|
self.show_next_unread,
|
||||||
self.list_contacts,
|
self.list_contacts,
|
||||||
self.list_accounts,
|
self.list_accounts,
|
||||||
|
self.account_info,
|
||||||
self.change_status,
|
self.change_status,
|
||||||
self.open_chat,
|
self.open_chat,
|
||||||
self.send_message,
|
self.send_message,
|
||||||
|
@ -310,10 +311,29 @@ class SignalObject(DbusPrototype):
|
||||||
if result and len(result) > 0:
|
if result and len(result) > 0:
|
||||||
result_array = []
|
result_array = []
|
||||||
for account in result:
|
for account in result:
|
||||||
result_array.append(account.encode('utf-8'))
|
result_array.append(account)
|
||||||
return result_array
|
return result_array
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def account_info(self, *args):
|
||||||
|
''' show info on account: resource, jid, nick, prio, message '''
|
||||||
|
[for_account] = self._get_real_arguments(args, 1)
|
||||||
|
if not gajim.connections.has_key(for_account):
|
||||||
|
# account is invalid
|
||||||
|
return None
|
||||||
|
account = gajim.connections[for_account]
|
||||||
|
result = {}
|
||||||
|
index = account.connected
|
||||||
|
result['status'] = STATUS_LIST[index]
|
||||||
|
result['name'] = account.name
|
||||||
|
result['jid'] = gajim.get_jid_from_account(account.name)
|
||||||
|
result['message'] = account.status
|
||||||
|
result['priority'] = unicode(gajim.config.get_per('accounts',
|
||||||
|
account.name, 'priority'))
|
||||||
|
result['resource'] = unicode(gajim.config.get_per('accounts',
|
||||||
|
account.name, 'resource'))
|
||||||
|
return repr(result)
|
||||||
|
|
||||||
def list_contacts(self, *args):
|
def list_contacts(self, *args):
|
||||||
''' list all contacts in the roster. If the first argument is specified,
|
''' list all contacts in the roster. If the first argument is specified,
|
||||||
then return the contacts for the specified account '''
|
then return the contacts for the specified account '''
|
||||||
|
@ -499,3 +519,4 @@ class SignalObject(DbusPrototype):
|
||||||
add_contact = method(INTERFACE)(add_contact)
|
add_contact = method(INTERFACE)(add_contact)
|
||||||
get_status = method(INTERFACE)(get_status)
|
get_status = method(INTERFACE)(get_status)
|
||||||
get_status_message = method(INTERFACE)(get_status_message)
|
get_status_message = method(INTERFACE)(get_status_message)
|
||||||
|
account_info = method(INTERFACE)(account_info)
|
||||||
|
|
Loading…
Reference in New Issue