vpnapi.py 文件源码

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

项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码
def filterAndSwitch(self, path, windowid, default, wait):
        # Given a path to an addon, and/or a window ID, determine if it's associated with a particular VPN and
        # switch to that VPN.  Return True when the switch has happened or False if there's a problem switching 
        # (or there's no VPN that's been set up).  If the connected VPN is the VPN that's been identifed as being 
        # required, or no filter is found, just return True without messing with the connection.  The default 
        # parameter is a boolean indicating if the default VPN should be connected to if no filter is found.
        # The wait parameter will determine if the function returns once the connection has been made, or if it's 
        # fire and forget (in which case True will be returned regardless).  
        if not self.isVPNSetUp():
            return False
        connection = self.isFiltered(path, windowid)
        # Switch to the default connection if there's no filter
        if connection == -1 and default : 
            xbmc.log(msg="VPN Mgr API : Reconnecting to the default", level=xbmc.LOGDEBUG)
            return self.defaultVPN(wait)
        if connection == 0:
            if self.getConnected() == "": return True
            xbmc.log(msg="VPN Mgr API : Disconnecting due to filter " + path + " or window ID " + str(windowid), level=xbmc.LOGDEBUG)
            self.setAPICommand("Disconnect")
            if wait: return self.waitForConnection("")
        if connection > 0:
            connection = connection - 1
            if self.primary_vpns[connection] == "": return False
            if self.getConnected() == self.primary_vpns[connection]: return True
            xbmc.log(msg="VPN Mgr API : Connecting to " + self.primary_vpns[connection] + " due to filter " + path + " or window ID " + str(windowid), level=xbmc.LOGDEBUG)
            self.setAPICommand(self.primary_vpns[connection])
            if wait: return self.waitForConnection(self.primary_vpns[connection])
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号