def downloadFailedCallback(self, pkgName):
     '''Download failed callback.'''
     if self.repoCache.cache.has_key(pkgName):
         # Update application information.
         appInfo = self.repoCache.cache[pkgName]
         if appInfo.pkg.is_upgradable:
             appStatus = APP_STATE_UPGRADE
         else:
             appStatus = APP_STATE_NORMAL
         
         # Update application view.
         recommendView = self.recommendPage.recommendView
         recommendView.switchToStatus(pkgName, appStatus)
             
         # Update repo view.
         repoView = self.repoPage.repoView
         repoView.switchToStatus(pkgName, appStatus, True)
             
         # Update update view.
         updateView = self.updatePage.updateView
         updateView.switchToStatus(pkgName, appStatus, True)
             
         # Update detail view.
         for pageId in [PAGE_RECOMMEND, PAGE_REPO, PAGE_UPGRADE, PAGE_UNINSTALL]:
             if self.detailViewDict.has_key(pageId):
                 detailView = self.detailViewDict[pageId]
                 detailView.switchToStatus(pkgName, appStatus)
             elif pageId == PAGE_REPO and self.searchViewDict.has_key(pageId):
                 searchView = self.searchViewDict[pageId].searchView
                 searchView.switchToStatus(pkgName, appStatus, True)
     else:
         print "Impossible: %s not in RepoCache" % (pkgName)
 def downloadFinishCallback(self, pkgName):
     '''Download finish callback.'''
     if self.repoCache.cache.has_key(pkgName):
         # Update application information.
         appInfo = self.repoCache.cache[pkgName]
         if appInfo.pkg.is_upgradable:
             appStatus = APP_STATE_UPGRADING
         else:
             appStatus = APP_STATE_INSTALLING
         appInfo.switchStatus(appStatus)
             
         # Update application view.
         recommendView = self.recommendPage.recommendView
         recommendView.switchToStatus(pkgName, appStatus)
             
         # Update repo view.
         repoView = self.repoPage.repoView
         repoView.switchToStatus(pkgName, appStatus)
             
         # Update update view.
         updateView = self.updatePage.updateView
         updateView.switchToStatus(pkgName, appStatus)
             
         # Update detail view.
         for pageId in [PAGE_RECOMMEND, PAGE_REPO, PAGE_UPGRADE, PAGE_UNINSTALL]:
             if self.detailViewDict.has_key(pageId):
                 detailView = self.detailViewDict[pageId]
                 detailView.switchToStatus(pkgName, appStatus)
             elif pageId == PAGE_REPO and self.searchViewDict.has_key(pageId):
                 searchView = self.searchViewDict[pageId].searchView
                 searchView.switchToStatus(pkgName, appStatus)
                 
         # Require new install action.
         if appStatus == APP_STATE_UPGRADING:
             self.actionQueue.addAction(pkgName, ACTION_UPGRADE)
         else:
             self.actionQueue.addAction(pkgName, ACTION_INSTALL)
     else:
         print "Impossible: %s not in RepoCache" % (pkgName)
 def switchStatus(self, pkgName, appStatus):
     '''Switch status.'''
     # Update recommand view.
     recommendView = self.recommendPage.recommendView
     recommendView.switchToStatus(pkgName, appStatus)
     
     # Update repo view.
     repoView = self.repoPage.repoView
     repoView.switchToStatus(pkgName, appStatus)
     
     # Update application view.
     updateView = self.updatePage.updateView
     updateView.switchToStatus(pkgName, appStatus)
         
     # Update detail view.
     for pageId in [PAGE_RECOMMEND, PAGE_REPO, PAGE_UPGRADE, PAGE_UNINSTALL]:
         if self.detailViewDict.has_key(pageId):
             detailView = self.detailViewDict[pageId]
             detailView.switchToStatus(pkgName, appStatus)
         elif pageId == PAGE_REPO and self.searchViewDict.has_key(pageId):
             searchView = self.searchViewDict[pageId].searchView
             searchView.switchToStatus(pkgName, appStatus)
    def actionFailedCallback(self, actionType, pkgName):
        '''Installing failed callback.'''
        if actionType == ACTION_INSTALL:
            if self.repoCache.cache.has_key(pkgName):
                # Update application information.
                appInfo = self.repoCache.cache[pkgName]
                appInfo.switchStatus(APP_STATE_NORMAL)
                
                # Update recommend view.
                recommendView = self.recommendPage.recommendView
                recommendView.initNormalStatus(pkgName, True)
                
                # Update repo view.
                repoView = self.repoPage.repoView
                repoView.initNormalStatus(pkgName, True, True)
                
                # Update detail view.
                for pageId in [PAGE_RECOMMEND, PAGE_REPO, PAGE_UPGRADE, PAGE_UNINSTALL]:
                    if self.detailViewDict.has_key(pageId):
                        detailView = self.detailViewDict[pageId]
                        detailView.initNormalStatus(pkgName, True)
                    elif pageId == PAGE_REPO and self.searchViewDict.has_key(pageId):
                        searchView = self.searchViewDict[pageId].searchView
                        searchView.initNormalStatus(pkgName, True, True)
            else:
                print "Impossible: %s not in RepoCache" % (pkgName)
        elif actionType == ACTION_UPGRADE:
            if self.repoCache.cache.has_key(pkgName):
                # Update application information.
                appInfo = self.repoCache.cache[pkgName]
                appInfo.switchStatus(APP_STATE_UPGRADE)

                # Update recommend view.
                recommendView = self.recommendPage.recommendView
                recommendView.switchToStatus(pkgName, APP_STATE_UPGRADE)
                
                # Update repo view.
                repoView = self.repoPage.repoView
                repoView.switchToStatus(pkgName, APP_STATE_UPGRADE, True)
                
                # Update update view.
                updateView = self.updatePage.updateView
                updateView.switchToStatus(pkgName, APP_STATE_UPGRADE, True)
                
                # Update detail view.
                for pageId in [PAGE_RECOMMEND, PAGE_REPO, PAGE_UPGRADE, PAGE_UNINSTALL]:
                    if self.detailViewDict.has_key(pageId):
                        detailView = self.detailViewDict[pageId]
                        detailView.switchToStatus(pkgName, APP_STATE_UPGRADE)
                    elif pageId == PAGE_REPO and self.searchViewDict.has_key(pageId):
                        searchView = self.searchViewDict[pageId].searchView
                        searchView.switchToStatus(pkgName, APP_STATE_UPGRADE, True)
            else:
                print "Impossible: %s not in RepoCache" % (pkgName)
        elif actionType == ACTION_UNINSTALL:
            if self.repoCache.cache.has_key(pkgName):
                # Update application information.
                appInfo = self.repoCache.cache[pkgName]
                appInfo.switchStatus(APP_STATE_INSTALLED)
                
                # Update uninstall view.
                uninstallView = self.uninstallPage.uninstallView
                uninstallView.initUninstallStatus(pkgName, True)
                
                # Update detail view.
                for pageId in [PAGE_RECOMMEND, PAGE_REPO, PAGE_UPGRADE, PAGE_UNINSTALL]:
                    if self.detailViewDict.has_key(pageId):
                        detailView = self.detailViewDict[pageId]
                        detailView.initNormalStatus(pkgName, False)
                    elif pageId == PAGE_UNINSTALL and self.searchViewDict.has_key(pageId):
                        searchView = self.searchViewDict[pageId].searchView
                        searchView.initUninstallStatus(pkgName, True)
            else:
                print "Impossible: %s not in RepoCache" % (pkgName)