def deactivate(cls, pname): cls.verboseLog( cls._tr("Deactivating plugin {name}").format(name=pname), "pyTSon.PluginHost.deactivate") if pname in cls.active: try: # remove hotkeys for key in cls.hotkeys: if cls.hotkeys[key][0].name == pname: cls.hotkeys[key] = (pname, cls.hotkeys[key][1]) # remove menuItems for key in cls.menus: if type(cls.menus[key][0]) is not str: if cls.menus[key][0].name == pname: cls.menus[key] = (pname, cls.menus[key][1]) ts3lib.setPluginMenuEnabled(key, False) cls.active[pname].stop() del cls.active[pname] cls.cfg.set("plugins", pname, "False") except: logprint( cls._tr("Error stopping python plugin {name}: " "{trace}").format(name=pname, trace=traceback.format_exc()), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon.PluginHost.deactivate")
def deactivateMenus(): for key, val in menustates: ts3lib.setPluginMenuEnabled(key, val) for key, p in cls.active.items(): if hasattr(p, "menuCreated"): p.menuCreated()
def toggleMenus(self, enabled): for menuItem in self.menuItems: try: ts3lib.setPluginMenuEnabled( PluginHost.globalMenuID(self, menuItem[1]), enabled) except: pass
def activate(cls, pname): cls.verboseLog( cls._tr("Activating plugin {name}").format(name=pname), "pyTSon.PluginHost.activate") if pname in cls.plugins: try: cls.active[pname] = cls.plugins[pname]() cls.cfg.set("plugins", pname, "True") for globid, (p, locid) in cls.menus.items(): if type(p) is str and p == pname: cls.menus[globid] = (cls.active[p], locid) ts3lib.setPluginMenuEnabled(globid, True) if hasattr(cls.active[pname], "menuCreated"): cls.active[pname].menuCreated() for keyword, (p, lockey) in cls.hotkeys.items(): if type(p) is str and p == pname: cls.hotkeys[keyword] = (cls.active[p], lockey) return True except: logprint( cls._tr("Error starting python plugin {name}: " "{trace}").format(name=pname, trace=traceback.format_exc()), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon.PluginHost.activate") return False
def deactivateMenus(): for key, val in menustates: ts3lib.setPluginMenuEnabled(key, val) for key, p in cls.active.items(): if hasattr(p, "menuCreated"): p.menuCreated()
def deactivate(cls, pname): cls.verboseLog(cls._tr("Deactivating plugin {name}"). format(name=pname), "pyTSon.PluginHost.deactivate") if pname in cls.active: try: # remove hotkeys for key in cls.hotkeys: if type(cls.hotkeys[key][0]) is not str: if cls.hotkeys[key][0].name == pname: cls.hotkeys[key] = (pname, cls.hotkeys[key][1]) # remove menuItems for key in cls.menus: if type(cls.menus[key][0]) is not str: if cls.menus[key][0].name == pname: cls.menus[key] = (pname, cls.menus[key][1]) ts3lib.setPluginMenuEnabled(key, False) cls.active[pname].stop() del cls.active[pname] cls.cfg.set("plugins", pname, "False") except: logprint(cls._tr("Error stopping python plugin {name}: " "{trace}").format(name=pname, trace=traceback. format_exc()), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon.PluginHost.deactivate")
def activate(cls, pname): cls.verboseLog(cls._tr("Activating plugin {name}").format(name=pname), "pyTSon.PluginHost.activate") if pname in cls.plugins: try: cls.active[pname] = cls.plugins[pname]() cls.cfg.set("plugins", pname, "True") for globid, (p, locid) in cls.menus.items(): if type(p) is str and p == pname: cls.menus[globid] = (cls.active[p], locid) ts3lib.setPluginMenuEnabled(globid, True) if hasattr(cls.active[pname], "menuCreated"): cls.active[pname].menuCreated() for keyword, (p, lockey) in cls.hotkeys.items(): if type(p) is str and p == pname: cls.hotkeys[keyword] = (cls.active[p], lockey) return True except: logprint(cls._tr("Error starting python plugin {name}: " "{trace}").format(name=pname, trace=traceback.format_exc()), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon.PluginHost.activate") return False
def menuCreated(self): if not self.name in PluginHost.active: return for id in [0, 10]: try: ts3lib.setPluginMenuEnabled(PluginHost.globalMenuID(self, id), False) except: pass
def checkServer(self, schid=0, status=None): if schid < 1: schid = ts3lib.getCurrentServerConnectionHandlerID() if status is None: (err, status) = ts3lib.getConnectionStatus(schid) if status == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: status = True elif status == ts3defines.ConnectStatus.STATUS_DISCONNECTED: status = False else: return for menuItem in self.menuItems: try: ts3lib.setPluginMenuEnabled( PluginHost.globalMenuID(self, menuItem[1]), status) except: pass
def checkServer(self): if self.schid > 0: (err, status) = ts3lib.getConnectionStatus(self.schid) else: status = ts3defines.ConnectStatus.STATUS_DISCONNECTED try: if status == ts3defines.ConnectStatus.STATUS_DISCONNECTED: ts3lib.setPluginMenuEnabled(PluginHost.globalMenuID(self, self.menuItems[0][1]), True) ts3lib.setPluginMenuEnabled(PluginHost.globalMenuID(self, self.menuItems[1][1]), False) elif status == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: ts3lib.setPluginMenuEnabled(PluginHost.globalMenuID(self, self.menuItems[0][1]), False) ts3lib.setPluginMenuEnabled(PluginHost.globalMenuID(self, self.menuItems[1][1]), True) except: pass