Exemplo n.º 1
0
def apiConnect(connection):
    if connection.isdigit():
        c = int(connection)
        addon = xbmcaddon.Addon(getID())
        # Adjust the 11 below to change conn_max
        if c > 0 and c < 11:
            connection = addon.getSetting(str(c) + "_vpn_validated")
            if not connection == "":
                setAPICommand(connection)
            else:
                errorTrace(
                    "api.py", "Connection requested, " + str(c) +
                    " has not been validated")
        else:
            errorTrace("api.py",
                       "Invalid connection, " + str(c) + " requested")
    else:
        if xbmcvfs.exists(connection):
            setAPICommand(connection)
        else:
            errorTrace(
                "api.py",
                "Requested connection, " + connection + " does not exist")
Exemplo n.º 2
0
import xbmcvfs
import string
from libs.common import setAPICommand, clearAPICommand, getAPICommand
from libs.utility import debugTrace, errorTrace, infoTrace, newPrint

addon = xbmcaddon.Addon("service.vpn.manager")
addon_name = addon.getAddonInfo("name")

# Get the first argument which will indicate the connection that's being dealt with
command = sys.argv[1]
lcommand = command.lower()

debugTrace("Entered api.py with parameter " + command)

if lcommand == "disconnect":
    setAPICommand("Disconnect")
elif lcommand == "cycle":
    setAPICommand("Cycle")
elif lcommand == "fake":
    setAPICommand("Fake")
elif lcommand == "real":
    setAPICommand("Real")
elif lcommand == "pause":
    setAPICommand("Pause")
elif lcommand == "restart":
    setAPICommand("Restart")
elif lcommand.startswith("connect"):
    connection = command[8:].strip(' \t\n\r')
    if connection.isdigit():
        c = int(connection)
        # Adjust the 11 below to change conn_max
Exemplo n.º 3
0
    if xbmcgui.Dialog().yesno(
            addon_name,
            "Updating the VPN settings will reset all VPN connections.  Connections must be re-validated before use.\nContinue?"
    ):
        # Display dialog to show what's going on
        progress = xbmcgui.DialogProgress()
        progress_title = "Resetting VPN connections"
        progress.create(addon_name, progress_title)

        if not getVPNRequestedProfile() == "":
            progress.close()
            xbmcgui.Dialog().ok(
                addon_name,
                "Connection to VPN being attempted and will be aborted.  Try again in a few seconds."
            )
            setAPICommand("Disconnect")
            success = False

        if success:
            # Stop the VPN monitor
            xbmc.sleep(100)
            progress.update(
                0, progress_title + "\n" + "Pausing VPN monitor..." + "\n\n")
            xbmc.sleep(100)

            if not stopService():
                progress.close()
                # Display error result in an ok dialog
                errorTrace(
                    "resetVPN.py",
                    "VPN monitor service is not running, can't reset VPNs")
Exemplo n.º 4
0
import xbmcaddon
import xbmcvfs
import string
from libs.common import setAPICommand, clearAPICommand, getAPICommand
from libs.utility import debugTrace, errorTrace, infoTrace, newPrint, getID

# Get the first argument which will indicate the connection that's being dealt with
command = sys.argv[1]
lcommand = command.lower()

debugTrace("Entered api.py with parameter " + command)

if not getID() == "":
    if lcommand == "disconnect": 
        setAPICommand("Disconnect")
    elif lcommand == "cycle":
        setAPICommand("Cycle")
    elif lcommand == "fake":
        setAPICommand("Fake")
    elif lcommand == "real":
        setAPICommand("Real")
    elif lcommand == "pause":
        setAPICommand("Pause")
    elif lcommand == "restart":
        setAPICommand("Restart")
    elif lcommand == "reconnect":
        setAPICommand("Reconnect")
    elif lcommand == "getip":
        setAPICommand("GetIP")
    elif lcommand.startswith("connect"): 
Exemplo n.º 5
0
            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")
                else:
                    if isAlternative(vpn_provider) and addon.getSetting("table_display_type") == "All connections":
                        _, connection, user_text, ignore = getAlternativeLocation(vpn_provider, connections[i], 0, True)
                        if not ignore and not user_text == "":
                            xbmcgui.Dialog().ok(addon_name, user_text)
                    else:
                        connection = location_connections[i-1]
                    if not connection == "":
                        setAPICommand(connection)
            freeCycleLock()
    else:
        xbmcgui.Dialog().notification(addon_name, "VPN is not set up and authenticated.", xbmcgui.NOTIFICATION_ERROR, 10000, True)
Exemplo n.º 6
0
    # Get info about the addon that this script is pretending to be attached to
    addon = xbmcaddon.Addon(getID())
    addon_name = getName()

    success = True
    # Reset the VPN connection values stored in the settings.xml
    if xbmcgui.Dialog().yesno(addon_name, "Updating the VPN settings will reset all VPN connections.  Connections must be re-validated before use.\nContinue?"):
        # Display dialog to show what's going on
        progress = xbmcgui.DialogProgress()
        progress_title = "Resetting VPN connections"
        progress.create(addon_name,progress_title) 

        if not getVPNRequestedProfile() == "":
            progress.close()
            xbmcgui.Dialog().ok(addon_name, "Connection to VPN being attempted and will be aborted.  Try again in a few seconds.")
            setAPICommand("Disconnect")
            success = False
        
        if success:
            # Stop the VPN monitor
            xbmc.sleep(100)
            progress.update(0, progress_title, "Pausing VPN monitor...")
            xbmc.sleep(100)
                
            if not stopService():
                progress.close()
                # Display error result in an ok dialog
                errorTrace("resetVPN.py", "VPN monitor service is not running, can't reset VPNs")
                xbmcgui.Dialog().ok(progress_title, "Error, Service not running. Check log and re-enable.")
                success = False
        
Exemplo n.º 7
0
                    " has not been validated")
        else:
            errorTrace("api.py",
                       "Invalid connection, " + str(c) + " requested")
    else:
        if xbmcvfs.exists(connection):
            setAPICommand(connection)
        else:
            errorTrace(
                "api.py",
                "Requested connection, " + connection + " does not exist")


if not getID() == "":
    if lcommand == "disconnect":
        setAPICommand("Disconnect")
    elif lcommand == "cycle":
        setAPICommand("Cycle")
    elif lcommand.startswith("toggle"):
        if isVPNConnected():
            setAPICommand("Disconnect")
        else:
            connection = command[7:].strip(' \t\n\r')
            apiConnect(connection)
    elif lcommand == "fake":
        setAPICommand("Fake")
    elif lcommand == "real":
        setAPICommand("Real")
    elif lcommand == "pause":
        setAPICommand("Pause")
    elif lcommand == "restart":
Exemplo n.º 8
0
            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:
            setAPICommand(ovpn_connections[i - 1])
        freeCycleLock()
else:
    xbmcgui.Dialog().notification(addon_name,
                                  "VPN is not set up and authenticated.",
                                  xbmcgui.NOTIFICATION_ERROR, 10000, True)

debugTrace("-- Exit table.py --")