diff cagou/core/cagou_main.py @ 346:7b9a0e57df53

core: new "connected" property in CagouApp
author Goffi <goffi@goffi.org>
date Sat, 04 Jan 2020 16:24:57 +0100
parents 89799148f894
children 33244f944bd8
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Sat Jan 04 16:24:57 2020 +0100
+++ b/cagou/core/cagou_main.py	Sat Jan 04 16:24:57 2020 +0100
@@ -296,6 +296,7 @@
     c_sec = properties.ListProperty(C.COLOR_SEC)
     c_sec_light = properties.ListProperty(C.COLOR_SEC_LIGHT)
     c_sec_dark = properties.ListProperty(C.COLOR_SEC_DARK)
+    connected = properties.BooleanProperty(False)
     # we have to put those constants here and not in core/constants.py
     # because of the use of dp(), which would import Kivy too early
     # and prevent the log hack
@@ -498,6 +499,11 @@
         del self.app._profile_manager
         super(Cagou, self).postInit(profile_manager)
 
+    def profilePlugged(self, profile):
+        super().profilePlugged(profile)
+        # FIXME: this won't work with multiple profiles
+        self.app.connected = self.profiles[profile].connected
+
     def _defaultFactoryMain(self, plugin_info, target, profiles):
         """default factory used to create main widgets instances
 
@@ -880,6 +886,16 @@
         else:
             return super(Cagou, self)._debugHandler(action, parameters, profile)
 
+    def connectedHandler(self, jid_s, profile):
+        # FIXME: this won't work with multiple profiles
+        super().connectedHandler(jid_s, profile)
+        self.app.connected = True
+
+    def disconnectedHandler(self, profile):
+        # FIXME: this won't work with multiple profiles
+        super().disconnectedHandler(profile)
+        self.app.connected = False
+
     ## misc ##
 
     def plugging_profiles(self):