示例#1
0
 def displayIcon(self, ret = None):
     # check if displays icon is enabled in options
     if not config.plugins.BoardReader.showcover.value or None == self.iconManager :
         return
         
     
     if False == self.changeIcon:
         return
     
     selItem = self.getSelItem()
     # when ret is != None the method is called from IconManager 
     # and in this variable the url for icon which was downloaded 
     # is returned 
     if ret != None and selItem != None:
         # if icon for other than selected item has been downloaded 
         # the displayed icon will not be changed
         if ret != selItem.iconimage:
             return
         
     # Display icon
     if selItem and selItem.iconimage != '' and self.iconManager:
         self["cover"].hide()
         # check if we have this icon and get the path to this icon on disk
         iconPath = self.iconManager.getIconPathFromAAueue(selItem.iconimage)
         printDBG( 'displayIcon -> getIconPathFromAAueue: ' + selItem.iconimage )
         if iconPath != '':
             printDBG( 'updateIcon: ' + iconPath )
             self["cover"].decodeCover(iconPath, self.decodeCoverCallBack, "cover")
             self.changeIcon = False
     else:
         self["cover"].hide()
     return
示例#2
0
 def callbackGetList(self, ret):
     printDBG( "plugin:callbackGetList" )
     
     global gMainFunctionsQueue
     #the proxy Queue will be used to call function from mainThread
     gMainFunctionsQueue.addToQueue("reloadList", ret)
     
     return
示例#3
0
 def decodeCoverCallBack(self, ret):
     printDBG("decodeIconIfNeedeCallBack")
     
     global gMainFunctionsQueue
     #the proxy Queue will be used to call function from mainThread
     gMainFunctionsQueue.addToQueue("updateCover", ret)
     
     return
示例#4
0
    def checkIconCallBack(self, ret):
        printDBG("checkIconCallBack")
 
        # ret - url for icon wich has been dowlnoaded
        global gMainFunctionsQueue
        
        #the proxy Queue will be used to call function from mainThread
        gMainFunctionsQueue.addToQueue("displayIcon", ret)
        return
示例#5
0
 def updateCover(self, retDict):
     # retDict - return dictionary  {Ident, Pixmap, FileName, Changed}
     printDBG('updateCover')
     if retDict:
         printDBG("updateCover retDict for Ident: %s " % retDict["Ident"])
         if retDict["Changed"]:
             self[retDict["Ident"]].updatePixmap(retDict["Pixmap"], retDict["FileName"])
         else:
             printDBG("updateCover pixel map not changed")
             
         if 'cover' == retDict["Ident"]:
             #check if we have icon for right item on list
             selItem = self.getSelItem()
             if selItem and selItem.iconimage != '':
                 # check if we have this icon and get the path to this icon on disk
                 iconPath = self.iconManager.getIconPathFromAAueue(selItem.iconimage)
                 if iconPath == retDict["FileName"]:
                     # now we are sure that we have right icon, so let show it
                     self[retDict["Ident"]].show()
         else:
             self[retDict["Ident"]].show()
     else:
         printDBG("updateCover retDict empty")
         
     return
示例#6
0
    def reloadList(self, ret):
        printDBG( "plugin:reloadList" )
        
        # ToDo: check ret.status if not OK do something :P
        if ret.status != RetHost.OK:
            printDBG( "++++++++++++++++++++++ callbackRefreshXML ret.status = %s" % ret.status )

        self.currList = ret.value
        
        self["list"].setList([ (x,) for x in self.currList])
        
        
        ####################################################
        #                   iconManager
        ####################################################
        iconList = []
        # fill icon List for icon manager 
        # if an user whant to see icons
        if config.plugins.BoardReader.showcover.value and self.iconManager:
            for it in self.currList:
                if it.iconimage != '':
                    iconList.append(it.iconimage)
        
        if len(iconList):
            # List has been changed so clear old Queue
            self.iconManager.clearDQueue()
            # a new list of icons should be downloaded
            self.iconManager.addToDQueue(iconList)
        #####################################################
        
        
        self["headertext"].setText(self.getCategoryPath())
            
        if len(self.currList) <= 0:
            if ret.message and ret.message != '':
                self["statustext"].setText("%s \n\nNaciśnij OK, aby odświeżyć" % ret.message)
            else:
                self["statustext"].setText("Brak elementów do wyświetlenia.\nNaciśnij OK, aby odświeżyć")
            self["list"].hide()
        else:
            #restor previus selection
            if len(self.currList) > self.nextSelIndex:
                self["list"].moveToIndex(self.nextSelIndex)
            else:
                #selection will not be change so manualy call
                self.changeBottomPanel()
            
            self["statustext"].setText("")            
            self["list"].show()
