예제 #1
0
    def Dialog_Select_Large(self, title, subject, items):
        self.selected = None

        def callback(selected):
            self.selected = selected
            self.dialog.close()

        self.dialog = DialogSelect("%s %s" % (GetLocalizedString(title), subject), items=items, callback=callback)
        self.dialog.doModal()
        del self.dialog

        return self.selected
예제 #2
0
    def Dialog_Select_Large(self, title, subject, items):
        self.selected = None

        def callback(selected):
            self.selected = selected
            self.dialog.close()

        self.dialog = DialogSelect("%s %s" % (GetLocalizedString(title), subject), items=items, callback=callback)
        self.dialog.doModal()
        del self.dialog

        return self.selected
예제 #3
0
class QuasarRPCServer(BaseHandler):
    public_methods_pattern = r'^[A-Za-z]\w+$'

    _objects = {}

    def Reset(self):
        for i in self._objects:
            try:
                self._objects[i].hide()
            except:
                pass
        log.info("Resetting RPC objects...")
        self._objects = {}

    def Refresh(self):
        return xbmc.executebuiltin("Container.Refresh")

    def UpdateAddonRepos(self):
        return xbmc.executebuiltin("UpdateAddonRepos")

    def SystemInformation(self):
        return system_information()

    def Notify(self, header, message, image):
        return notify(GetLocalizedString(message), header, 3000, image)

    def Keyboard(self, default="", heading="", hidden=False):
        keyboard = xbmc.Keyboard(default, GetLocalizedString(heading), hidden)
        keyboard.doModal()
        if keyboard.isConfirmed():
            return keyboard.getText()

    def Dialog_Select(self, title, items):
        dialog = xbmcgui.Dialog()
        return dialog.select(GetLocalizedString(title), items)

    def Dialog_Select_Large(self, title, subject, items):
        self.selected = None

        def callback(selected):
            self.selected = selected
            self.dialog.close()

        self.dialog = DialogSelect("%s %s" % (GetLocalizedString(title), subject), items=items, callback=callback)
        self.dialog.doModal()
        del self.dialog

        return self.selected

    def Player_GetPlayingFile(self, *args, **kwargs):
        return XBMC_PLAYER.getPlayingFile()

    def Player_IsPlaying(self, *args, **kwargs):
        return XBMC_PLAYER.isPlaying(*args, **kwargs)

    def Player_IsPaused(self):
        return xbmc.getCondVisibility("Player.Paused")

    def ConvertLanguage(self, *args, **kwargs):
        return xbmc.convertLanguage(*args, **kwargs)

    def GetPlatform(self):
        return PLATFORM

    def GetAddonInfo(self):
        info = {}
        for key in ("author", "changelog", "description", "disclaimer",
                    "fanart", "icon", "id", "name", "path", "profile", "stars",
                    "summary", "type", "version"):
            info[key] = ADDON.getAddonInfo(key)
        return info

    def GetLanguage(self, *args, **kwargs):
        return xbmc.getLanguage(*args, **kwargs)

    def GetLocalizedString(self, *args, **kwargs):
        return ADDON.getLocalizedString(*args, **kwargs).encode('utf-8')

    def GetSetting(self, *args, **kwargs):
        return ADDON.getSetting(*args, **kwargs)

    def SetSetting(self, *args, **kwargs):
        return ADDON.setSetting(*args, **kwargs)

    def TranslatePath(self, *args, **kwargs):
        return xbmc.translatePath(*args, **kwargs)

    def Log(self, *args, **kwargs):
        return xbmc.log(*args, **kwargs)

    def Dialog_CloseAll(self, *args, **kwargs):
        return xbmc.executebuiltin("Dialog.Close(all, true)")

    def InsertTorrent(self, *args, **kwargs):
        window = InsertTorrent("InsertTorrent.xml", ADDON_PATH, "Default")
        window.doModal()
        retval = {"type": ("cancelled", "url", "file")[window.type], "path": window.retval}
        del window
        return retval

    ###########################################################################
    # DialogProgress
    ###########################################################################
    def DialogProgress_Create(self, *args, **kwargs):
        dialog = xbmcgui.DialogProgress()
        self._objects[id(dialog)] = dialog
        dialog.create(*args, **kwargs)
        return id(dialog)

    def DialogProgress_IsCanceled(self, hwnd, *args, **kwargs):
        return self._objects[hwnd].iscanceled(*args, **kwargs)

    def DialogProgress_Update(self, hwnd, *args, **kwargs):
        return self._objects[hwnd].update(*args, **kwargs)

    def DialogProgress_Close(self, hwnd, *args, **kwargs):
        dialog = self._objects.pop(hwnd)
        dialog.close()
        del dialog

    # Background DialogProgress
    def DialogProgressBG_Create(self, *args, **kwargs):
        dialog = xbmcgui.DialogProgressBG()
        self._objects[id(dialog)] = dialog
        dialog.create(*args, **kwargs)
        return id(dialog)

    def DialogProgressBG_IsFinished(self, hwnd, *args, **kwargs):
        return self._objects[hwnd].isFinished(*args, **kwargs)

    def DialogProgressBG_Update(self, hwnd, *args, **kwargs):
        return self._objects[hwnd].update(*args, **kwargs)

    def DialogProgressBG_Close(self, hwnd, *args, **kwargs):
        dialog = self._objects.pop(hwnd)
        dialog.close()
        del dialog

    # Overlay status
    def OverlayStatus_Create(self):
        overlay = OverlayText()
        overlayId = id(overlay)
        self._objects[overlayId] = overlay
        return overlayId

    def OverlayStatus_Update(self, hwnd, percent, line1, line2, line3):
        text = "\n".join([line1, line2, line3])
        self._objects[hwnd].text = text

    def OverlayStatus_Show(self, hwnd):
        self._objects[hwnd].show()

    def OverlayStatus_Hide(self, hwnd):
        self._objects[hwnd].hide()

    def OverlayStatus_Close(self, hwnd):
        overlay = self._objects.pop(hwnd)
        overlay.hide()
        del overlay
