Ejemplo n.º 1
0
    def _on_exit(self):
        if self.xbmc_monitor.abortRequested():
            del self.xbmc_monitor
            return

        # Clear our properties
        self.reset_properties()

        # Close video info dialog
        if window.is_visible(ID_VIDEOINFO):
            window.close(ID_VIDEOINFO)
            window.wait_until_active(ID_VIDEOINFO, invert=True, poll=0.1)

        # Close base window
        if window.is_visible(self.window_id):
            xbmc.executebuiltin('Action(Back)')
            window.wait_until_active(self.window_id, invert=True, poll=0.1)

        # If we don't have the return param then try to re-open original info
        if self.return_info and not self.params.get('return'):
            if window.wait_until_active(self.window_id, invert=True, poll=0.1, timeout=1):
                xbmc.executebuiltin('Action(Info)')

        # Clear our instance property because we left
        window.get_property(PREFIX_INSTANCE, clear_property=True)
Ejemplo n.º 2
0
    def event_loop(self):
        window.wait_for_property(PREFIX_INSTANCE, 'True', True)
        while not self.xbmc_monitor.abortRequested() and not self.exit:
            # Path added so let's put it in the queue
            if window.get_property(PREFIX_ADDPATH):
                self._on_add()

            # Exit called so let's exit
            elif window.get_property(PREFIX_COMMAND) == 'exit':
                self._call_exit()

            # Path changed so let's update
            elif self.current_path != self.added_path:
                self._on_change()
                self.xbmc_monitor.waitForAbort(0.5)

            # User force quit so let's exit
            elif not window.is_visible(self.window_id):
                self._call_exit()

            # User pressed back and closed video info window
            elif not window.is_visible(ID_VIDEOINFO):
                self._on_back()
                self.xbmc_monitor.waitForAbort(0.5)

            # Nothing happened this round so let's loop and wait
            else:
                self.xbmc_monitor.waitForAbort(0.5)

        self._on_exit()
Ejemplo n.º 3
0
    def call_auto(self):
        if window.get_property(PREFIX_INSTANCE):
            # Already instance running and has window open so let's exit
            if window.is_visible(self.window_id):
                return
            # Do some clean-up because we didn't exit cleanly last time
            window.get_property(PREFIX_INSTANCE, clear_property=True)
            self.reset_properties()

        # Start up our service to monitor the windows
        return self.event_loop()
Ejemplo n.º 4
0
    def _on_change(self):
        # On first run the base window won't be open yet so don't check for it
        base_id = None if self.first_run else self.window_id

        # Close the info dialog first before doing anything
        if window.is_visible(ID_VIDEOINFO):
            window.close(ID_VIDEOINFO)

            # If we timeout or user forced back out of base window then we exit
            if not window.wait_until_active(ID_VIDEOINFO, base_id,
                                            invert=True):
                return self._call_exit()

        # On last position let's exit
        if self.position == 0:
            return self._call_exit(True)

        # On first run let's open our base window
        if self.first_run:
            window.activate(self.window_id)
            if not window.wait_until_active(self.window_id, poll=0.5):
                return self._call_exit()

        # Set our base window
        base_window = xbmcgui.Window(self.kodi_id)

        # Check that base window has correct control ID and clear it out
        control_list = base_window.getControl(CONTAINER_ID)
        if not control_list:
            kodi_log(
                u'SKIN ERROR!\nControl {} unavailable in Window {}'.format(
                    CONTAINER_ID, self.window_id), 1)
            return self._call_exit()
        control_list.reset()

        # Wait for the container to update before doing anything
        if not window.wait_until_updated(container_id=CONTAINER_ID,
                                         instance_id=self.window_id):
            return self._call_exit()

        # Open the info dialog
        base_window.setFocus(control_list)
        xbmc.executebuiltin(u'SetFocus({},0,absolute)'.format(CONTAINER_ID))
        xbmc.executebuiltin('Action(Info)')
        if not window.wait_until_active(ID_VIDEOINFO, self.window_id):
            return self._call_exit()

        # Set current_path to added_path because we've now updated everything
        # Set first_run to False because we've now finished our first run through
        self.current_path = self.added_path
        self.first_run = False