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 isAlternative(vpn_provider) and not addon.getSetting( "allow_cycle_reconnect") == "true": displayStatus() else: connectVPN("0", ovpn_connection) return
def listConnections(): # Start with the disconnect option url = base_url + "?disconnect" if getVPNProfileFriendly() == "": li = xbmcgui.ListItem("[COLOR ffff0000](Disconnected)[/COLOR]") li.setArt({"icon":getIconPath()+"disconnected.png"}) else: li = xbmcgui.ListItem("[COLOR ffff0000]Disconnect[/COLOR]") li.setArt({"icon":getIconPath()+"unlocked.png"}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) # We should have a VPN set up by now, but don't list if we haven't. vpn_provider = addon.getSetting("vpn_provider") debugTrace("Listing the connections available for " + vpn_provider) if not vpn_provider == "": # Get the list of connections and add them to the directory if not isAlternative(vpn_provider): all_connections = getAddonList(vpn_provider, "*.ovpn") ovpn_connections = getFilteredProfileList(all_connections, addon.getSetting("vpn_protocol"), None) connections = getFriendlyProfileList(ovpn_connections, "", "") else: ovpn_connections = getAlternativeLocations(vpn_provider, False) connections = getAlternativeFriendlyLocations(vpn_provider, False) inc = 0 for connection in ovpn_connections: if not isAlternative(vpn_provider): # Regular connections have the ovpn filename added ot the URL url = base_url + "?change?" + ovpn_connections[inc] else: # Alternative connections use the friendly name which can then be resolved later url = base_url + "?change?" + connections[inc] conn_text = "" conn_primary = "" i=1 # Adjust 10 and 11 below if changing number of conn_max while (i < 11): if addon.getSetting(str(i) + "_vpn_validated_friendly") == connections[inc].strip(" ") : conn_primary = " (" + str(i) + ")" i = 10 i=i+1 if getVPNProfileFriendly() == connections[inc].strip(" ") and isVPNConnected(): conn_text = "[COLOR ff00ff00]" + connections[inc] + conn_primary + " (Connected)[/COLOR]" if fakeConnection(): icon = getIconPath()+"faked.png" else: icon = getIconPath()+"connected.png" else: if not conn_primary == "": conn_text = "[COLOR ff0099ff]" + connections[inc] + conn_primary + "[/COLOR]" else: conn_text = connections[inc] + conn_primary icon = getIconPath()+"locked.png" li = xbmcgui.ListItem(conn_text) li.setArt({"icon":icon}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) inc = inc + 1 xbmcplugin.endOfDirectory(addon_handle) return
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
# Reset the ovpn files if action == "ovpn": if addon.getSetting("1_vpn_validated") == "" or xbmcgui.Dialog().yesno( addon_name, "Resetting the VPN provider will disconnect and reset all VPN connections, and then remove any files that have been created. Continue?" ): suspendConfigUpdate() # Disconnect so that live files are not being modified if isVPNConnected(): resetVPNConnections(addon) debugTrace("Deleting all generated files") # Delete the generated files, and reset the locations so it can be selected again removeGeneratedFiles() # Delete any values that have previously been validated vpn_provider = getVPNLocation(addon.getSetting("vpn_provider")) if isAlternative(vpn_provider): resetAlternative(vpn_provider) # Reset the IP service error counts, etc resetIPServices() addon = xbmcaddon.Addon(getID()) # Reset values that would have been stored as part of validation addon.setSetting("vpn_provider_validated", "") addon.setSetting("vpn_locations_list", "") addon.setSetting("vpn_username_validated", "") addon.setSetting("vpn_password_validated", "") # Re-enble the wizard addon.setSetting("vpn_wizard_enabled", "true") resumeConfigUpdate() xbmcgui.Dialog().ok( addon_name, "Reset the VPN provider. Validate a connection to start using a VPN again.\n" )
cancel_text = "[I][COLOR grey]Cancel[/COLOR][/I]" disconnect_text = "[COLOR ffff0000]Disconnect[/COLOR]" disconnected_text = "[COLOR ffff0000](Disconnected)[/COLOR]" # Don't display the table if there's nothing been set up if connectionValidated(addon): if getCycleLock(): vpn_provider = addon.getSetting("vpn_provider_validated") # 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 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":
addon_name = getName() # Reset the ovpn files if action == "ovpn": if getVPNRequestedProfile() == "": if xbmcgui.Dialog().yesno(addon_name, "Resetting the VPN provider will disconnect and reset all VPN connections, and then remove any files that have been created. Continue?"): suspendConfigUpdate() # Disconnect so that live files are not being modified resetVPNConnections(addon) infoTrace("managefiles.py", "Resetting the VPN provider") # Delete the generated files, and reset the locations so it can be selected again removeGeneratedFiles() # Delete any values that have previously been validated vpn_provider = getVPNLocation(addon.getSetting("vpn_provider")) if isAlternative(vpn_provider): resetAlternative(vpn_provider) # Reset the IP service error counts, etc resetIPServices() addon = xbmcaddon.Addon(getID()) resetVPNProvider(addon) addon = xbmcaddon.Addon(getID()) resumeConfigUpdate() xbmcgui.Dialog().ok(addon_name, "Reset the VPN provider. Validate a connection to start using a VPN again.") else: xbmcgui.Dialog().ok(addon_name, "Connection to VPN being attempted and has been aborted. Try again in a few seconds.") setAPICommand("Disconnect") # Generate the VPN provider files if action == "generate": # Only used during development to create location files generateAll()
cancel_text = "[I][COLOR grey]Cancel[/COLOR][/I]" disconnect_text = "[COLOR ffff0000]Disconnect[/COLOR]" disconnected_text = "[COLOR ffff0000](Disconnected)[/COLOR]" # Don't display the table if there's nothing been set up if connectionValidated(addon): if getCycleLock(): vpn_provider = addon.getSetting("vpn_provider_validated") # 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 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")