예제 #4
0
class QuasarRPCServer(BaseHandler):
    public_methods_pattern = r'^[A-Za-z]\w+$'

    _objects = {}

    def Reset(self):
        for i in self._objects:
            try:
                self._objects[i].hide()
            except:
                pass
        log.info("Resetting RPC objects...")
        self._objects = {}

    def UpdateAddonRepos(self):
        return xbmc.executebuiltin("UpdateAddonRepos")

    def SystemInformation(self):
        return system_information()

    def Notify(self, header, message, image):
        return notify(GetLocalizedString(message), header, 3000, image)

    def Keyboard(self, default="", heading="", hidden=False):
        keyboard = xbmc.Keyboard(default, GetLocalizedString(heading), hidden)
        keyboard.doModal()
        if keyboard.isConfirmed():
            return keyboard.getText()

    def Dialog_Select(self, title, items):
        dialog = xbmcgui.Dialog()
        return dialog.select(GetLocalizedString(title), items)

    def Dialog_Select_Large(self, title, subject, items):
        self.selected = None

        def callback(selected):
            self.selected = selected
            self.dialog.close()

        self.dialog = DialogSelect("%s %s" % (GetLocalizedString(title), subject), items=items, callback=callback)
        self.dialog.doModal()
        del self.dialog

        return self.selected

    def Player_GetPlayingFile(self, *args, **kwargs):
        return XBMC_PLAYER.getPlayingFile()

    def Player_IsPlaying(self, *args, **kwargs):
        return XBMC_PLAYER.isPlaying(*args, **kwargs)

    def Player_IsPaused(self):
        return xbmc.getCondVisibility("Player.Paused")

    def ConvertLanguage(self, *args, **kwargs):
        return xbmc.convertLanguage(*args, **kwargs)

    def GetPlatform(self):
        return PLATFORM

    def GetAddonInfo(self):
        info = {}
        for key in ("author", "changelog", "description", "disclaimer",
                    "fanart", "icon", "id", "name", "path", "profile", "stars",
                    "summary", "type", "version"):
            info[key] = ADDON.getAddonInfo(key)
        return info

    def GetLanguage(self, *args, **kwargs):
        return xbmc.getLanguage(*args, **kwargs)

    def GetLocalizedString(self, *args, **kwargs):
        return ADDON.getLocalizedString(*args, **kwargs).encode('utf-8')

    def GetSetting(self, *args, **kwargs):
        return ADDON.getSetting(*args, **kwargs)

    def SetSetting(self, *args, **kwargs):
        return ADDON.setSetting(*args, **kwargs)

    def TranslatePath(self, *args, **kwargs):
        return xbmc.translatePath(*args, **kwargs)

    def Log(self, *args, **kwargs):
        return xbmc.log(*args, **kwargs)

    def Dialog_CloseAll(self, *args, **kwargs):
        return xbmc.executebuiltin("Dialog.Close(all, true)")

    def InsertTorrent(self, *args, **kwargs):
        window = InsertTorrent("InsertTorrent.xml", ADDON_PATH, "Default")
        window.doModal()
        retval = {"type": ("cancelled", "url", "file")[window.type], "path": window.retval}
        del window
        return retval

    ###########################################################################
    # DialogProgress
    ###########################################################################
    def DialogProgress_Create(self, *args, **kwargs):
        dialog = xbmcgui.DialogProgress()
        self._objects[id(dialog)] = dialog
        dialog.create(*args, **kwargs)
        return id(dialog)

    def DialogProgress_IsCanceled(self, hwnd, *args, **kwargs):
        return self._objects[hwnd].iscanceled(*args, **kwargs)

    def DialogProgress_Update(self, hwnd, *args, **kwargs):
        return self._objects[hwnd].update(*args, **kwargs)

    def DialogProgress_Close(self, hwnd, *args, **kwargs):
        dialog = self._objects.pop(hwnd)
        dialog.close()
        del dialog

    # Background DialogProgress
    def DialogProgressBG_Create(self, *args, **kwargs):
        dialog = xbmcgui.DialogProgressBG()
        self._objects[id(dialog)] = dialog
        dialog.create(*args, **kwargs)
        return id(dialog)

    def DialogProgressBG_IsFinished(self, hwnd, *args, **kwargs):
        return self._objects[hwnd].isFinished(*args, **kwargs)

    def DialogProgressBG_Update(self, hwnd, *args, **kwargs):
        return self._objects[hwnd].update(*args, **kwargs)

    def DialogProgressBG_Close(self, hwnd, *args, **kwargs):
        dialog = self._objects.pop(hwnd)
        dialog.close()
        del dialog

    # Overlay status
    def OverlayStatus_Create(self):
        overlay = OverlayText()
        overlayId = id(overlay)
        self._objects[overlayId] = overlay
        return overlayId

    def OverlayStatus_Update(self, hwnd, percent, line1, line2, line3):
        text = "\n".join([line1, line2, line3])
        self._objects[hwnd].text = text

    def OverlayStatus_Show(self, hwnd):
        self._objects[hwnd].show()

    def OverlayStatus_Hide(self, hwnd):
        self._objects[hwnd].hide()

    def OverlayStatus_Close(self, hwnd):
        overlay = self._objects.pop(hwnd)
        overlay.hide()
        del overlay