Inject account object instead of account string into contact instances.
Each contact has now access to the account object instead of the account string.
This commit is contained in:
parent
ae9376ff63
commit
8203211e74
|
@ -25,4 +25,8 @@ class Account(object):
|
||||||
self.contacts = contacts
|
self.contacts = contacts
|
||||||
self.gc_contacts = gc_contacts
|
self.gc_contacts = gc_contacts
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return self.name.__hash__()
|
|
@ -229,7 +229,7 @@ class Contacts:
|
||||||
sub='', ask='', resource='', priority=0, keyID='', client_caps=None,
|
sub='', ask='', resource='', priority=0, keyID='', client_caps=None,
|
||||||
our_chatstate=None, chatstate=None, last_status_time=None,
|
our_chatstate=None, chatstate=None, last_status_time=None,
|
||||||
composing_xep=None, mood={}, tune={}, activity={}):
|
composing_xep=None, mood={}, tune={}, activity={}):
|
||||||
|
account = self._accounts.get(account, account) # Use Account object if available
|
||||||
return Contact(jid=jid, account=account, name=name, groups=groups,
|
return Contact(jid=jid, account=account, name=name, groups=groups,
|
||||||
show=show, status=status, sub=sub, ask=ask, resource=resource, priority=priority,
|
show=show, status=status, sub=sub, ask=ask, resource=resource, priority=priority,
|
||||||
keyID=keyID, client_caps=client_caps, our_chatstate=our_chatstate,
|
keyID=keyID, client_caps=client_caps, our_chatstate=our_chatstate,
|
||||||
|
@ -239,6 +239,7 @@ class Contacts:
|
||||||
def create_self_contact(self, jid, account, resource, show, status, priority, keyID=''):
|
def create_self_contact(self, jid, account, resource, show, status, priority, keyID=''):
|
||||||
conn = common.gajim.connections[account]
|
conn = common.gajim.connections[account]
|
||||||
nick = common.gajim.nicks[account]
|
nick = common.gajim.nicks[account]
|
||||||
|
account = self._accounts.get(account, account) # Use Account object if available
|
||||||
return self.create_contact(jid=jid, account=account,
|
return self.create_contact(jid=jid, account=account,
|
||||||
name=nick, groups=['self_contact'], show=show, status=status,
|
name=nick, groups=['self_contact'], show=show, status=status,
|
||||||
sub='both', ask='none', priority=priority, keyID=keyID,
|
sub='both', ask='none', priority=priority, keyID=keyID,
|
||||||
|
@ -246,6 +247,7 @@ class Contacts:
|
||||||
activity=conn.activity)
|
activity=conn.activity)
|
||||||
|
|
||||||
def create_not_in_roster_contact(self, jid, account, resource='', name='', keyID=''):
|
def create_not_in_roster_contact(self, jid, account, resource='', name='', keyID=''):
|
||||||
|
account = self._accounts.get(account, account) # Use Account object if available
|
||||||
return self.create_contact(jid=jid, account=account, resource=resource,
|
return self.create_contact(jid=jid, account=account, resource=resource,
|
||||||
name=name, groups=[_('Not in Roster')], show='not in roster',
|
name=name, groups=[_('Not in Roster')], show='not in roster',
|
||||||
status='', sub='none', keyID=keyID)
|
status='', sub='none', keyID=keyID)
|
||||||
|
@ -372,6 +374,7 @@ class Contacts:
|
||||||
|
|
||||||
def create_gc_contact(self, room_jid, account, name='', show='', status='',
|
def create_gc_contact(self, room_jid, account, name='', show='', status='',
|
||||||
role='', affiliation='', jid='', resource=''):
|
role='', affiliation='', jid='', resource=''):
|
||||||
|
account = self._accounts.get(account, account) # Use Account object if available
|
||||||
return GC_Contact(room_jid, account, name, show, status, role, affiliation, jid,
|
return GC_Contact(room_jid, account, name, show, status, role, affiliation, jid,
|
||||||
resource)
|
resource)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue