Remove different dicts for tune, activity and mood and from now on only use the common 'pep' dict.
The pep dict contacts the different UserPEP classes.
This commit is contained in:
parent
aa53988fd1
commit
a3ea00f4ea
|
@ -168,9 +168,6 @@ class Connection(ConnectionHandlers):
|
|||
self.pubsub_supported = False
|
||||
self.pubsub_publish_options_supported = False
|
||||
self.pep_supported = False
|
||||
self.mood = {}
|
||||
self.tune = {}
|
||||
self.activity = {}
|
||||
self.pep = {}
|
||||
# Do we continue connection when we get roster (send presence,get vcard..)
|
||||
self.continue_connect_info = None
|
||||
|
|
|
@ -94,7 +94,7 @@ class Contact(CommonContact):
|
|||
def __init__(self, jid, account, name='', groups=[], show='', status='', sub='',
|
||||
ask='', resource='', priority=0, keyID='', client_caps=None,
|
||||
our_chatstate=None, chatstate=None, last_status_time=None, msg_id = None,
|
||||
composing_xep=None, mood={}, tune={}, activity={}):
|
||||
composing_xep=None):
|
||||
|
||||
CommonContact.__init__(self, jid, account, resource, show, status, name,
|
||||
our_chatstate, composing_xep, chatstate, client_caps=client_caps)
|
||||
|
@ -111,9 +111,6 @@ class Contact(CommonContact):
|
|||
self.last_status_time = last_status_time
|
||||
|
||||
self.pep = {}
|
||||
self.mood = mood.copy()
|
||||
self.tune = tune.copy()
|
||||
self.activity = activity.copy()
|
||||
|
||||
def get_full_jid(self):
|
||||
if self.resource:
|
||||
|
@ -229,23 +226,25 @@ class Contacts:
|
|||
def create_contact(self, jid, account, name='', groups=[], show='', status='',
|
||||
sub='', ask='', resource='', priority=0, keyID='', client_caps=None,
|
||||
our_chatstate=None, chatstate=None, last_status_time=None,
|
||||
composing_xep=None, mood={}, tune={}, activity={}):
|
||||
composing_xep=None):
|
||||
account = self._accounts.get(account, account) # Use Account object if available
|
||||
return Contact(jid=jid, account=account, name=name, groups=groups,
|
||||
show=show, status=status, sub=sub, ask=ask, resource=resource, priority=priority,
|
||||
keyID=keyID, client_caps=client_caps, our_chatstate=our_chatstate,
|
||||
chatstate=chatstate, last_status_time=last_status_time,
|
||||
composing_xep=composing_xep, mood=mood, tune=tune, activity=activity)
|
||||
composing_xep=composing_xep)
|
||||
|
||||
def create_self_contact(self, jid, account, resource, show, status, priority, keyID=''):
|
||||
def create_self_contact(self, jid, account, resource, show, status, priority,
|
||||
name='', keyID=''):
|
||||
conn = common.gajim.connections[account]
|
||||
nick = common.gajim.nicks[account]
|
||||
nick = name or common.gajim.nicks[account]
|
||||
account = self._accounts.get(account, account) # Use Account object if available
|
||||
return self.create_contact(jid=jid, account=account,
|
||||
self_contact = self.create_contact(jid=jid, account=account,
|
||||
name=nick, groups=['self_contact'], show=show, status=status,
|
||||
sub='both', ask='none', priority=priority, keyID=keyID,
|
||||
resource=resource, mood=conn.mood, tune=conn.tune,
|
||||
activity=conn.activity)
|
||||
resource=resource)
|
||||
self_contact.pep = conn.pep
|
||||
return self_contact
|
||||
|
||||
def create_not_in_roster_contact(self, jid, account, resource='', name='', keyID=''):
|
||||
account = self._accounts.get(account, account) # Use Account object if available
|
||||
|
|
|
@ -237,24 +237,16 @@ class AbstractPEP(object):
|
|||
'''To be implemented by subclasses'''
|
||||
raise NotImplementedError
|
||||
|
||||
def _update_contacts(self, jid, account):
|
||||
dict = {} if self._retracted else self._pep_specific_data
|
||||
|
||||
for contact in common.gajim.contacts.get_contacts(account, jid):
|
||||
setattr(contact, self.type, dict)
|
||||
|
||||
def _update_contacts(self, jid, account):
|
||||
for contact in common.gajim.contacts.get_contacts(account, jid):
|
||||
if self._retracted:
|
||||
if self.type in contact.pep:
|
||||
del contact.pep[self.type]
|
||||
else:
|
||||
contact.pep[self.type] = self
|
||||
|
||||
def _update_account(self, account):
|
||||
dict = {} if self._retracted else self._pep_specific_data
|
||||
|
||||
acc = common.gajim.connections[account]
|
||||
setattr(acc, self.type, dict)
|
||||
|
||||
def _update_account(self, account):
|
||||
acc = common.gajim.connections[account]
|
||||
if self._retracted:
|
||||
if self.type in acc.pep:
|
||||
del acc.pep[self.type]
|
||||
|
@ -571,15 +563,10 @@ def delete_pep(jid, name):
|
|||
|
||||
if jid == common.gajim.get_jid_from_account(name):
|
||||
acc = common.gajim.connections[name]
|
||||
acc.activity = {}
|
||||
user_send_tune(name)
|
||||
acc.tune = {}
|
||||
acc.mood = {}
|
||||
acc.pep = {}
|
||||
|
||||
for contact in common.gajim.contacts.get_contacts(name, user):
|
||||
contact.activity = {}
|
||||
contact.tune = {}
|
||||
contact.mood = {}
|
||||
contact.pep = {}
|
||||
|
||||
if jid == common.gajim.get_jid_from_account(name):
|
||||
common.gajim.interface.roster.draw_account(name)
|
||||
|
|
|
@ -88,9 +88,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
|||
self.no_log_for = False
|
||||
|
||||
self.pep_supported = False
|
||||
self.mood = {}
|
||||
self.tune = {}
|
||||
self.activity = {}
|
||||
self.pep = {}
|
||||
# Do we continue connection when we get roster (send presence,get vcard...)
|
||||
self.continue_connect_info = None
|
||||
if gajim.HAVE_GPG:
|
||||
|
|
|
@ -2432,11 +2432,10 @@ class RosterWindow:
|
|||
account_name = account
|
||||
if gajim.account_is_connected(account):
|
||||
account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total))
|
||||
contact = gajim.contacts.create_contact(jid=jid, account=account, name=account_name,
|
||||
show=connection.get_status(), sub='', status=connection.status,
|
||||
resource=connection.server_resource,
|
||||
priority=connection.priority, mood=connection.mood,
|
||||
tune=connection.tune, activity=connection.activity)
|
||||
contact = gajim.contacts.create_self_contact(jid=jid, account=account,
|
||||
name=account_name, show=connection.get_status(),
|
||||
status=connection.status, resource=connection.server_resource,
|
||||
priority=connection.priority)
|
||||
if gajim.connections[account].gpg:
|
||||
contact.keyID = gajim.config.get_per('accounts', connection.name,
|
||||
'keyid')
|
||||
|
|
|
@ -14,9 +14,7 @@ class MockConnection(Mock, ConnectionHandlersBase):
|
|||
|
||||
self.name = account
|
||||
self.connected = 2
|
||||
self.mood = {}
|
||||
self.activity = {}
|
||||
self.tune = {}
|
||||
self.pep = {}
|
||||
self.blocked_contacts = {}
|
||||
self.blocked_groups = {}
|
||||
self.sessions = {}
|
||||
|
|
Loading…
Reference in New Issue