# HG changeset patch # User Goffi # Date 1388780707 -3600 # Node ID f89173f4485010eae9bf5721ea52a17d46debf05 # Parent ab66dac17d1f5f745560faf191d5d545b22d631f frontends: fixed sendMessage calls, sendMessage is now async so callback and errback need to be specified + redraw in PrimivitusApp.notify diff -r ab66dac17d1f -r f89173f44850 frontends/src/jp/jp --- a/frontends/src/jp/jp Sun Dec 29 17:48:14 2013 +0100 +++ b/frontends/src/jp/jp Fri Jan 03 21:25:07 2014 +0100 @@ -256,14 +256,15 @@ 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 -r ab66dac17d1f -r f89173f44850 frontends/src/primitivus/primitivus --- a/frontends/src/primitivus/primitivus Sun Dec 29 17:48:14 2013 +0100 +++ b/frontends/src/primitivus/primitivus Fri Jan 03 21:25:07 2014 +0100 @@ -103,13 +103,12 @@ 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 @@ 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 -r ab66dac17d1f -r f89173f44850 frontends/src/quick_frontend/quick_app.py --- a/frontends/src/quick_frontend/quick_app.py Sun Dec 29 17:48:14 2013 +0100 +++ b/frontends/src/quick_frontend/quick_app.py Fri Jan 03 21:25:07 2014 +0100 @@ -280,11 +280,15 @@ 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):