diff options
author | xhaggi <sascha.woo@gmail.com> | 2014-05-06 19:25:51 +0200 |
---|---|---|
committer | xhaggi <sascha.woo@gmail.com> | 2014-05-08 17:02:20 +0200 |
commit | c7d8fcf17a8ce160fe9cf1a775b896cd4b399b31 (patch) | |
tree | 37981fdc0cd8e23d82a1e73c839ab17cb6639122 | |
parent | f239d65ed9d80d6c386bf1b6ce7f66fd7cf1dc29 (diff) |
[pvr] adds a background job to search for missing channel icons
This adds a background job to search for missing channel icons, which is exectued on every PVR manager start.
-rwxr-xr-x | language/English/strings.po | 8 | ||||
-rw-r--r-- | xbmc/pvr/PVRManager.cpp | 20 | ||||
-rw-r--r-- | xbmc/pvr/PVRManager.h | 15 | ||||
-rw-r--r-- | xbmc/pvr/channels/PVRChannelGroup.cpp | 17 | ||||
-rw-r--r-- | xbmc/pvr/channels/PVRChannelGroupsContainer.cpp | 3 |
5 files changed, 56 insertions, 7 deletions
diff --git a/language/English/strings.po b/language/English/strings.po index 58e811bc9e..45eaba3652 100755 --- a/language/English/strings.po +++ b/language/English/strings.po @@ -8502,7 +8502,13 @@ msgctxt "#19285" msgid "Browse for icon" msgstr "" -#empty strings from id 19286 to 19498 +#. Notification message if process starts searching for missing channel icons +#: xbmc/pvr/PVRManager.cpp +msgctxt "#19286" +msgid "Searching for channel icons" +msgstr "" + +#empty strings from id 19287 to 19498 #: xbmc/epg/Epg.cpp msgctxt "#19499" diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index 9e23a185c9..c580622b76 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -144,7 +144,7 @@ void CPVRManager::OnSettingAction(const CSetting *setting) if (settingId == "pvrmenu.searchicons") { if (IsStarted()) - SearchMissingChannelIcons(); + TriggerSearchMissingChannelIcons(); } else if (settingId == "pvrmanager.resetdb") { @@ -449,13 +449,18 @@ void CPVRManager::Process(void) bool bRestart(false); while (IsStarted() && m_addons && m_addons->HasConnectedClients() && !bRestart) { - /* continue last watched channel after first startup */ + /* first startup */ if (m_bFirstStart) { { CSingleLock lock(m_critSection); m_bFirstStart = false; } + + /* start job to search for missing channel icons */ + TriggerSearchMissingChannelIcons(); + + /* continue last watched channel */ ContinueLastChannel(); } /* execute the next pending jobs if there are any */ @@ -1455,6 +1460,11 @@ void CPVRManager::TriggerSaveChannelSettings(void) QueueJob(new CPVRChannelSettingsSaveJob()); } +void CPVRManager::TriggerSearchMissingChannelIcons(void) +{ + CJobManager::GetInstance().AddJob(new CPVRSearchMissingChannelIconsJob(), NULL); +} + void CPVRManager::ExecutePendingJobs(void) { CSingleLock lock(m_critSectionTriggers); @@ -1539,6 +1549,12 @@ bool CPVRChannelSwitchJob::DoWork(void) return true; } +bool CPVRSearchMissingChannelIconsJob::DoWork(void) +{ + g_PVRManager.SearchMissingChannelIcons(); + return true; +} + bool CPVRManager::CreateChannelEpgs(void) { if (EpgsCreated()) diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index 12866a34ea..c8461ac478 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -397,6 +397,11 @@ namespace PVR void TriggerSaveChannelSettings(void); /*! + * @brief Let the background thread search for missing channel icons. + */ + void TriggerSearchMissingChannelIcons(void); + + /*! * @brief Update the channel that is currently active. * @param item The new channel. * @return True if it was updated correctly, false otherwise. @@ -745,4 +750,14 @@ namespace PVR CFileItem* m_previous; CFileItem* m_next; }; + + class CPVRSearchMissingChannelIconsJob : public CJob + { + public: + CPVRSearchMissingChannelIconsJob(void) {} + virtual ~CPVRSearchMissingChannelIconsJob() {} + virtual const char *GetType() const { return "pvr-search-missing-channel-icons"; } + + bool DoWork(); + }; } diff --git a/xbmc/pvr/channels/PVRChannelGroup.cpp b/xbmc/pvr/channels/PVRChannelGroup.cpp index a4c3c7fa15..a74a763c6e 100644 --- a/xbmc/pvr/channels/PVRChannelGroup.cpp +++ b/xbmc/pvr/channels/PVRChannelGroup.cpp @@ -29,6 +29,7 @@ #include "guilib/GUIWindowManager.h" #include "dialogs/GUIDialogYesNo.h" #include "dialogs/GUIDialogOK.h" +#include "dialogs/GUIDialogExtendedProgressBar.h" #include "music/tags/MusicInfoTag.h" #include "utils/log.h" #include "Util.h" @@ -246,7 +247,10 @@ void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */) if (fileItemList.IsEmpty()) return; - + + CGUIDialogExtendedProgressBar* dlgProgress = (CGUIDialogExtendedProgressBar*)g_windowManager.GetWindow(WINDOW_DIALOG_EXT_PROGRESS); + CGUIDialogProgressBarHandle* dlgProgressHandle = dlgProgress ? dlgProgress->GetHandle(g_localizeStrings.Get(19286)) : NULL; + CSingleLock lock(m_critSection); /* create a map for fast lookup of normalized file base name */ @@ -260,10 +264,18 @@ void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */) fileItemMap.insert(std::make_pair(baseName, (*it)->GetPath())); } + int channelIndex = 0; for(std::vector<PVRChannelGroupMember>::const_iterator it = m_members.begin(); it != m_members.end(); ++it) { CPVRChannelPtr channel = (*it).channel; + /* update progress dialog */ + if (dlgProgressHandle) + { + dlgProgressHandle->SetProgress(channelIndex++, m_members.size()); + dlgProgressHandle->SetText(channel->ChannelName()); + } + /* skip if an icon is already set and exists */ if (channel->IsIconExists()) continue; @@ -290,6 +302,9 @@ void CPVRChannelGroup::SearchAndSetChannelIcons(bool bUpdateDb /* = false */) /* TODO: start channel icon scraper here if nothing was found */ } + + if (dlgProgressHandle) + dlgProgressHandle->MarkFinished(); } /********** sort methods **********/ diff --git a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp index 3c76d1e731..da774ac78f 100644 --- a/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp +++ b/xbmc/pvr/channels/PVRChannelGroupsContainer.cpp @@ -254,7 +254,6 @@ void CPVRChannelGroupsContainer::SearchMissingChannelIcons(void) { CLog::Log(LOGINFO, "PVRChannelGroupsContainer - %s - starting channel icon search", __FUNCTION__); - // TODO: Add Process dialog here CPVRChannelGroupPtr channelgrouptv = GetGroupAllTV(); CPVRChannelGroupPtr channelgroupradio = GetGroupAllRadio(); @@ -262,8 +261,6 @@ void CPVRChannelGroupsContainer::SearchMissingChannelIcons(void) channelgrouptv->SearchAndSetChannelIcons(true); if (channelgroupradio) channelgroupradio->SearchAndSetChannelIcons(true); - - CGUIDialogOK::ShowAndGetInput(19167,0,20177,0); } CFileItemPtr CPVRChannelGroupsContainer::GetLastPlayedChannel(void) const |