示例#7
0
 def requestListFromHost(self, type, currSelIndex = -1, videoUrl = ''):
     
     if self.isNotInWorkThread():
         self["list"].hide()
         
         if type != 'ForVideoLinks' and type != 'ResolveURL':
             #hide bottom panel
             self["cover"].hide()
             self["console"].setText('')
             
         if type == 'ForItem' or type == 'ForSearch':
             self.prevSelList.append(self.currSelIndex)
             if type == 'ForSearch':
                 self.categoryList.append('Wyniki wyszukiwania')
             else:
                 self.categoryList.append(self.currSelectedItemName) 
             #new list, so select first index
             self.nextSelIndex = 0
         
         selItem = None
         if currSelIndex > -1 and len(self.currList) > currSelIndex:
             selItem = self.currList[currSelIndex]
         
         if type == 'Refresh':
             self["statustext"].setText("Odświeżam...............")
             self.workThread = AsyncMethod(self.host.getCurrentList, self.callbackGetList)(1)
         elif type == 'Initial':
             self["statustext"].setText("Pobieranie..............")
             self.workThread = AsyncMethod(self.host.getInitList, self.callbackGetList)()
         elif type == 'Previous':
             self["statustext"].setText("Pobieranie..............")
             self.workThread = AsyncMethod(self.host.getPrevList, self.callbackGetList)()
         elif type == 'ForItem':
             self["statustext"].setText("Pobieranie..............")
             self.workThread = AsyncMethod(self.host.getListForItem, self.callbackGetList)(currSelIndex, 0, selItem)
         elif type == 'ForSearch':
             self["statustext"].setText("Szukam..................")
             self.workThread = AsyncMethod(self.host.getSearchResults, self.callbackGetList)(self.searchPattern, self.searchType)
         else:
             printDBG( 'requestListFromHost unknown list type: ' + type )
                     
     return
示例#8
0
 def keyOK(self):
     self.save()
     
     if self.firstHostIdx > -1:
         curIndex = self["config"].getCurrentIndex()
         if curIndex >= self.firstHostIdx:
             # calculate index in hosts list
             idx = curIndex - self.firstHostIdx
             global gListOfHostsNames
             if idx < len(gListOfHostsNames):
                 hostName = gListOfHostsNames[idx]
                 if IsHostEnabled(hostName):
                     try:
                         self.host = __import__('forums.forum' + hostName, globals(), locals(), ['GetConfigList'], -1)
                         if( len(self.host.GetConfigList()) < 1 ):
                             printDBG('ConfigMenu host "%s" does not have additiona configs' % hostName)
                         self.session.open(ConfigHostMenu, hostName = hostName)
                     except:
                         printDBG('ConfigMenu host "%s" does not have method GetConfigList' % hostName)
     return
示例#9
0
 def back_pressed(self):
     try:
         if not self.isNotInWorkThread():
             self.workThread.Thread._Thread__stop()
             self["statustext"].setText(_("Action cancelled!"))
             return
     except:
         return
         
     if self.visible:
                    
         if len(self.prevSelList) > 0:
             self.nextSelIndex = self.prevSelList.pop()
             self.categoryList.pop()
             printDBG( "back_pressed prev sel index %s" % self.nextSelIndex )
             self.requestListFromHost('Previous')
         else:
             #There is no prev categories, so exit
             #self.close()
             self.selectHost()
     else:
         self.showWindow()
         
     return
