Ejemplo n.º 1
0
def changeConnection():
    # Connect, or display status if we're already using selected VPN profile
    # If there is no profile, then skip this as the user has selected something non-selectable
    debugTrace("Changing connection to " + params + " from " +
               getVPNProfile() + ", connected:" + str(isVPNConnected()))
    addon = xbmcaddon.Addon(getID())
    ignore = False
    user_text = ""
    vpn_provider = addon.getSetting("vpn_provider")
    if isAlternative(vpn_provider):
        # Convert the friendly name to a file name, or an error message
        _, ovpn_connection, user_text, ignore = getAlternativeLocation(
            vpn_provider, params, 0, True)
    else:
        # Just extract the ovpn name from the URL for regular providers
        ovpn_connection = params
    # Try and connect if we've got a connection name.  If we're already connection, display the status
    if not ignore:
        if not user_text == "":
            xbmcgui.Dialog().ok(addon_name, user_text)
        elif isVPNConnected() and ovpn_connection == getVPNProfile(
        ) and not allowReconnection(vpn_provider) and not addon.getSetting(
                "allow_cycle_reconnect") == "true":
            displayStatus()
        else:
            connectVPN("0", ovpn_connection)
    return
Ejemplo n.º 2
0
def changeConnection():
    # Connect, or display status if we're already using selected VPN profile
    debugTrace("Changing connection to " + params + " from " + getVPNProfile() + ", connected:" + str(isVPNConnected()))
    if isVPNConnected() and params == getVPNProfile():
        displayStatus()
    else:        
        connectVPN("0", params)
    return
Ejemplo n.º 3
0
def changeConnection():
    # Connect, or display status if we're already using selected VPN profile
    debugTrace("Changing connection to " + params + " from " + getVPNProfile() + ", connected:" + str(isVPNConnected()))
    if isVPNConnected() and params == getVPNProfile():
        displayStatus()
    else:        
        connectVPN("0", params)
    return
Ejemplo n.º 4
0
def changeConnection():
    # Connect, or display status if we're already using selected VPN profile
    debugTrace("Changing connection to " + params + " from " +
               getVPNProfile() + ", connected:" + str(isVPNConnected()))
    if isVPNConnected() and params == getVPNProfile() and not isAlternative(
            addon.getSetting("vpn_provider")) and not addon.getSetting(
                "allow_cycle_reconnect") == "true":
        displayStatus()
    else:
        connectVPN("0", params)
    return
Ejemplo n.º 5
0
def changeConnection():
    xbmc.executebuiltin("ActivateWindow(busydialog)")
    # Connect, or display status if we're already using selected VPN profile
    debugTrace("Changing connection to " + params + " from " +
               getVPNProfile() + ", connected:" + str(isVPNConnected()))
    if isVPNConnected() and params == getVPNProfile():
        displayStatus()
    else:
        disconnectVPN2()
        connectVPN("1", params)
    xbmc.executebuiltin("Dialog.Close(busydialog)")
    return
