# 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 + "\n" + "Pausing VPN monitor..." + "\n\n") xbmc.sleep(100)
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( "Connecting to primary VPN at boot time")
try: from libs.generation import generateAll except: pass action = sys.argv[1] debugTrace("-- Entered managefiles.py with parameter " + action + " --") if not getID() == "": addon = xbmcaddon.Addon(getID()) 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 if isVPNConnected(): 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()
# 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])
debugTrace("-- Entered resetVPN.py --") if not getID() == "": # 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")
except: pass action = sys.argv[1] debugTrace("-- Entered managefiles.py with parameter " + action + " --") if not getID() == "": addon = xbmcaddon.Addon(getID()) 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())