示例#10
0
    def selectHost(self):
    
        self.host = None
        self.hostName = ''
        self.nextSelIndex = 0
        self.prevSelList = []
        self.categoryList = []
        self.currList = []
        self.currSelectedItemName = ""
        self.json_installed = False
        try:
            import simplejson
            self.json_installed = True
        except:
            pass
        try:
            import json as simplejson
            self.json_installed = True
        except:
            pass

        options = [] 
        hostsList = GetHostsList()
        brokenHostList = []
        for hostName in hostsList:
            hostEnabled  = False
            try:
                exec('if config.plugins.BoardReader.host' + hostName + '.value: hostEnabled = True')
            except:
                hostEnabled = False
            if True == hostEnabled:
                if not config.plugins.BoardReader.devHelper.value:
                    try:
                        _temp = __import__('forums.forum' + hostName, globals(), locals(), ['gettytul'], -1)
                        title = _temp.gettytul()
                        printDBG('host name "%s"' % hostName)
                    except:
                        printDBG('get host name exception for host "%s"' % hostName)
                        brokenHostList.append('host'+hostName)
                        continue # do not use default name if import name will failed
                else:
                    _temp = __import__('forums.forum' + hostName, globals(), locals(), ['gettytul'], -1)
                    title = _temp.gettytul()
                    printDBG('host name "%s"' % hostName)
                options.extend(((title, hostName),))
        options.sort()
        
        #if len(brokenHostList) > 0:
        #    self.session.open(MessageBox, "Poniższe playery są niepoprawne lub brakuje im pewnych modułów.\n" + '\n'.join(brokenHostList), type = MessageBox.TYPE_INFO, timeout = 10 )
     
        options.extend(((_("Config"), "config"),))
        from playerselector import PlayerSelectorWidget

        self.session.openWithCallback(self.selectHostCallback, PlayerSelectorWidget, list = options)
        return
示例#11
0
 def selectHostCallback(self, ret):
     hasIcon = False
     if ret:               
         printDBG("Selected host" + ret[1])
         if ret[1] == "config":
             self.session.openWithCallback(self.selectHost, ConfigMenu)
             return
         else:
             if not config.plugins.BoardReader.devHelper.value:
                 try:
                     self.hostName = ret[1]
                     _temp = __import__('forums.forum' + self.hostName, globals(), locals(), ['MyHost'], -1)
                     self.host = _temp.MyHost()
                 except:
                     printDBG( 'Cannot import class MyHost for host: "%s"' % ret[1] )
                     self.close()
                     return
             else:
                 self.hostName = ret[1]
                 _temp = __import__('forums.forum' + self.hostName, globals(), locals(), ['MyHost'], -1)
                 self.host = _temp.MyHost()
             
         if self.showMessageNoFreeSpaceForIcon and hasIcon:
             self.showMessageNoFreeSpaceForIcon = False
             self.session.open(MessageBox, "Brak wolnego miejsca w katalogu %s. \nNowe ikony nie beda ściągane. \nAby nowe ikony były dostępne wymagane jest 10MB wolnego miejsca." % (config.plugins.BoardReader.SciezkaCache.value), type = MessageBox.TYPE_INFO, timeout = 10 )
     else:
         self.close()
         return
     
     #############################################
     #            change logo for player
     #############################################
     self["playerlogo"].hide()
     
     hRet= self.host.getLogoPath()
     if hRet.status == RetHost.OK and  len(hRet.value):
         logoPath = hRet.value[0]
             
         if logoPath != '':
             printDBG( 'Logo Path: ' + logoPath )
             self["playerlogo"].decodeCover(logoPath, \
                                            self.decodeCoverCallBack, \
                                            "playerlogo")
     #############################################
     
     # request initial list from host        
     self.getInitialList()
     
     return
示例#12
0
 def getSelItem(self):
     currSelIndex = self["list"].getCurrentIndex()
     if len(self.currList) <= currSelIndex:
         printDBG( "ERROR: getSelItem there is no item with index: %d, listOfItems.len: %d" % (currSelIndex, len(self.currList)) )
         return
     return self.currList[currSelIndex]
