frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify
This commit is contained in:
parent
401f47273b
commit
fc003ecf77
3 changed files with 15 additions and 10 deletions
|
|
@ -256,14 +256,15 @@ class JP(object):
|
|||
|
||||
if self.options.separate: #we send stdin in several messages
|
||||
if header:
|
||||
self.bridge.sendMessage(self.dest_jid, header, profile_key=self.profile)
|
||||
self.bridge.sendMessage(self.dest_jid, header, profile_key=self.profile, callback=lambda: None, errback=lambda ignore: ignore)
|
||||
while (True):
|
||||
line = clean_ustr(sys.stdin.readline().decode('utf-8','ignore'))
|
||||
if not line:
|
||||
break
|
||||
self.bridge.sendMessage(self.dest_jid, line.replace("\n",""), profile_key=self.profile)
|
||||
self.bridge.sendMessage(self.dest_jid, line.replace("\n",""), profile_key=self.profile, callback=lambda: None, errback=lambda ignore: ignore)
|
||||
else:
|
||||
self.bridge.sendMessage(self.dest_jid, header + clean_ustr(u"".join([stream.decode('utf-8','ignore') for stream in sys.stdin.readlines()])), profile_key=self.profile)
|
||||
self.bridge.sendMessage(self.dest_jid, header + clean_ustr(u"".join([stream.decode('utf-8','ignore') for stream in sys.stdin.readlines()])),
|
||||
profile_key=self.profile, callback=lambda: None, errback=lambda ignore: ignore)
|
||||
|
||||
|
||||
def pipe_out(self):
|
||||
|
|
|
|||
|
|
@ -103,13 +103,12 @@ class EditBar(sat_widgets.ModalEdit):
|
|||
contact = self.app.contact_list.getContact() ###Based on the fact that there is currently only one contact selectableat once
|
||||
if contact:
|
||||
chat = self.app.chat_wins[contact]
|
||||
try:
|
||||
self.app.sendMessage(contact,
|
||||
self.app.sendMessage(contact,
|
||||
editBar.get_edit_text(),
|
||||
mess_type = "groupchat" if chat.type == 'group' else "chat",
|
||||
profile_key=self.app.profile)
|
||||
except: # FIXME: bad global catch + sendMessage is now async
|
||||
self.app.notify(_("Error while sending message"))
|
||||
errback=lambda failure: self.app.notify(_("Error while sending message (%s)") % unicode(failure)),
|
||||
profile_key=self.app.profile
|
||||
)
|
||||
editBar.set_edit_text('')
|
||||
elif self.mode == 'COMMAND':
|
||||
self.commandHandler()
|
||||
|
|
@ -346,6 +345,7 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
def notify(self, message):
|
||||
""""Notify message to user via notification bar"""
|
||||
self.notBar.addMessage(message)
|
||||
self.redraw()
|
||||
|
||||
def addWindow(self, widget):
|
||||
"""Display a window if possible,
|
||||
|
|
|
|||
|
|
@ -280,11 +280,15 @@ class QuickApp(object):
|
|||
timestamp = extra.get('archive')
|
||||
self.chat_wins[win.bare].printMessage(from_jid, msg, profile, float(timestamp) if timestamp else '')
|
||||
|
||||
def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, profile_key="@NONE@"):
|
||||
def sendMessage(self, to_jid, message, subject='', mess_type="auto", extra={}, callback=None, errback=None, profile_key="@NONE@"):
|
||||
if to_jid.startswith(Const.PRIVATE_PREFIX):
|
||||
to_jid = unescapePrivate(to_jid)
|
||||
mess_type = "chat"
|
||||
self.bridge.sendMessage(to_jid, message, subject, mess_type, extra, profile_key)
|
||||
if callback is None:
|
||||
callback = lambda: None
|
||||
if errback is None:
|
||||
errback = lambda failure: self.showDialog(unicode(failure), _(u"sendMessage Error"), "error")
|
||||
self.bridge.sendMessage(to_jid, message, subject, mess_type, extra, profile_key, callback=callback, errback=errback)
|
||||
|
||||
def newAlert(self, msg, title, alert_type, profile):
|
||||
if not self.check_profile(profile):
|
||||
|
|
|
|||
Loading…
Reference in a new issue