From 8b77f3155288d51197dfa1082dd3e7079a9d7620 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Wed, 23 Aug 2017 01:10:03 -0400 Subject: [refactor] add state listener to signal state transition to UI --- src/leap/bitmask/vpn/process.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/leap/bitmask/vpn/process.py') diff --git a/src/leap/bitmask/vpn/process.py b/src/leap/bitmask/vpn/process.py index ecbc150..19115d6 100644 --- a/src/leap/bitmask/vpn/process.py +++ b/src/leap/bitmask/vpn/process.py @@ -33,14 +33,21 @@ from twisted.logger import Logger from leap.bitmask.vpn.utils import get_vpn_launcher from leap.bitmask.vpn.management import ManagementProtocol - from leap.bitmask.vpn.launchers import darwin from leap.bitmask.vpn.constants import IS_MAC, IS_LINUX +from leap.common.events import catalog, emit_async + OPENVPN_VERBOSITY = 4 +class VPNStateListener(object): + + def change_state(self, state): + emit_async(catalog.VPN_STATUS_CHANGED) + + class _VPNProcess(protocol.ProcessProtocol): """ @@ -99,6 +106,9 @@ class _VPNProcess(protocol.ProcessProtocol): @defer.inlineCallbacks def _got_management_protocol(self, proto): self.proto = proto + listener = VPNStateListener() + proto.addStateListener(listener) + try: yield proto.logOn() yield proto.getVersion() -- cgit v1.2.3