changeset 2167:4b78b4c7f805

core, frontends: various fixes for Libervia: - quick_app: don't fail when we can't get autodisconnect parameter - bridge: removed useless BridgeFrontend parent class - use of TypeError, unicode and list to workaround Pyjamas incompatibilities
author Goffi <goffi@goffi.org>
date Sun, 26 Feb 2017 18:23:01 +0100 (2017-02-26)
parents 1b3fbb76984b
children 255830fdb80b
files frontends/src/bridge/bridge_frontend.py frontends/src/bridge/dbus_bridge.py frontends/src/quick_frontend/quick_app.py frontends/src/quick_frontend/quick_chat.py src/core/sat_main.py src/tools/common/ansi.py
diffstat 6 files changed, 13 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/bridge/bridge_frontend.py	Sun Feb 26 18:20:27 2017 +0100
+++ b/frontends/src/bridge/bridge_frontend.py	Sun Feb 26 18:23:01 2017 +0100
@@ -18,12 +18,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-class BridgeFrontend(object):
-
-    def register(self, functionName, handler):
-        raise NotImplementedError
-
-
 class BridgeException(Exception):
     """An exception which has been raised from the backend and arrived to the frontend."""
 
--- a/frontends/src/bridge/dbus_bridge.py	Sun Feb 26 18:20:27 2017 +0100
+++ b/frontends/src/bridge/dbus_bridge.py	Sun Feb 26 18:23:01 2017 +0100
@@ -18,7 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sat.core.i18n import _
-from bridge_frontend import BridgeFrontend, BridgeException
+from bridge_frontend import BridgeException
 import dbus
 from sat.core.log import getLogger
 log = getLogger(__name__)
@@ -59,7 +59,7 @@
     return BridgeException(name, message, condition)
 
 
-class Bridge(BridgeFrontend):
+class Bridge(object):
 
     def bridgeConnect(self, callback, errback):
         try:
--- a/frontends/src/quick_frontend/quick_app.py	Sun Feb 26 18:20:27 2017 +0100
+++ b/frontends/src/quick_frontend/quick_app.py	Sun Feb 26 18:23:01 2017 +0100
@@ -76,10 +76,15 @@
         self.whoami = jid.JID(jid_s)  # resource might change after the connection
         self.bridge.isConnected(self.profile, callback=self._plug_profile_isconnected)
 
+    def _autodisconnectEb(self, failure_):
+        # XXX: we ignore error on this parameter, as Libervia can't access it
+        log.warning(_("Error while trying to get autodisconnect param, ignoring: {}").format(failure_))
+        self._plug_profile_autodisconnect("false")
+
     def _plug_profile_isconnected(self, connected):
         self.connected = connected
         self.bridge.asyncGetParamA("autodisconnect", "Connection", profile_key=self.profile,
-                                   callback=self._plug_profile_autodisconnect, errback=self._getParamError)
+                                   callback=self._plug_profile_autodisconnect, errback=self._autodisconnectEb)
 
     def _plug_profile_autodisconnect(self, autodisconnect):
         if C.bool(autodisconnect):
--- a/frontends/src/quick_frontend/quick_chat.py	Sun Feb 26 18:20:27 2017 +0100
+++ b/frontends/src/quick_frontend/quick_chat.py	Sun Feb 26 18:23:01 2017 +0100
@@ -139,7 +139,8 @@
             except KeyError:
                 log.error(u"extra data is missing user nick for uid {}".format(self.uid))
                 return ""
-        if self.parent.type == C.CHAT_GROUP or entity in contact_list.getSpecials(C.CONTACT_SPECIAL_GROUP):
+        # FIXME: converted getSpecials to list for pyjamas
+        if self.parent.type == C.CHAT_GROUP or entity in list(contact_list.getSpecials(C.CONTACT_SPECIAL_GROUP)):
             return entity.resource or ""
         if entity.bare in contact_list:
             return contact_list.getCache(entity, 'nick') or contact_list.getCache(entity, 'name') or entity.node or entity
@@ -292,7 +293,7 @@
     @staticmethod
     def getWidgetHash(target, profiles):
         profile = list(profiles)[0]
-        return profile + "\n" + target.bare
+        return profile + "\n" + unicode(target.bare)
 
     @staticmethod
     def getPrivateHash(target, profile):
--- a/src/core/sat_main.py	Sun Feb 26 18:20:27 2017 +0100
+++ b/src/core/sat_main.py	Sun Feb 26 18:23:01 2017 +0100
@@ -36,7 +36,6 @@
 from sat.stdui import ui_contact_list, ui_profile_manager
 import sat.plugins
 from glob import glob
-from uuid import uuid4
 import sys
 import os.path
 import uuid
@@ -733,7 +732,7 @@
         """
         callback_id = kwargs.pop('force_id', None)
         if callback_id is None:
-            callback_id = str(uuid4())
+            callback_id = str(uuid.uuid4())
         else:
             if callback_id in self._cb_map:
                 raise exceptions.ConflictError(_(u"id already registered"))
--- a/src/tools/common/ansi.py	Sun Feb 26 18:20:27 2017 +0100
+++ b/src/tools/common/ansi.py	Sun Feb 26 18:23:01 2017 +0100
@@ -44,7 +44,7 @@
 
 try:
     tty = sys.stdout.isatty()
-except AttributeError:
+except (AttributeError, TypeError):  # FIXME: TypeError is here for Pyjamas, need to be removed
     tty = False
 if not tty:
     # we don't want ANSI escape codes if we are not outputing to a tty!