primitivus, quick_frontends: moved newMessage signal handler to quick_frontend
This commit is contained in:
parent
d3dd1ce464
commit
288aaca7e8
1 changed files with 21 additions and 23 deletions
|
|
@ -211,7 +211,7 @@ class QuickApp(object):
|
|||
self.registerSignal("connected")
|
||||
self.registerSignal("disconnected")
|
||||
self.registerSignal("newContact")
|
||||
self.registerSignal("newMessage", self._newMessage)
|
||||
self.registerSignal("newMessage")
|
||||
self.registerSignal("newAlert")
|
||||
self.registerSignal("presenceUpdate")
|
||||
self.registerSignal("subscribe")
|
||||
|
|
@ -406,24 +406,37 @@ class QuickApp(object):
|
|||
_groups = list(groups)
|
||||
self.contact_lists[profile].setContact(entity, _groups, attributes, in_roster=True)
|
||||
|
||||
def _newMessage(self, from_jid_s, msg, type_, to_jid_s, extra, profile):
|
||||
def newMessageHandler(self, from_jid_s, msg, type_, to_jid_s, extra, profile):
|
||||
from_jid = jid.JID(from_jid_s)
|
||||
to_jid = jid.JID(to_jid_s)
|
||||
self.newMessageHandler(from_jid, to_jid, msg, type_, extra, profile)
|
||||
|
||||
def newMessageHandler(self, from_jid, to_jid, msg, type_, extra, profile):
|
||||
from_me = from_jid.bare == self.profiles[profile].whoami.bare
|
||||
target = to_jid if from_me else from_jid
|
||||
|
||||
chat_type = C.CHAT_GROUP if type_ == C.MESS_TYPE_GROUPCHAT else C.CHAT_ONE2ONE
|
||||
contact_list = self.contact_lists[profile]
|
||||
|
||||
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, target, type_=chat_type, profile=profile)
|
||||
chat_widget = self.widgets.getOrCreateWidget(quick_chat.QuickChat, target, type_=chat_type, on_new_widget=None, profile=profile)
|
||||
|
||||
self.current_action_ids = set() # FIXME: to be removed
|
||||
self.current_action_ids_cb = {} # FIXME: to be removed
|
||||
|
||||
if not from_jid in contact_list and from_jid.bare != self.profiles[profile].whoami.bare:
|
||||
#XXX: needed to show entities which haven't sent any
|
||||
# presence information and which are not in roster
|
||||
contact_list.setContact(from_jid)
|
||||
|
||||
# we display the message in the widget
|
||||
chat_widget.newMessage(from_jid, target, msg, type_, extra, profile)
|
||||
|
||||
# ContactList alert
|
||||
visible = False
|
||||
for widget in self.visible_widgets:
|
||||
if isinstance(widget, quick_chat.QuickChat) and widget.manageMessage(from_jid, type_):
|
||||
visible = True
|
||||
break
|
||||
if not visible:
|
||||
contact_list.setAlert(from_jid.bare if type_ == C.MESS_TYPE_GROUPCHAT else from_jid)
|
||||
|
||||
def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key=C.PROF_KEY_NONE):
|
||||
if callback is None:
|
||||
callback = lambda dummy=None: None # FIXME: optional argument is here because pyjamas doesn't support callback without arg with json proxy
|
||||
|
|
|
|||
Loading…
Reference in a new issue