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:
Stephan Erb 2009-11-15 23:52:43 +01:00
parent aa53988fd1
commit a3ea00f4ea
6 changed files with 22 additions and 44 deletions

View File

@ -168,9 +168,6 @@ class Connection(ConnectionHandlers):
self.pubsub_supported = False self.pubsub_supported = False
self.pubsub_publish_options_supported = False self.pubsub_publish_options_supported = False
self.pep_supported = False self.pep_supported = False
self.mood = {}
self.tune = {}
self.activity = {}
self.pep = {} self.pep = {}
# Do we continue connection when we get roster (send presence,get vcard..) # Do we continue connection when we get roster (send presence,get vcard..)
self.continue_connect_info = None self.continue_connect_info = None

View File

@ -94,7 +94,7 @@ class Contact(CommonContact):
def __init__(self, jid, account, name='', groups=[], show='', status='', sub='', def __init__(self, jid, account, name='', groups=[], show='', status='', sub='',
ask='', resource='', priority=0, keyID='', client_caps=None, ask='', resource='', priority=0, keyID='', client_caps=None,
our_chatstate=None, chatstate=None, last_status_time=None, msg_id = 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, CommonContact.__init__(self, jid, account, resource, show, status, name,
our_chatstate, composing_xep, chatstate, client_caps=client_caps) our_chatstate, composing_xep, chatstate, client_caps=client_caps)
@ -111,9 +111,6 @@ class Contact(CommonContact):
self.last_status_time = last_status_time self.last_status_time = last_status_time
self.pep = {} self.pep = {}
self.mood = mood.copy()
self.tune = tune.copy()
self.activity = activity.copy()
def get_full_jid(self): def get_full_jid(self):
if self.resource: if self.resource:
@ -229,23 +226,25 @@ class Contacts:
def create_contact(self, jid, account, name='', groups=[], show='', status='', def create_contact(self, jid, account, name='', groups=[], show='', status='',
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):
account = self._accounts.get(account, account) # Use Account object if available 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,
chatstate=chatstate, last_status_time=last_status_time, 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] 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 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, 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,
resource=resource, mood=conn.mood, tune=conn.tune, resource=resource)
activity=conn.activity) self_contact.pep = conn.pep
return self_contact
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 account = self._accounts.get(account, account) # Use Account object if available

View File

@ -237,24 +237,16 @@ class AbstractPEP(object):
'''To be implemented by subclasses''' '''To be implemented by subclasses'''
raise NotImplementedError raise NotImplementedError
def _update_contacts(self, jid, account): 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):
for contact in common.gajim.contacts.get_contacts(account, jid):
setattr(contact, self.type, dict)
if self._retracted: if self._retracted:
if self.type in contact.pep: if self.type in contact.pep:
del contact.pep[self.type] del contact.pep[self.type]
else: else:
contact.pep[self.type] = self contact.pep[self.type] = self
def _update_account(self, account): def _update_account(self, account):
dict = {} if self._retracted else self._pep_specific_data acc = common.gajim.connections[account]
acc = common.gajim.connections[account]
setattr(acc, self.type, dict)
if self._retracted: if self._retracted:
if self.type in acc.pep: if self.type in acc.pep:
del acc.pep[self.type] del acc.pep[self.type]
@ -571,15 +563,10 @@ def delete_pep(jid, name):
if jid == common.gajim.get_jid_from_account(name): if jid == common.gajim.get_jid_from_account(name):
acc = common.gajim.connections[name] acc = common.gajim.connections[name]
acc.activity = {} acc.pep = {}
user_send_tune(name)
acc.tune = {}
acc.mood = {}
for contact in common.gajim.contacts.get_contacts(name, user): for contact in common.gajim.contacts.get_contacts(name, user):
contact.activity = {} contact.pep = {}
contact.tune = {}
contact.mood = {}
if jid == common.gajim.get_jid_from_account(name): if jid == common.gajim.get_jid_from_account(name):
common.gajim.interface.roster.draw_account(name) common.gajim.interface.roster.draw_account(name)

View File

@ -88,9 +88,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
self.no_log_for = False self.no_log_for = False
self.pep_supported = False self.pep_supported = False
self.mood = {} self.pep = {}
self.tune = {}
self.activity = {}
# Do we continue connection when we get roster (send presence,get vcard...) # Do we continue connection when we get roster (send presence,get vcard...)
self.continue_connect_info = None self.continue_connect_info = None
if gajim.HAVE_GPG: if gajim.HAVE_GPG:

View File

@ -2432,11 +2432,10 @@ class RosterWindow:
account_name = account account_name = account
if gajim.account_is_connected(account): if gajim.account_is_connected(account):
account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total))
contact = gajim.contacts.create_contact(jid=jid, account=account, name=account_name, contact = gajim.contacts.create_self_contact(jid=jid, account=account,
show=connection.get_status(), sub='', status=connection.status, name=account_name, show=connection.get_status(),
resource=connection.server_resource, status=connection.status, resource=connection.server_resource,
priority=connection.priority, mood=connection.mood, priority=connection.priority)
tune=connection.tune, activity=connection.activity)
if gajim.connections[account].gpg: if gajim.connections[account].gpg:
contact.keyID = gajim.config.get_per('accounts', connection.name, contact.keyID = gajim.config.get_per('accounts', connection.name,
'keyid') 'keyid')

View File

@ -14,9 +14,7 @@ class MockConnection(Mock, ConnectionHandlersBase):
self.name = account self.name = account
self.connected = 2 self.connected = 2
self.mood = {} self.pep = {}
self.activity = {}
self.tune = {}
self.blocked_contacts = {} self.blocked_contacts = {}
self.blocked_groups = {} self.blocked_groups = {}
self.sessions = {} self.sessions = {}