diff --git a/frontends/src/jp/jp b/frontends/src/jp/jp index 51eea11c..0862b883 100755 --- a/frontends/src/jp/jp +++ b/frontends/src/jp/jp @@ -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): diff --git a/frontends/src/primitivus/primitivus b/frontends/src/primitivus/primitivus index 6656ee98..9ac57820 100755 --- a/frontends/src/primitivus/primitivus +++ b/frontends/src/primitivus/primitivus @@ -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, diff --git a/frontends/src/quick_frontend/quick_app.py b/frontends/src/quick_frontend/quick_app.py index e7aa5b8c..bdd04f17 100644 --- a/frontends/src/quick_frontend/quick_app.py +++ b/frontends/src/quick_frontend/quick_app.py @@ -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):