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
# 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": title = "Connected - " + getVPNProfileFriendly() connections.insert(0, disconnect_text) else: title = "Disconnected" connections.insert(0, disconnected_text)