Esempio n. 1
0
    def check_all(self):
        """
        check all drives
        """
        if rc.app():
            # Some app is running, do not scan, it's not necessary
            return

        self.lock.acquire()
        try:
            for media in config.REMOVABLE_MEDIA:
                last_status = media.drive_status
                self.identify(media)

                if last_status != media.drive_status:
                    _debug_('MEDIA: Status=%s' % media.drive_status, 2)
                    _debug_('Posting IDENTIFY_MEDIA event', 2)
                    if last_status == None:
                        rc.post_event(
                            plugin.event('IDENTIFY_MEDIA', arg=(media, True)))
                    else:
                        rc.post_event(
                            plugin.event('IDENTIFY_MEDIA', arg=(media, False)))
        finally:
            self.lock.release()
Esempio n. 2
0
 def _event_handler(self, event):
     logger.log(9, '_event_handler(event=%s), event.arg=%r, event.context=%r, PluginInterface.detached=%r', 
         event, event.arg, event.context, PluginInterface.detached)
     gui = audio.player.get()
     if gui:
         p = gui.player
         if event == BUTTON:
             if event.arg == 'FFWD':
                 p.eventhandler(Event('SEEK', arg='10', context='audio'))
             elif event.arg == 'REW':
                 p.eventhandler(Event('SEEK', arg='-10', context='audio'))
             elif event.arg == 'PAUSE':
                 p.eventhandler(Event('PLAY', context='audio'))
             elif event.arg == 'STOP':
                 PluginInterface.detached = False
                 p.eventhandler(Event('STOP'))
             elif event.arg == 'NEXT':
                 p.eventhandler(Event('PLAYLIST_NEXT', context='audio'))
             elif event.arg == 'PREV':
                 p.eventhandler(Event('PLAYLIST_PREV', context='audio'))
         elif plugin.isevent(event) == 'DETACH':
             p.eventhandler(event)
             self._detach()
         elif plugin.isevent(event) == 'ATTACH':
             self._attach()
             p.eventhandler(event)
         elif event == VIDEO_START:
             PluginInterface.detached = False
             p.eventhandler(Event('STOP'))
         elif event == PLAY_START and gui.visible:
             rc.post_event(plugin.event('ATTACH'))
Esempio n. 3
0
    def poll(self, menuw=None, arg=None):
        """
        poll to check for devices
        """
        changes = False

        current_devices = util.list_usb_devices()
        for d in current_devices:
            try:
                self.devices.remove(d)
            except ValueError:
                _debug_('new device %s' % (d))
                for device, message, action in config.USB_HOTPLUG:
                    if d == device:
                        pop = PopupBox(text=message)
                        pop.show()
                        os.system(action)
                        pop.destroy()
                        break
                else:
                    changes = True

        for d in self.devices:
            changes = True
            _debug_('removed device %s' % (d))

        if changes:
            rc.post_event(plugin.event('USB'))

        self.devices = current_devices
Esempio n. 4
0
    def poll(self, menuw=None, arg=None):
        """
        poll to check for devices
        """
        changes = False

        current_devices = util.list_usb_devices()
        for d in current_devices:
            try:
                self.devices.remove(d)
            except ValueError:
                logger.debug('new device %s', d)
                for device, message, action in config.USB_HOTPLUG:
                    if d == device:
                        pop = dialog.show_working_indicator(message)
                        os.system(action)
                        pop.hide()
                        break
                else:
                    changes = True

        for d in self.devices:
            changes = True
            logger.debug('removed device %s', d)

        if changes:
            rc.post_event(plugin.event('USB'))

        self.devices = current_devices
Esempio n. 5
0
    def poll(self, menuw=None, arg=None):
        """
        poll to check for devices
        """
        changes = False

        current_devices = util.list_usb_devices()
        for d in current_devices:
            try:
                self.devices.remove(d)
            except ValueError:
                logger.debug('new device %s', d)
                for device, message, action in config.USB_HOTPLUG:
                    if d == device:
                        pop = dialog.show_working_indicator(message)
                        os.system(action)
                        pop.hide()
                        break
                else:
                    changes = True

        for d in self.devices:
            changes = True
            logger.debug('removed device %s', d)

        if changes:
            rc.post_event(plugin.event('USB'))

        self.devices = current_devices
Esempio n. 6
0
 def check_all(self):
     """ Check all drives """
     if not skin.active():
         # Some app is running, do not scan, it's not necessary
         return
     self.lock.acquire()
     try:
         for media in config.REMOVABLE_MEDIA:
             self.identify(media)
             if media.get_drive_status_changed():
                 logger.debug('posting IDENTIFY_MEDIA event %r', media.drive_status_text(media.drive_status))
                 rc.post_event(plugin.event('IDENTIFY_MEDIA', arg=(media, media.drive_status)))
     finally:
         self.lock.release()
Esempio n. 7
0
    def check_all(self):
        """ Check all drives """
        if rc.app():
            # Some app is running, do not scan, it's not necessary
            return

        self.lock.acquire()
        try:
            for media in config.REMOVABLE_MEDIA:
                self.identify(media)
                if media.get_drive_status_changed():
                    _debug_('posting IDENTIFY_MEDIA event %r' % (media.drive_status_text(media.drive_status)))
                    rc.post_event(plugin.event('IDENTIFY_MEDIA', arg=(media, media.drive_status)))
        finally:
            self.lock.release()
Esempio n. 8
0
    def detach(self):
        _debug_('detach(self)', 2)
        gui = audio.player.get()

        # hide the player and show the menu
        mpav = plugin.getbyname('audio.mpav')
        if mpav:
            mpav.stop_mpav()

        mplvis = plugin.getbyname('audio.mplayervis')
        if mplvis:
            mplvis.stop_visual()

        gui.hide()
        gui.menuw.show()

        # set all menuw's to None to prevent the next title to be
        # visible again
        gui.menuw = None
        gui.item.menuw = None
        if gui.item.parent:
            gui.item.parent.menuw = None
        rc.post_event(plugin.event('DETACH'))
Esempio n. 9
0
 def attach(self):
     logger.debug('attach()')
     rc.post_event(plugin.event('ATTACH'))
Esempio n. 10
0
 def detach(self):
     logger.debug('detach()')
     rc.post_event(plugin.event('DETACH'))
Esempio n. 11
0
 def show(self, arg=None, menuw=None):
     logger.debug('show(arg=%r, menuw=%r)', arg, menuw)
     rc.post_event(plugin.event('ATTACH'))
     self._attach(menuw)
Esempio n. 12
0
 def poll(self, menuw=None, arg=None):
     active = self.switch.getActive()
     if active != self.previousActive:
         self.previousActive = active
         rc.post_event(plugin.event('UVSWITCH', active))