Mercurial > libervia-desktop-kivy
changeset 370:1a12bbd80943
android: autoconnect profile using the new `profileAutoconnectGet` backend method:
thanks to this method, Cagou know which profile is started automatically in backend, and
can start it in frontend too.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jan 2020 21:17:08 +0100 |
parents | bbf992b0be0d |
children | 080b6cc17f53 |
files | cagou/__init__.py cagou/core/cagou_main.py cagou/core/platform_/android.py cagou/core/platform_/base.py |
diffstat | 4 files changed, 28 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/cagou/__init__.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/__init__.py Mon Jan 27 21:17:08 2020 +0100 @@ -1,5 +1,4 @@ -#!/usr//bin/env python2 -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client # Copyright (C) 2016-2019 Jérôme Poisson (goffi@goffi.org)
--- a/cagou/core/cagou_main.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/core/cagou_main.py Mon Jan 27 21:17:08 2020 +0100 @@ -515,7 +515,8 @@ self.app.showWidget() self.bridge.getVersion(callback=self._getVersionCb) self.app.initFrontendState() - self.postInit() + if local_platform.do_postInit(): + self.postInit() def postInit(self, __=None): # FIXME: resize doesn't work with SDL2 on android, so we use below_target for now
--- a/cagou/core/platform_/android.py Mon Jan 27 21:17:08 2020 +0100 +++ b/cagou/core/platform_/android.py Mon Jan 27 21:17:08 2020 +0100 @@ -80,12 +80,33 @@ # XXX: we use a separated socket instead of bridge because if we # try to call a bridge method in on_pause method, the call data # is not written before the actual pause - s = self._frontend_status_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + s = self._frontend_status_socket = socket.socket( + socket.AF_UNIX, socket.SOCK_STREAM) s.connect(os.path.join(SOCKET_DIR, SOCKET_FILE)) s.sendall(STATE_RUNNING) + def profileAutoconnectGetCb(self, profile=None): + if profile is not None: + G.host.options.profile = profile + G.host.postInit() + + def profileAutoconnectGetEb(self, failure_): + log.error(f"Error while getting profile to autoconnect: {failure_}") + G.host.postInit() + + def do_postInit(self): + G.host.bridge.profileAutoconnectGet( + callback=self.profileAutoconnectGetCb, + errback=self.profileAutoconnectGetEb + ) + return False + def onProfilePlugged(self, profile): log.debug("ANDROID profilePlugged") + G.host.bridge.setParam( + "autoconnect_backend", C.BOOL_TRUE, "Connection", -1, profile, + callback=lambda: log.info(f"profile {profile} autonnection set"), + errback=lambda: log.error(f"can't set {profile} autonnection")) for method, *args in self.cache: method(*args) del self.cache