def listConnections(): # 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 vpn_provider != "": # Get the list of connections and add them to the directory all_connections = getProfileList(vpn_provider) ovpn_connections = getFilteredProfileList( all_connections, addon.getSetting("vpn_protocol"), None) connections = getFriendlyProfileList(vpn_provider, ovpn_connections) inc = 0 for connection in ovpn_connections: url = base_url + "?change?" + ovpn_connections[inc] conn_text = "" conn_primary = "" if getVPNProfileFriendly() == connections[inc] and isVPNConnected( ): conn_text = "[COLOR ff00ff00]" + connections[ inc] + conn_primary + " (Connected)[/COLOR]" icon = getIconPath() + "connected.png" else: conn_text = connections[inc] + conn_primary icon = getIconPath() + "locked.png" li = xbmcgui.ListItem(conn_text, iconImage=icon) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) inc = inc + 1 xbmcplugin.endOfDirectory(addon_handle) 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 listConnections(): # Start with the disconnect option url = base_url + "?disconnect" if getVPNProfileFriendly() == "": li = xbmcgui.ListItem("[COLOR ffff0000](Disconnected)[/COLOR]", iconImage=getIconPath() + "disconnected.png") else: li = xbmcgui.ListItem("[COLOR ffff0000]Disconnect[/COLOR]", iconImage=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 vpn_provider != "": # Get the list of connections and add them to the directory all_connections = getAddonList(vpn_provider, "*.ovpn") ovpn_connections = getFilteredProfileList( all_connections, addon.getSetting("vpn_protocol"), None) connections = getFriendlyProfileList(ovpn_connections, "", "") inc = 0 for connection in ovpn_connections: url = base_url + "?change?" + ovpn_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]: conn_primary = " (" + str(i) + ")" i = 10 i = i + 1 if getVPNProfileFriendly() == connections[inc] 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, iconImage=icon) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) inc = inc + 1 xbmcplugin.endOfDirectory(addon_handle) return
def listSystem(addon): lines = getSystemData(addon, True, True, True, True) 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(addon): lines = getSystemData(addon, True, True, True, True) 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 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 listConnections(): # Start with the disconnect option url = base_url + "?disconnect" if getVPNProfileFriendly() == "": li = xbmcgui.ListItem("[COLOR ffff0000](Disconnected)[/COLOR]", iconImage=getIconPath()+"disconnected.png") else: li = xbmcgui.ListItem("[COLOR ffff0000]Disconnect[/COLOR]", iconImage=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 vpn_provider != "": # Get the list of connections and add them to the directory all_connections = getAddonList(vpn_provider, "*.ovpn") ovpn_connections = getFilteredProfileList(all_connections, addon.getSetting("vpn_protocol"), None) connections = getFriendlyProfileList(ovpn_connections) inc = 0 for connection in ovpn_connections: url = base_url + "?change?" + ovpn_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] : conn_primary = " (" + str(i) + ")" i = 10 i=i+1 if getVPNProfileFriendly() == connections[inc] and isVPNConnected(): conn_text = "[COLOR ff00ff00]" + connections[inc] + conn_primary + " (Connected)[/COLOR]" 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, iconImage=icon) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) inc = inc + 1 xbmcplugin.endOfDirectory(addon_handle) return
def defCred(): addon = xbmcaddon.Addon("service.purevpn.monitor") fd = open(getIconPath()+"settings.xml", 'r') if fd: debugTrace("Opening settings.xml") fd2 = open(getIconPath()+"settings.xml.bak", 'w') vpn_username = addon.getSetting("vpn_username") vpn_password = addon.getSetting("vpn_password") # Searching for the lines having username and password in settings.xml and keeping the lines unchanged. for line in fd: if "id=\"vpn_username\"" in line: line = " <setting label=\"32004\" type=\"text\" id=\"vpn_username\" default=\"" + vpn_username + "\"/>\n" elif "id=\"vpn_password\"" in line: line = " <setting label=\"32005\" type=\"text\" id=\"vpn_password\" option=\"hidden\" default=\"" + vpn_password + "\"/>\n" fd2.write(line) fd2.close() fd.close() #os.remove(getIconPath()+"settings.xml") shutil.copy(getIconPath()+"settings.xml.bak", getIconPath()+"settings.xml") else: debugTrace("Error opening settings.xml")
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
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