Ejemplo n.º 6
0
                reconnect_on_drop = addon.getSetting("vpn_reconnect")
                reconnect_filtering = addon.getSetting(
                    "vpn_reconnect_filtering")
                display_location_info = addon.getSetting(
                    "display_location_on_connect")
                #if addon.getSetting("vpn_command_use_sudo") == "true": useSudo(True)
                #else: useSudo(False)

                # Refresh filter lists
                debugTrace("Update filter lists from settings")
                refreshAddonFilterLists()

                # If the VPN is not deliberately disconnected, then connect it
                if vpn_setup and not getVPNState() == "off":
                    if getVPNState() == "started":
                        debugTrace("VPN is started on " + getVPNProfile() +
                                   " requesting " + getVPNRequestedProfile())
                        # We're connected, but to the wrong VPN
                        if not getVPNRequestedProfile() == "":
                            if getVPNProfile() != getVPNRequestedProfile():
                                reconnect_vpn = True
                    else:
                        debugTrace("VPN not started, state is " +
                                   getVPNState())
                        # If we've just booted, then we won't have set the vpn_state property on the window
                        # so it'll come back empty.  Use this to determine if we should connect on boot
                        if getVPNState() == "":
                            # Just booted/started service.  If we're not connected at boot, then we're
                            # deliberately disconnected until the user uses one of the connect options
                            if connect_at_boot == "true":
                                debugTrace(
Ejemplo n.º 7
0
                # Build a list of all ovpn files using the current active filter
                if not isAlternative(vpn_provider):
                    all_connections = getAddonList(addon.getSetting("vpn_provider_validated"), "*.ovpn")
                    location_connections = getFilteredProfileList(all_connections, addon.getSetting("vpn_protocol"), None)
                    location_connections.sort()
                else:
                    location_connections = getAlternativeLocations(vpn_provider, False)
                    connections = getAlternativeFriendlyLocations(vpn_provider, False)
            else:
                # Build a list of all validated connections
                location_connections = getValidatedList(addon, "")
            # Build the friendly list, displaying any active connection in blue
            if isAlternative(vpn_provider) and addon.getSetting("table_display_type") == "All connections":
                connections = getAlternativeFriendlyProfileList(connections, getVPNProfileFriendly(), "ff00ff00")
            else:
                connections = getFriendlyProfileList(location_connections, getVPNProfile(), "ff00ff00")
            if getVPNState() == "started":
                title = "Connected - " + getVPNProfileFriendly()
                connections.insert(0, disconnect_text)
            else:
                title = "Disconnected"
                connections.insert(0, disconnected_text)
            
            connections.append(cancel_text)

            i = xbmcgui.Dialog().select(title, connections)
            if connections[i] == disconnect_text or connections[i] == disconnected_text:
                setAPICommand("Disconnect")
            elif not connections[i] == cancel_text:
                if getVPNProfile() == location_connections[i-1] and (allowReconnection(vpn_provider) or addon.getSetting("allow_cycle_reconnect") == "true"):
                    setAPICommand("Reconnect")
Ejemplo n.º 8
0
                    # It can get deleted sometimes, like when reinstalling the addon
                    if usesPassAuth(getVPNLocation(vpn_provider)) and not xbmcvfs.exists(getCredentialsPath(addon)):
                        writeCredentials(addon)
                
                # Force a reboot timer check
                reboot_timer = 3600
                seconds_to_reboot_check = 0

				# Refresh filter lists
                debugTrace("Update filter lists from settings")
                refreshAddonFilterLists()

				# If the VPN is not deliberately disconnected, then connect it
                if vpn_setup and not getVPNState() == "off":
                    if getVPNState() == "started":
                        debugTrace("VPN is started on " + getVPNProfile() + " requesting " + getVPNRequestedProfile())
						# We're connected, but to the wrong VPN
                        if not getVPNRequestedProfile() == "":
                            if getVPNProfile() != getVPNRequestedProfile() :
                                reconnect_vpn = True
                    else:
                        debugTrace("VPN not started, state is " + getVPNState())
						# If we've just booted, then we won't have set the vpn_state property on the window
						# so it'll come back empty.  Use this to determine if we should connect on boot
                        if getVPNState() == "":
							# Just booted/started service.  If we're not connected at boot, then we're
							# deliberately disconnected until the user uses one of the connect options
                            if addon.getSetting("vpn_connect_at_boot") == "true":
                                debugTrace("Connecting to primary VPN at boot time")
                                setVPNRequestedProfile(primary_vpns[0])
                                setVPNRequestedProfileFriendly(primary_vpns_friendly[0])
Ejemplo n.º 9
0
                if not isAlternative(vpn_provider):
                    all_connections = getAddonList(
                        addon.getSetting("vpn_provider_validated"), "*.ovpn")
                    location_connections = getFilteredProfileList(
                        all_connections, addon.getSetting("vpn_protocol"),
                        None)
                    location_connections.sort()
                else:
                    location_connections = getAlternativeLocations(
                        vpn_provider, False)
            else:
                # Build a list of all validated connections
                location_connections = getValidatedList(addon, "")
            # Build the friendly list, displaying any active connection in blue
            connections = getFriendlyProfileList(location_connections,
                                                 getVPNProfile(), "ff00ff00")
            if getVPNState() == "started":
                title = "Connected - " + getVPNProfileFriendly()
                connections.insert(0, disconnect_text)
            else:
                title = "Disconnected"
                connections.insert(0, disconnected_text)

            connections.append(cancel_text)

            i = xbmcgui.Dialog().select(title, connections)
            if connections[i] == disconnect_text or connections[
                    i] == disconnected_text:
                setAPICommand("Disconnect")
            elif not connections[i] == cancel_text:
                if getVPNProfile() == location_connections[i - 1] and (
Ejemplo n.º 10
0
    if getCycleLock():
        # Want to stop cycling whilst this menu is displayed, and clear any active cycle
        clearVPNCycle()
        if addon.getSetting("table_display_type") == "All Connections":
            # Build a list of all ovpn files using the current active filter
            all_connections = getAddonList(
                addon.getSetting("vpn_provider_validated"), "*.ovpn")
            ovpn_connections = getFilteredProfileList(
                all_connections, addon.getSetting("vpn_protocol"), None)
            ovpn_connections.sort()
        else:
            # Build a list of all validated connections
            ovpn_connections = getValidatedList(addon, "")
        # Build the friendly list, displaying any active connection in blue
        location_connections = getFriendlyProfileList(ovpn_connections,
                                                      getVPNProfile(),
                                                      "ff00ff00")
        if getVPNState() == "started":
            title = "Connected - " + getVPNProfileFriendly()
            location_connections.insert(0, disconnect_text)
        else:
            title = "Disconnected"
            location_connections.insert(0, disconnected_text)

        location_connections.append(cancel_text)

        i = xbmcgui.Dialog().select(title, location_connections)
        if location_connections[i] == disconnect_text or location_connections[
                i] == disconnected_text:
            setAPICommand("Disconnect")
        elif not location_connections[i] == cancel_text: