gajim-remote now support nicknames. Fixes #871
This commit is contained in:
parent
274d5270d1
commit
e261e0a7a0
1 changed files with 67 additions and 35 deletions
|
@ -240,6 +240,7 @@ class SignalObject(DbusPrototype):
|
||||||
send file, located at 'file_path' to 'jid', using account
|
send file, located at 'file_path' to 'jid', using account
|
||||||
(optional) 'account' '''
|
(optional) 'account' '''
|
||||||
file_path, jid, account = self._get_real_arguments(args, 3)
|
file_path, jid, account = self._get_real_arguments(args, 3)
|
||||||
|
jid = self._get_real_jid(jid, account)
|
||||||
connected_account, contact = self.get_account_and_contact(account, jid)
|
connected_account, contact = self.get_account_and_contact(account, jid)
|
||||||
|
|
||||||
if connected_account:
|
if connected_account:
|
||||||
|
@ -272,6 +273,7 @@ class SignalObject(DbusPrototype):
|
||||||
send chat 'message' to 'jid', using account (optional) 'account'.
|
send chat 'message' to 'jid', using account (optional) 'account'.
|
||||||
if keyID is specified, encrypt the message with the pgp key '''
|
if keyID is specified, encrypt the message with the pgp key '''
|
||||||
jid, message, keyID, account = self._get_real_arguments(args, 4)
|
jid, message, keyID, account = self._get_real_arguments(args, 4)
|
||||||
|
jid = self._get_real_jid(jid, account)
|
||||||
return self._send_message(jid, message, keyID, account)
|
return self._send_message(jid, message, keyID, account)
|
||||||
|
|
||||||
def send_single_message(self, *args):
|
def send_single_message(self, *args):
|
||||||
|
@ -279,6 +281,7 @@ class SignalObject(DbusPrototype):
|
||||||
send single 'message' to 'jid', using account (optional) 'account'.
|
send single 'message' to 'jid', using account (optional) 'account'.
|
||||||
if keyID is specified, encrypt the message with the pgp key '''
|
if keyID is specified, encrypt the message with the pgp key '''
|
||||||
jid, subject, message, keyID, account = self._get_real_arguments(args, 5)
|
jid, subject, message, keyID, account = self._get_real_arguments(args, 5)
|
||||||
|
jid = self._get_real_jid(jid, account)
|
||||||
return self._send_message(jid, message, keyID, account, type, subject)
|
return self._send_message(jid, message, keyID, account, type, subject)
|
||||||
|
|
||||||
def open_chat(self, *args):
|
def open_chat(self, *args):
|
||||||
|
@ -288,8 +291,7 @@ class SignalObject(DbusPrototype):
|
||||||
if not jid:
|
if not jid:
|
||||||
# FIXME: raise exception for missing argument (dbus0.35+)
|
# FIXME: raise exception for missing argument (dbus0.35+)
|
||||||
return None
|
return None
|
||||||
if jid.startswith('xmpp:'):
|
jid = self._get_real_jid(jid, account)
|
||||||
jid = jid[5:] # len('xmpp:') = 5
|
|
||||||
|
|
||||||
if account:
|
if account:
|
||||||
accounts = [account]
|
accounts = [account]
|
||||||
|
@ -362,6 +364,7 @@ class SignalObject(DbusPrototype):
|
||||||
if not jid:
|
if not jid:
|
||||||
# FIXME: raise exception for missing argument (0.3+)
|
# FIXME: raise exception for missing argument (0.3+)
|
||||||
return None
|
return None
|
||||||
|
jid = self._get_real_jid(jid, account)
|
||||||
|
|
||||||
cached_vcard = gajim.connections.values()[0].get_cached_vcard(jid)
|
cached_vcard = gajim.connections.values()[0].get_cached_vcard(jid)
|
||||||
if cached_vcard:
|
if cached_vcard:
|
||||||
|
@ -500,6 +503,7 @@ class SignalObject(DbusPrototype):
|
||||||
|
|
||||||
def remove_contact(self, *args):
|
def remove_contact(self, *args):
|
||||||
[jid, account] = self._get_real_arguments(args, 2)
|
[jid, account] = self._get_real_arguments(args, 2)
|
||||||
|
jid = self._get_real_jid(jid, account)
|
||||||
accounts = gajim.contacts.get_accounts()
|
accounts = gajim.contacts.get_accounts()
|
||||||
|
|
||||||
# if there is only one account in roster, take it as default
|
# if there is only one account in roster, take it as default
|
||||||
|
@ -536,6 +540,34 @@ class SignalObject(DbusPrototype):
|
||||||
args = args[:desired_length]
|
args = args[:desired_length]
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
def _get_real_jid(self, jid, account = None):
|
||||||
|
'''get the real jid from the given one: removes xmpp: or get jid from nick
|
||||||
|
if account is specified, search only in this account
|
||||||
|
'''
|
||||||
|
if account:
|
||||||
|
accounts = [account]
|
||||||
|
else:
|
||||||
|
accounts = gajim.connections.keys()
|
||||||
|
if jid.startswith('xmpp:'):
|
||||||
|
return jid[5:] # len('xmpp:') = 5
|
||||||
|
nick_in_roster = None # Is jid a nick ?
|
||||||
|
for account in accounts:
|
||||||
|
# Does jid exists in roster of one account ?
|
||||||
|
if gajim.contacts.get_contacts_from_jid(account, jid):
|
||||||
|
return jid
|
||||||
|
if not nick_in_roster:
|
||||||
|
# look in all contact if one has jid as nick
|
||||||
|
for jid_ in gajim.contacts.get_jid_list(account):
|
||||||
|
c = gajim.contacts.get_contacts_from_jid(account, jid_)
|
||||||
|
if c[0].name == jid:
|
||||||
|
nick_in_roster = jid_
|
||||||
|
break
|
||||||
|
if nick_in_roster:
|
||||||
|
# We have not found jid in roster, but we found is as a nick
|
||||||
|
return nick_in_roster
|
||||||
|
# We have not found it as jid nor as nick, probably a not in roster jid
|
||||||
|
return jid
|
||||||
|
|
||||||
def _contacts_as_dbus_structure(self, contacts):
|
def _contacts_as_dbus_structure(self, contacts):
|
||||||
''' get info from list of Contact objects and create dbus dict '''
|
''' get info from list of Contact objects and create dbus dict '''
|
||||||
if not contacts:
|
if not contacts:
|
||||||
|
|
Loading…
Add table
Reference in a new issue