示例#13
0
 def ok_pressed(self):
     if self.visible:
         sel = None
         try:
             sel = self["list"].l.getCurrentSelection()[0]
         except:
             printDBG( "ok_pressed except" )
             self.getRefreshedCurrList()
             return
         if sel is None:
             printDBG( "ok_pressed sel is None" )
             self.getInitialList()
             return
         elif len(self.currList) <= 0:
             printDBG( "ok_pressed list is empty" )
             self.getRefreshedCurrList()
             return
         else:
             printDBG( "ok_pressed selected item: %s" % (sel.name) )
             
             self.currSelectedItemName = sel.name             
             item = self.getSelItem()
             
             #Get current selection
             currSelIndex = self["list"].getCurrentIndex()
             #remember only prev categories
             if item.type == CDisplayListItem.TYPE_CATEGORY:
                     printDBG( "ok_pressed selected TYPE_CATEGORY" )
                     self.currSelIndex = currSelIndex
                     self.requestListFromHost('ForItem', currSelIndex, '')
             elif item.type == CDisplayListItem.TYPE_NEWTHREAD or item.type == CDisplayListItem.TYPE_OLDTHREAD:
                     printDBG( "ok_pressed selected TYPE_[NEW|OLD]THREAD" )
                     self.currSelIndex = currSelIndex
                     ThreadContent, mainURL, ThreadURL = self.host.getFullThread(self.currSelIndex)
                     printDBG("ThreadContent:" + ThreadContent)
                     from libs.ThreadView import ThreadView
                     self.session.openWithCallback(self.LeaveThreadView, ThreadView, ThreadContent, mainURL, ThreadURL)
             else:
                 printDBG( "ok_pressed selected TYPE_SEARCH" )
                 self.currSelIndex = currSelIndex
                 self.startSearchProcedure(item.possibleTypesOfSearch)
     else:
         self.showWindow()
         
     return
示例#14
0
#icons
config.plugins.BoardReader.IconsSize = ConfigSelection(default = "100", choices = [("135", "135x135"),("120", "120x120"),("100", "100x100")]) 
config.plugins.BoardReader.numOfRow = ConfigSelection(default = "0", choices = [("1", "1"),("2", "2"),("3", "3"),("4", "4"),("0", "auto")])
config.plugins.BoardReader.numOfCol = ConfigSelection(default = "0", choices = [("1", "1"),("2", "2"),("3", "3"),("4", "4"),("5", "5"),("6", "6"),("7", "7"),("8", "8"),("0", "auto")])

config.plugins.BoardReader.cleanup = ConfigYesNo(default = True)

########################################################
# Generate list of hosts options for Enabling/Disabling
########################################################
gListOfHostsNames = [] 
gListOfHostsNames = GetHostsList()
for hostName in gListOfHostsNames:
    try:
        printDBG("Set default options for host '%s'" % hostName)
        # as default all hosts are enabled
        exec('config.plugins.BoardReader.host' + hostName + ' = ConfigYesNo(default = True)')
    except:
        printDBG("Options import for host '%s' EXEPTION" % hostName)

class ConfigMenu(Screen, ConfigListScreen):

    skin = """
    <screen name="Boards Client config" position="center,center" size="540,440" title="" backgroundColor="#31000000" >

            <widget name="config" position="10,10" size="520,395" zPosition="1" transparent="0" backgroundColor="#31000000" scrollbarMode="showOnDemand" />
            <widget name="key_green" position="0,405" zPosition="2" size="100,35" valign="center" halign="right" font="Regular;22" transparent="1" foregroundColor="green" />
            <widget name="key_blue" position="100,405" zPosition="2" size="50,35" valign="center" halign="center" font="Regular;22" transparent="1" foregroundColor="blue" />
            <widget name="key_red" position="150,405" zPosition="2" size="100,35" valign="center" halign="right" font="Regular;22" transparent="1" foregroundColor="red" />
            <widget name="key_yellow" position="250,405" zPosition="2" size="200,35" valign="center" halign="right" font="Regular;22" transparent="1" foregroundColor="yellow" />