common.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:service.vpn.manager 作者: Zomboided 项目源码 文件源码
def wizard():
    addon = xbmcaddon.Addon("service.vpn.manager")
    addon_name = addon.getAddonInfo("name")    

    # Indicate the wizard has been run, regardless of if it is to avoid asking again
    addon.setSetting("vpn_wizard_run", "true")

    # Wizard or settings?
    if xbmcgui.Dialog().yesno(addon_name, "No primary VPN connection has been set up.  Would you like to do this using the set up wizard or using the Settings dialog?", "", "", "Settings", "Wizard"):

        # Select the VPN provider
        provider_list = list(provider_display)
        provider_list.sort()
        vpn = xbmcgui.Dialog().select("Select your VPN provider.", provider_list)
        vpn = provider_display.index(provider_list[vpn])
        vpn_provider = provider_display[vpn]

        success = True
        # If User Defined VPN then offer to run the wizard
        if isUserDefined(vpn_provider):
            success = importWizard()        

        if success:
            # Get the username and password
            vpn_username = ""
            vpn_password = ""
            if usesPassAuth(vpn_provider):
                vpn_username = xbmcgui.Dialog().input("Enter your " + vpn_provider + " username.", type=xbmcgui.INPUT_ALPHANUM)
                if not vpn_username == "":
                    vpn_password = xbmcgui.Dialog().input("Enter your " + vpn_provider + " password.", type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT)

            # Try and connect if we've gotten all the data
            if (not usesPassAuth(vpn_provider)) or (not vpn_password == ""):
                addon.setSetting("vpn_provider", vpn_provider)
                addon.setSetting("vpn_username", vpn_username)
                addon.setSetting("vpn_password", vpn_password)
                connectVPN("1", vpn_provider)
                # Need to reinitialise addon here for some reason...
                addon = xbmcaddon.Addon("service.vpn.manager")
                if connectionValidated(addon):
                    xbmcgui.Dialog().ok(addon_name, "Successfully connected to " + vpn_provider + ".  Use the Settings dialog to add additional VPN connections.  You can also define add-on filters to dynamically change the VPN connection being used.")
                else:
                    xbmcgui.Dialog().ok(addon_name, "Could not connect to " + vpn_provider + ".  Use the Settings dialog to correct any issues and try connecting again.")

            else:
                xbmcgui.Dialog().ok(addon_name, "You need to enter both a VPN username and password to connect.")
        else:
            xbmcgui.Dialog().ok(addon_name, "There was a problem setting up the User Defined provider.  Fix any issues and run the wizard again from the VPN Configuration tab.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号