summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/vpn/_status.py
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2017-06-29 18:54:30 +0200
committerRuben Pollan <meskio@sindominio.net>2017-07-20 21:37:03 +0200
commitd25757fba7d98b4535629de9dccf3f32b3e03487 (patch)
treea309c339c75bef34067d63f3bcffa2fc07c61f7c /src/leap/bitmask/vpn/_status.py
parent05cdff086cfa4b4770d1d1af50b1f462e09b1632 (diff)
[refactor] use VPNManagment in composition instead of inheritance
We make an ugly step for that moving the VPNStatus into VPNManagement. Let's iterate on it a second time to clean up that. - Related: #8942
Diffstat (limited to 'src/leap/bitmask/vpn/_status.py')
-rw-r--r--src/leap/bitmask/vpn/_status.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/leap/bitmask/vpn/_status.py b/src/leap/bitmask/vpn/_status.py
index 6bd9c7c9..5d41a535 100644
--- a/src/leap/bitmask/vpn/_status.py
+++ b/src/leap/bitmask/vpn/_status.py
@@ -74,9 +74,10 @@ class VPNStatus(object):
elif status in self._CONNECTED:
status = "on"
- self._status = status
- self.errcode = errcode
- emit_async(catalog.VPN_STATUS_CHANGED)
+ if self._status != status:
+ self._status = status
+ self.errcode = errcode
+ emit_async(catalog.VPN_STATUS_CHANGED)
def get_traffic_status(self):
down = None
@@ -87,7 +88,8 @@ class VPNStatus(object):
up = bytes2human(self._traffic_up)
return {'down': down, 'up': up}
- def set_traffic_status(self, status):
- up, down = status
- self._traffic_up = up
- self._traffic_down = down
+ def set_traffic_status(self, up, down):
+ if up != self._traffic_up or down != self._traffic_down:
+ self._traffic_up = up
+ self._traffic_down = down
+ emit_async(catalog.VPN_STATUS_CHANGED)