def __init__(self): """ Create lister for XBMC notifications """ XplPlugin.__init__(self, name='xbmc_not') # Create logger self.log.debug("Listener for XBMC notifications created") # Get configuration self._config = Query(self.myxpl, self.log) address = self._config.query('xbmc_not', 'address') delay = self._config.query('xbmc_not', 'delay') maxdelay = self._config.query('xbmc_not', 'maxdelay') self.log.debug("Config : address = " + address) self.log.debug("Config : delay = " + delay) self.log.debug("Config : maxdelay = " + maxdelay) # Create XBMCNotification object self.xbmc_notification_manager = XBMCNotification(self.log, address, delay, \ maxdelay) # Create listeners Listener(self.xbmc_notification_cb, self.myxpl, { 'schema': 'osd.basic', 'xpltype': 'xpl-cmnd' }) self.enable_hbeat() self.enable_hbeat()
class XBMCNotificationListener(XplPlugin): """ Create listener for xPL messages about xbmc notifications """ def __init__(self): """ Create lister for XBMC notifications """ XplPlugin.__init__(self, name='xbmc_not') # Create logger self.log.debug("Listener for XBMC notifications created") # Get configuration self._config = Query(self.myxpl, self.log) address = self._config.query('xbmc_not', 'address') delay = self._config.query('xbmc_not', 'delay') maxdelay = self._config.query('xbmc_not', 'maxdelay') self.log.debug("Config : address = " + address) self.log.debug("Config : delay = " + delay) self.log.debug("Config : maxdelay = " + maxdelay) # Create XBMCNotification object self.xbmc_notification_manager = XBMCNotification(self.log, address, delay, \ maxdelay) # Create listeners Listener(self.xbmc_notification_cb, self.myxpl, { 'schema': 'osd.basic', 'xpltype': 'xpl-cmnd' }) self.enable_hbeat() self.enable_hbeat() def xbmc_notification_cb(self, message): """ Call XBMC notification lib @param message : message to send """ self.log.debug("Call xbmc_notification_cb") if 'command' in message.data: command = message.data['command'] if 'text' in message.data: text = message.data['text'] if 'row' in message.data: row = message.data['row'] if 'delay' in message.data: delay = message.data['delay'] self.log.debug("Call _notify") self.xbmc_notification_manager.notify(command, text, row, delay)