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 allowReconnection(vpn_provider) and not addon.getSetting( "allow_cycle_reconnect") == "true": displayStatus() else: connectVPN("0", ovpn_connection) return
title = "Connected - " + getVPNProfileFriendly() connections.insert(0, disconnect_text) else: title = "Disconnected" connections.insert(0, disconnected_text) connections.append(cancel_text) i = xbmcgui.Dialog().select(title, connections) if connections[i] == disconnect_text or connections[i] == disconnected_text: setAPICommand("Disconnect") elif not connections[i] == cancel_text: if getVPNProfile() == location_connections[i-1] and (allowReconnection(vpn_provider) or addon.getSetting("allow_cycle_reconnect") == "true"): setAPICommand("Reconnect") else: if isAlternative(vpn_provider) and addon.getSetting("table_display_type") == "All connections": _, connection, user_text, ignore = getAlternativeLocation(vpn_provider, connections[i], 0, True) if not ignore and not user_text == "": xbmcgui.Dialog().ok(addon_name, user_text) else: connection = location_connections[i-1] if not connection == "": setAPICommand(connection) freeCycleLock() else: xbmcgui.Dialog().notification(addon_name, "VPN is not set up and authenticated.", xbmcgui.NOTIFICATION_ERROR, 10000, True) else: errorTrace("table.py", "VPN service is not ready") debugTrace("-- Exit table.py --")