primitivus, quick_frontends: moved newMessage signal handler to quick_frontend
This commit is contained in:
parent
d3dd1ce464
commit
288aaca7e8
2 changed files with 21 additions and 23 deletions
|
|
@ -530,8 +530,8 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
|
||||
def removeWindow(self):
|
||||
"""Remove window showed on the right column"""
|
||||
#TODO: to a better Window management than this crappy hack
|
||||
assert(len(self.center_part.widget_list)<=2)
|
||||
#TODO: better Window management than this hack
|
||||
assert len(self.center_part.widget_list) <= 2
|
||||
wid_idx = len(self.center_part.widget_list)-1
|
||||
self.center_part.widget_list[wid_idx] = urwid.Filler(urwid.Text(''))
|
||||
self.center_part.focus_position = 0
|
||||
|
|
@ -556,21 +556,6 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
self.selectWidget(chat_widget)
|
||||
self.menu_roller.addMenu(_('Chat menu'), chat_widget.getMenu(), C.MENU_ID_WIDGET)
|
||||
|
||||
def newMessageHandler(self, from_jid, to_jid, msg, type_, extra, profile):
|
||||
QuickApp.newMessageHandler(self, from_jid, to_jid, msg, type_, extra, profile)
|
||||
|
||||
if not from_jid in self.contact_lists[profile] 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
|
||||
self.contact_lists[profile].setContact(from_jid)
|
||||
visible = False
|
||||
for widget in self.visible_widgets:
|
||||
if isinstance(widget, Chat) and widget.manageMessage(from_jid, type_):
|
||||
visible = True
|
||||
break
|
||||
if not visible:
|
||||
self.contact_lists[profile].setAlert(from_jid.bare if type_ == C.MESS_TYPE_GROUPCHAT else from_jid)
|
||||
|
||||
def _dialogOkCb(self, widget, data):
|
||||
self.removePopUp()
|
||||
answer_cb = data[0]
|
||||
|
|
|
|||
|
|
@ -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