def topLevel(): # Build the top level menu with URL callbacks to this plugin debugTrace("Displaying the top level menu") url = base_url + "?settings" li = xbmcgui.ListItem("Add-on Settings", iconImage=getIconPath()+"settings.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) url = base_url + "?display" li = xbmcgui.ListItem("Display VPN status", iconImage=getIconPath()+"display.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) if addon.getSetting("vpn_system_menu_item") == "true": url = base_url + "?system" li = xbmcgui.ListItem("Display enhanced information", iconImage=getIconPath()+"enhanced.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) url = base_url + "?list" li = xbmcgui.ListItem("Change or disconnect VPN connection", iconImage=getIconPath()+"locked.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) url = base_url + "?cycle" li = xbmcgui.ListItem("Cycle through primary VPN connections", iconImage=getIconPath()+"cycle.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) url = base_url + "?switch" if isVPNMonitorRunning(): li = xbmcgui.ListItem("Pause add-on filtering", iconImage=getIconPath()+"paused.png") else: li = xbmcgui.ListItem("Restart add-on filtering", iconImage=getIconPath()+"play.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) xbmcplugin.endOfDirectory(addon_handle) return
def switchService(): debugTrace("Switching monitor state, current state is " + getVPNMonitorState()) if isVPNMonitorRunning(): setVPNMonitorState("Stopped") addon.setSetting("monitor_paused", "true") infoTrace("addon.py", "VPN monitor service paused") else: setVPNMonitorState("Started") addon.setSetting("monitor_paused", "false") infoTrace("addon.py", "VPN monitor service restarted") xbmc.executebuiltin('Container.Refresh') return
def listSystem(): lines = [] site, ip, country, isp = getIPInfo(addon) lines.append("[B][COLOR ff0099ff]Connection[/COLOR][/B]") if isVPNConnected(): lines.append("Connected using profile " + getVPNProfileFriendly()) lines.append("VPN provider is " + addon.getSetting("vpn_provider")) else: lines.append("Not connected to a VPN") lines.append("Connection location is " + country) lines.append("External IP address is " + ip) lines.append("Service Provider is " + isp) lines.append("Location sourced from " + site) lines.append("[B][COLOR ff0099ff]Network[/COLOR][/B]") lines.append("IP address is " + xbmc.getInfoLabel("Network.IPAddress")) lines.append("Gateway is " + xbmc.getInfoLabel("Network.GatewayAddress")) lines.append("Subnet mask is " + xbmc.getInfoLabel("Network.SubnetMask")) lines.append("Primary DNS is " + xbmc.getInfoLabel("Network.DNS1Address")) lines.append("Secondary DNS is " + xbmc.getInfoLabel("Network.DNS2Address")) lines.append("[B][COLOR ff0099ff]PureVPN monitor[/COLOR][/B]") lines.append("PureVPN monitor verison is " + addon.getAddonInfo("version")) lines.append("PureVPN monitor behaviour is " + getPlatformString()) if isVPNMonitorRunning(): lines.append("PureVPN monitor add-on split tunneling is playing") else: lines.append("PureVPN monitor add-on split tunneling is stopped") lines.append("[B][COLOR ff0099ff]System[/COLOR][/B]") lines.append("Kodi build version is " + xbmc.getInfoLabel("System.BuildVersion")) lines.append("System name is " + xbmc.getInfoLabel("System.FriendlyName")) lines.append("System date is " + xbmc.getInfoLabel("System.Date")) lines.append("System time is " + xbmc.getInfoLabel("System.Time")) lines.append("Platform is " + sys.platform) lines.append("Free memory is " + xbmc.getInfoLabel("System.FreeMemory")) lines.append("Disk is " + xbmc.getInfoLabel("System.TotalSpace") + ", " + xbmc.getInfoLabel("System.UsedSpace")) for line in lines: url = base_url + "?back" li = xbmcgui.ListItem(line, iconImage=getIconPath() + "enhanced.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) xbmcplugin.endOfDirectory(addon_handle) return
def listSystem(): lines = [] site, ip, country, isp = getIPInfo(addon) lines.append("[B][COLOR ff0099ff]Connection[/COLOR][/B]") if isVPNConnected(): lines.append("Connected using profile " + getVPNProfileFriendly()) lines.append("VPN provider is " + addon.getSetting("vpn_provider")) else: lines.append("Not connected to a VPN") lines.append("Connection location is " + country) lines.append("External IP address is " + ip) lines.append("Service Provider is " + isp) lines.append("Location sourced from " + site) lines.append("[B][COLOR ff0099ff]Network[/COLOR][/B]") lines.append("IP address is " + xbmc.getInfoLabel("Network.IPAddress")) lines.append("Gateway is " + xbmc.getInfoLabel("Network.GatewayAddress")) lines.append("Subnet mask is " + xbmc.getInfoLabel("Network.SubnetMask")) lines.append("Primary DNS is " + xbmc.getInfoLabel("Network.DNS1Address")) lines.append("Secondary DNS is " + xbmc.getInfoLabel("Network.DNS2Address")) lines.append("[B][COLOR ff0099ff]VPN Manager[/COLOR][/B]") lines.append("VPN Manager verison is " + addon.getAddonInfo("version")) lines.append("VPN Manager behaviour is " + getPlatformString()) if isVPNMonitorRunning(): lines.append("VPN Manager add-on filtering is running") else: lines.append("VPN Manager add-on filtering is paused") lines.append("[B][COLOR ff0099ff]System[/COLOR][/B]") lines.append("Kodi build version is " + xbmc.getInfoLabel("System.BuildVersion")) lines.append("System name is " + xbmc.getInfoLabel("System.FriendlyName")) lines.append("System date is " + xbmc.getInfoLabel("System.Date")) lines.append("System time is " + xbmc.getInfoLabel("System.Time")) lines.append("Platform is " + sys.platform) lines.append("Free memory is " + xbmc.getInfoLabel("System.FreeMemory")) lines.append("Disk is " + xbmc.getInfoLabel("System.TotalSpace") + ", " + xbmc.getInfoLabel("System.UsedSpace")) for line in lines: url = base_url + "?back" li = xbmcgui.ListItem(line, iconImage=getIconPath()+"enhanced.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) xbmcplugin.endOfDirectory(addon_handle) return
setVPNRequestedProfileFriendly(getVPNProfileFriendly()) setVPNProfile("") setVPNProfileFriendly("") reconnect_vpn = True timer = 0 # Fetch the path and name of the current addon current_path = xbmc.getInfoLabel('Container.FolderPath') current_name = xbmc.getInfoLabel('Container.FolderName') # See if it's a different add-on the last time we checked. If we don't know the # current_name (like when the player is playing within an addon), then skip making a change. #print "Current path = " + current_path #print "Current name = " + current_name if vpn_setup and not (xbmcgui.Window(10000).getProperty(last_addon) == current_name) and not current_name == "": if isVPNMonitorRunning(): # If the monitor is stopped, we want to warn warned_monitor = False debugTrace("Encountered a new addon, " + current_path + " " + current_name) debugTrace("Previous addon was " + (xbmcgui.Window(10000).getProperty(last_addon))) # Update window property to current addon xbmcgui.Window(10000).setProperty(last_addon, current_name) # Work out if we're using a primary VPN so if we have multiple filters # and one of them is current we don't switch unncessarily primary_found = 0 # # Adjust 10 below if changing number of conn_max for i in range(0, 10): if not primary_vpns[i] == "" and getVPNProfile( ) == primary_vpns[i]:
# the timer in the loop (which seems to drift/take longer depending on what's going on) if seconds_to_reboot_check > 3600: seconds_to_reboot_check = 3600 debugTrace("Same day reboot, check again in " + str(seconds_to_reboot_check)) else: # Reboot on a different day, check status again in an hour. setReboot("waiting") # Fetch the path and name of the current addon current_path = xbmc.getInfoLabel("Container.FolderPath") current_name = xbmc.getInfoLabel("Container.FolderName") # See if it's a different add-on the last time we checked. If we don't know the # current_name (like when the player is playing within an addon), then skip making a change. #print "Current path = " + current_path #print "Current name = " + current_name if vpn_setup and not (xbmcgui.Window(10000).getProperty(last_addon) == current_name) and not current_name == "": if isVPNMonitorRunning(): # If the monitor is paused, we want to warn warned_monitor = False debugTrace("Encountered a new addon, " + current_path + " " + current_name) debugTrace("Previous addon was " + (xbmcgui.Window(10000).getProperty(last_addon))) # Update window property to current addon xbmcgui.Window(10000).setProperty(last_addon, current_name) # Work out if we're using a primary VPN so if we have multiple filters # and one of them is current we don't switch unncessarily primary_found = 0 # # Adjust 10 below if changing number of conn_max for i in range (0, 10): if not primary_vpns[i] == "" and getVPNProfile() == primary_vpns[i]: primary_found = i+1 # See if we should be filtering this addon # -1 is no, 0 is disconnect, >0 is specific VPN
def topLevel(): xbmc.executebuiltin("ActivateWindow(busydialog)") # Build the top level menu with URL callbacks to this plugin addon = xbmcaddon.Addon("service.purevpn.monitor") vpn_provider = addon.getSetting("vpn_provider") debugTrace("Displaying the top level menu") try: url = base_url + "?disconnect" if getVPNProfileFriendly() != "": li = xbmcgui.ListItem("[COLOR ffff0000]Disconnect[/COLOR]", iconImage=getIconPath() + "unlocked.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) except: pass url = base_url + "?display" li = xbmcgui.ListItem("Display VPN status", iconImage=getIconPath() + "display.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) url = base_url + "?list" if getVPNProfileFriendly() == "": li = xbmcgui.ListItem("Connect to Country", iconImage=getIconPath() + "locked.png") else: li = xbmcgui.ListItem("Change Country", iconImage=getIconPath() + "locked.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) url = base_url + "?switch" if isVPNMonitorRunning(): li = xbmcgui.ListItem("Stop Split tunneling", iconImage=getIconPath() + "paused.png") else: li = xbmcgui.ListItem("Play Split tunneling", iconImage=getIconPath() + "play.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) url = base_url + "?settings" li = xbmcgui.ListItem("Add-on Settings", iconImage=getIconPath() + "settings.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) if createUpdateChecker(): addonname = 'PureVPN' response = "PureVPN's Kodi Add-on has a new update. Please download the update from www.purevpn.com/kodi-addon" xbmcgui.Dialog().ok(addonname, response) if addon.getSetting("vpn_system_menu_item") == "true": url = base_url + "?system" li = xbmcgui.ListItem("Display enhanced information", iconImage=getIconPath() + "enhanced.png") xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) xbmcplugin.endOfDirectory(addon_handle) updateService() createUnPass() xbmc.executebuiltin("Dialog.Close(busydialog)") return