quick frontend, primitivus: quickContactList refactored to handle several profiles at once
This commit is contained in:
parent
0b52799489
commit
8851addc20
1 changed files with 552 additions and 168 deletions
|
|
@ -29,6 +29,7 @@ from sat_frontends.quick_frontend import quick_widgets
|
|||
from sat_frontends.quick_frontend import quick_menus
|
||||
from sat_frontends.quick_frontend import quick_blog
|
||||
from sat_frontends.quick_frontend import quick_chat, quick_games
|
||||
from sat_frontends.quick_frontend import quick_contact_list
|
||||
from sat_frontends.quick_frontend.constants import Const as C
|
||||
|
||||
import sys
|
||||
|
|
@ -95,8 +96,7 @@ class ProfileManager(object):
|
|||
|
||||
def _plug_profile_gotCachedValues(self, cached_values):
|
||||
# add the contact list and its listener
|
||||
contact_list = self.host.addContactList(self.profile)
|
||||
self.host.contact_lists[self.profile] = contact_list
|
||||
contact_list = self.host.contact_lists.addProfile(self.profile)
|
||||
|
||||
for entity, data in cached_values.iteritems():
|
||||
for key, value in data.iteritems():
|
||||
|
|
@ -192,8 +192,7 @@ class ProfilesManager(object):
|
|||
|
||||
# remove the contact list and its listener
|
||||
host = self._profiles[profile].host
|
||||
host.contact_lists[profile].onDelete()
|
||||
del host.contact_lists[profile]
|
||||
host.contact_lists[profile].unplug()
|
||||
|
||||
del self._profiles[profile]
|
||||
|
||||
|
|
@ -218,7 +217,7 @@ class QuickApp(object):
|
|||
self.profiles = ProfilesManager()
|
||||
self.ready_profiles = set() # profiles which are connected and ready
|
||||
self.signals_cache = {} # used to keep signal received between start of plug_profile and when the profile is actualy ready
|
||||
self.contact_lists = {}
|
||||
self.contact_lists = quick_contact_list.QuickContactListHandler(self)
|
||||
self.widgets = quick_widgets.QuickWidgetsManager(self)
|
||||
if check_options is not None:
|
||||
self.options = check_options()
|
||||
|
|
@ -296,7 +295,8 @@ class QuickApp(object):
|
|||
@property
|
||||
def alerts_count(self):
|
||||
"""Count the over whole alerts for all contact lists"""
|
||||
return sum([sum(clist._alerts.values()) for clist in self.contact_lists.values()])
|
||||
# FIXME
|
||||
# return sum([sum(clist._alerts.values()) for clist in self.contact_lists.values()])
|
||||
|
||||
def registerSignal(self, function_name, handler=None, iface="core", with_profile=True):
|
||||
"""Register a handler for a signal
|
||||
|
|
@ -448,14 +448,6 @@ class QuickApp(object):
|
|||
def clear_profile(self):
|
||||
self.profiles.clear()
|
||||
|
||||
def addContactList(self, profile):
|
||||
"""Method to subclass to add a contact list widget
|
||||
|
||||
will be called on each profile session build
|
||||
@return: a ContactList widget
|
||||
"""
|
||||
return NotImplementedError
|
||||
|
||||
def newWidget(self, widget):
|
||||
raise NotImplementedError
|
||||
|
||||
|
|
@ -473,7 +465,7 @@ class QuickApp(object):
|
|||
def disconnectedHandler(self, profile):
|
||||
"""called when the connection is closed"""
|
||||
log.debug(_("Disconnected"))
|
||||
self.contact_lists[profile].clearContacts()
|
||||
self.contact_lists[profile].disconnect()
|
||||
self.setPresenceStatus(C.PRESENCE_UNAVAILABLE, '', profile=profile)
|
||||
|
||||
def actionNewHandler(self, action_data, id_, security_limit, profile):
|
||||
|
|
@ -481,8 +473,8 @@ class QuickApp(object):
|
|||
|
||||
def newContactHandler(self, jid_s, attributes, groups, profile):
|
||||
entity = jid.JID(jid_s)
|
||||
_groups = list(groups)
|
||||
self.contact_lists[profile].setContact(entity, _groups, attributes, in_roster=True)
|
||||
groups = list(groups)
|
||||
self.contact_lists[profile].setContact(entity, groups, attributes, in_roster=True)
|
||||
|
||||
def newMessageHandler(self, from_jid_s, msg, type_, to_jid_s, extra, profile):
|
||||
from_jid = jid.JID(from_jid_s)
|
||||
|
|
@ -516,7 +508,7 @@ class QuickApp(object):
|
|||
if isinstance(widget, quick_chat.QuickChat) and widget.manageMessage(from_jid, type_):
|
||||
visible = True
|
||||
break
|
||||
if visible:
|
||||
if visible: # FIXME: à virer gof:
|
||||
if self.isHidden(): # the window is hidden
|
||||
self.updateAlertsCounter(extra_inc=1)
|
||||
else:
|
||||
|
|
@ -730,7 +722,7 @@ class QuickApp(object):
|
|||
|
||||
def contactDeletedHandler(self, jid_s, profile):
|
||||
target = jid.JID(jid_s)
|
||||
self.contact_lists[profile].removeContact(target, in_roster=True)
|
||||
self.contact_lists[profile].removeContact(target)
|
||||
|
||||
def entityDataUpdatedHandler(self, entity_s, key, value, profile):
|
||||
entity = jid.JID(entity_s)
|
||||
|
|
|
|||
Loading…
Reference in a new issue