quick_frontends, primitivus: move the chat states logic to quick_frontend
This commit is contained in:
parent
c6419871ac
commit
14f4b4b8ec
1 changed files with 70 additions and 35 deletions
|
|
@ -23,7 +23,7 @@ log = getLogger(__name__)
|
|||
from sat_frontends.tools import jid
|
||||
from sat_frontends.quick_frontend import quick_widgets
|
||||
from sat_frontends.quick_frontend.constants import Const as C
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
try:
|
||||
# FIXME: to be removed when an acceptable solution is here
|
||||
|
|
@ -34,6 +34,8 @@ except (TypeError, AttributeError): # Error raised is not the same depending on
|
|||
|
||||
class QuickChat(quick_widgets.QuickWidget):
|
||||
|
||||
visible_states = ['chat_state']
|
||||
|
||||
def __init__(self, host, target, type_=C.CHAT_ONE2ONE, profiles=None):
|
||||
"""
|
||||
@param type_: can be C.CHAT_ONE2ONE for single conversation or C.CHAT_GROUP for chat à la IRC
|
||||
|
|
@ -207,12 +209,25 @@ class QuickChat(quick_widgets.QuickWidget):
|
|||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def updateChatState(self, from_jid, state):
|
||||
"""Set the chat state (XEP-0085) of the contact.
|
||||
def updateEntityState(self, entity, type_, value):
|
||||
"""Update a state value for the given entity.
|
||||
|
||||
@param state: the new chat state
|
||||
@param entity (jid.JID): entity to update
|
||||
@param type_ (unicode): type of state (e.g. 'chat_state')
|
||||
@param value (unicode): new value
|
||||
"""
|
||||
raise NotImplementedError
|
||||
contact_list = self.host.contact_lists[self.profile]
|
||||
contact_list.setCache(entity, type_, value)
|
||||
clist = self.host.contact_lists[self.profile]
|
||||
states = OrderedDict()
|
||||
for key in self.visible_states:
|
||||
value = clist.getCache(entity, key)
|
||||
if value:
|
||||
states[key] = value
|
||||
if self.type == C.CHAT_GROUP:
|
||||
self.setOccupantStates(entity, states)
|
||||
else:
|
||||
self.setContactStates(entity, states)
|
||||
|
||||
def addGamePanel(self, widget):
|
||||
"""Insert a game panel to this Chat dialog.
|
||||
|
|
|
|||
Loading…
Reference in a new issue