Permalink
Browse files

Merge branch 'PR488'. closes #488

  • Loading branch information...
2 parents 53d808a + bd71a3d commit 7bc746d1da54aaa83da026eb45566c2e81309153 @opdenkamp opdenkamp committed Apr 18, 2012
@@ -1807,6 +1807,10 @@
<string id="19248">Daily wakeup time (HH:MM:SS)</string>
<string id="19249">Filter channels</string>
<string id="19250">Loading EPG from database</string>
+ <string id="19251">Update EPG information</string>
+ <string id="19252">Schedule EPG update for this channel?</string>
+ <string id="19253">EPG update scheduled for channel</string>
+ <string id="19254">EPG update failed for channel</string>
<string id="19499">Other/Unknown</string>
<string id="19500">Movie/Drama</string>
@@ -122,6 +122,7 @@ enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0,
CONTEXT_BUTTON_SORTBY_DATE,
CONTEXT_BUTTON_MENU_HOOKS,
CONTEXT_BUTTON_PLAY_AND_QUEUE,
+ CONTEXT_BUTTON_UPDATE_EPG,
CONTEXT_BUTTON_USER1,
CONTEXT_BUTTON_USER2,
CONTEXT_BUTTON_USER3,
View
@@ -43,6 +43,7 @@ CEpg::CEpg(int iEpgID, const CStdString &strName /* = "" */, const CStdString &s
m_bChanged(!bLoadedFromDb),
m_bTagsChanged(false),
m_bLoaded(false),
+ m_bUpdatePending(false),
m_iEpgID(iEpgID),
m_strName(strName),
m_strScraperName(strScraperName),
@@ -55,6 +56,7 @@ CEpg::CEpg(CPVRChannel *channel, bool bLoadedFromDb /* = false */) :
m_bChanged(!bLoadedFromDb),
m_bTagsChanged(false),
m_bLoaded(false),
+ m_bUpdatePending(false),
m_iEpgID(channel->EpgID()),
m_strName(channel->ChannelName()),
m_strScraperName(channel->EPGScraper()),
@@ -67,6 +69,7 @@ CEpg::CEpg(void) :
m_bChanged(false),
m_bTagsChanged(false),
m_bLoaded(false),
+ m_bUpdatePending(false),
m_iEpgID(0),
m_strName(StringUtils::EmptyString),
m_strScraperName(StringUtils::EmptyString),
@@ -85,6 +88,7 @@ CEpg &CEpg::operator =(const CEpg &right)
m_bChanged = right.m_bChanged;
m_bTagsChanged = right.m_bTagsChanged;
m_bLoaded = right.m_bLoaded;
+ m_bUpdatePending = right.m_bUpdatePending;
m_iEpgID = right.m_iEpgID;
m_strName = right.m_strName;
m_strScraperName = right.m_strScraperName;
@@ -124,6 +128,22 @@ void CEpg::SetScraperName(const CStdString &strScraperName)
}
}
+void CEpg::SetUpdatePending(bool bUpdatePending /* = true */)
+{
+ {
+ CSingleLock lock(m_critSection);
+ m_bUpdatePending = bUpdatePending;
+ }
+
+ if (bUpdatePending)
+ g_EpgContainer.SetHasPendingUpdates(true);
+}
+
+void CEpg::ForceUpdate(void)
+{
+ SetUpdatePending();
+}
+
bool CEpg::HasValidEntries(void) const
{
CSingleLock lock(m_critSection);
@@ -474,7 +494,7 @@ CDateTime CEpg::GetLastScanTime(void)
return m_lastScanTime;
}
-bool CEpg::Update(const time_t start, const time_t end, int iUpdateTime)
+bool CEpg::Update(const time_t start, const time_t end, int iUpdateTime, bool bForceUpdate /* = false */)
{
bool bGrabSuccess(true);
bool bUpdate(false);
@@ -490,12 +510,17 @@ bool CEpg::Update(const time_t start, const time_t end, int iUpdateTime)
/* get the last update time from the database */
CDateTime lastScanTime = GetLastScanTime();
- /* check if we have to update */
- time_t iNow = 0;
- time_t iLastUpdate = 0;
- CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(iNow);
- lastScanTime.GetAsTime(iLastUpdate);
- bUpdate = (iNow > iLastUpdate + iUpdateTime);
+ if (!bForceUpdate)
+ {
+ /* check if we have to update */
+ time_t iNow = 0;
+ time_t iLastUpdate = 0;
+ CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(iNow);
+ lastScanTime.GetAsTime(iLastUpdate);
+ bUpdate = (iNow > iLastUpdate + iUpdateTime);
+ }
+ else
+ bUpdate = true;
if (bUpdate)
bGrabSuccess = LoadFromClients(start, end);
@@ -511,6 +536,9 @@ bool CEpg::Update(const time_t start, const time_t end, int iUpdateTime)
else
CLog::Log(LOGERROR, "EPG - %s - failed to update table '%s'", __FUNCTION__, Name().c_str());
+ CSingleLock lock(m_critSection);
+ m_bUpdatePending = false;
+
return bGrabSuccess;
}
@@ -959,3 +987,9 @@ bool CEpg::HasPVRChannel(void) const
CSingleLock lock(m_critSection);
return m_iPVRChannelId != -1;
}
+
+bool CEpg::UpdatePending(void) const
+{
+ CSingleLock lock(m_critSection);
+ return m_bUpdatePending;
+}
View
@@ -107,6 +107,23 @@ namespace EPG
virtual void SetScraperName(const CStdString &strScraperName);
/*!
+ * @brief Specify if EPG should be manually updated on the next cycle
+ * @param bUpdatePending True if EPG should be manually updated
+ */
+ virtual void SetUpdatePending(bool bUpdatePending = true);
+
+ /*!
+ * @brief Returns if there is a manual update pending for this EPG
+ * @returns True if there are is a manual update pending, false otherwise
+ */
+ virtual bool UpdatePending(void) const;
+
+ /*!
+ * @brief Clear the current tag and schedule manual update
+ */
+ virtual void ForceUpdate(void);
+
+ /*!
* @brief Get the name of this table.
* @return The name of this table.
*/
@@ -206,9 +223,10 @@ namespace EPG
* @param start The start time.
* @param end The end time.
* @param iUpdateTime Update the table after the given amount of time has passed.
+ * @param bForceUpdate Force update from client even if it's not the time to
* @return True if the update was successful, false otherwise.
*/
- virtual bool Update(const time_t start, const time_t end, int iUpdateTime);
+ virtual bool Update(const time_t start, const time_t end, int iUpdateTime, bool bForceUpdate = false);
/*!
* @brief Get all EPG entries.
@@ -333,6 +351,7 @@ namespace EPG
bool m_bChanged; /*!< true if anything changed that needs to be persisted, false otherwise */
bool m_bTagsChanged; /*!< true when any tags are changed and not persisted, false otherwise */
bool m_bLoaded; /*!< true when the initial entries have been loaded */
+ bool m_bUpdatePending; /*!< true if manual update is pending */
int m_iEpgID; /*!< the database ID of this table */
CStdString m_strName; /*!< the name of this table */
CStdString m_strScraperName; /*!< the name of the scraper to use */
@@ -54,6 +54,7 @@ CEpgContainer::CEpgContainer(void) :
m_bPreventUpdates = false;
m_updateEvent.Reset();
m_bLoaded = false;
+ m_bHasPendingUpdates = false;
m_database.Open();
}
@@ -201,6 +202,7 @@ void CEpgContainer::Process(void)
time_t iNow = 0;
bool bUpdateEpg(true);
+ bool bHasPendingUpdates(false);
if (!m_bLoaded)
{
@@ -225,6 +227,18 @@ void CEpgContainer::Process(void)
if (!m_bStop && iNow >= m_iLastEpgCleanup)
RemoveOldEntries();
+ /* check for pending manual EPG updates */
+ if (!m_bStop)
+ {
+ {
+ CSingleLock lock(m_critSection);
+ bHasPendingUpdates = m_bHasPendingUpdates;
+ }
+
+ if (bHasPendingUpdates)
+ UpdateEPG(true);
+ }
+
/* check for updated active tag */
if (!m_bStop)
CheckPlayingEvents();
@@ -414,7 +428,7 @@ void CEpgContainer::WaitForUpdateFinish(bool bInterrupt /* = true */)
m_updateEvent.Wait();
}
-bool CEpgContainer::UpdateEPG()
+bool CEpgContainer::UpdateEPG(bool bOnlyPending /* = false */)
{
bool bInterrupted(false);
unsigned int iUpdatedTables(0);
@@ -435,7 +449,7 @@ bool CEpgContainer::UpdateEPG()
m_bIsUpdating = true;
}
- if (bShowProgress)
+ if (bShowProgress && !bOnlyPending)
ShowProgressDialog();
/* open the database */
@@ -460,10 +474,10 @@ bool CEpgContainer::UpdateEPG()
if (!epg)
continue;
- if (bShowProgress)
+ if (bShowProgress && !bOnlyPending)
UpdateProgressDialog(++iCounter, m_epgs.size(), epg->Name());
- if (epg->Update(start, end, m_iUpdateTime))
+ if ((!bOnlyPending || epg->UpdatePending()) && epg->Update(start, end, m_iUpdateTime, bOnlyPending))
++iUpdatedTables;
}
@@ -480,10 +494,11 @@ bool CEpgContainer::UpdateEPG()
{
CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(m_iNextEpgUpdate);
m_iNextEpgUpdate += g_advancedSettings.m_iEpgUpdateCheckInterval;
+ m_bHasPendingUpdates = false;
}
}
- if (bShowProgress)
+ if (bShowProgress && !bOnlyPending)
CloseProgressDialog();
/* notify observers */
@@ -601,3 +616,9 @@ bool CEpgContainer::IsInitialising(void) const
CSingleLock lock(m_critSection);
return m_bIsInitialising;
}
+
+void CEpgContainer::SetHasPendingUpdates(bool bHasPendingUpdates /* = true */)
+{
+ CSingleLock lock(m_critSection);
+ m_bHasPendingUpdates = bHasPendingUpdates;
+}
@@ -201,6 +201,12 @@ namespace EPG
void PreventUpdates(bool bSetTo = true) { m_bPreventUpdates = bSetTo; }
/*!
+ * @brief Notify EPG container that there are pending manual EPG updates
+ * @param bHasPendingUpdates The new value
+ */
+ void SetHasPendingUpdates(bool bHasPendingUpdates = true);
+
+ /*!
* @return True while being initialised.
*/
bool IsInitialising(void) const;
@@ -228,9 +234,10 @@ namespace EPG
/*!
* @brief Load and update the EPG data.
+ * @param bOnlyPending Only check and update EPG tables with pending manual updates
* @return True if the update has not been interrupted, false otherwise.
*/
- virtual bool UpdateEPG();
+ virtual bool UpdateEPG(bool bOnlyPending = false);
/*!
* @return True if a running update should be interrupted, false otherwise.
@@ -274,6 +281,7 @@ namespace EPG
bool m_bIsInitialising; /*!< true while the epg manager hasn't loaded all tables */
bool m_bLoaded; /*!< true after epg data is initially loaded from the database */
bool m_bPreventUpdates; /*!< true to prevent EPG updates */
+ bool m_bHasPendingUpdates; /*!< true if there are manual updates pending */
time_t m_iLastEpgCleanup; /*!< the time the EPG was cleaned up */
time_t m_iNextEpgUpdate; /*!< the time the EPG will be updated */
time_t m_iNextEpgActiveTagCheck; /*!< the time the EPG will be checked for active tag updates */
@@ -23,6 +23,7 @@
#include "dialogs/GUIDialogFileBrowser.h"
#include "dialogs/GUIDialogNumeric.h"
+#include "dialogs/GUIDialogKaiToast.h"
#include "dialogs/GUIDialogOK.h"
#include "dialogs/GUIDialogYesNo.h"
#include "dialogs/GUIDialogKeyboard.h"
@@ -110,6 +111,7 @@ void CGUIWindowPVRChannels::GetContextButtons(int itemNumber, CContextButtons &b
buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */
buttons.Add(CONTEXT_BUTTON_FILTER, 19249); /* filter channels */
+ buttons.Add(CONTEXT_BUTTON_UPDATE_EPG, 19251); /* update EPG information */
}
}
@@ -128,6 +130,7 @@ bool CGUIWindowPVRChannels::OnContextButton(int itemNumber, CONTEXT_BUTTON butto
OnContextButtonInfo(pItem.get(), button) ||
OnContextButtonGroupManager(pItem.get(), button) ||
OnContextButtonFilter(pItem.get(), button) ||
+ OnContextButtonUpdateEpg(pItem.get(), button) ||
CGUIWindowPVRCommon::OnContextButton(itemNumber, button);
}
@@ -503,6 +506,38 @@ bool CGUIWindowPVRChannels::OnContextButtonFilter(CFileItem *item, CONTEXT_BUTTO
return bReturn;
}
+bool CGUIWindowPVRChannels::OnContextButtonUpdateEpg(CFileItem *item, CONTEXT_BUTTON button)
+{
+ bool bReturn = false;
+
+ if (button == CONTEXT_BUTTON_UPDATE_EPG)
+ {
+ CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
+ if (!pDialog)
+ return bReturn;
+
+ CPVRChannel *channel = item->GetPVRChannelInfoTag();
+ pDialog->SetHeading(19251);
+ pDialog->SetLine(0, g_localizeStrings.Get(19252));
+ pDialog->SetLine(1, channel->ChannelName());
+ pDialog->SetLine(2, "");
+ pDialog->DoModal();
+
+ if (!pDialog->IsConfirmed())
+ return bReturn;
+
+ bReturn = UpdateEpgForChannel(item);
+
+ CStdString strMessage;
+ strMessage.Format("%s: '%s'", g_localizeStrings.Get(bReturn ? 19253 : 19254), channel->ChannelName());
+ CGUIDialogKaiToast::QueueNotification(bReturn ? CGUIDialogKaiToast::Info : CGUIDialogKaiToast::Error,
+ g_localizeStrings.Get(19166),
+ strMessage);
+ }
+
+ return bReturn;
+}
+
void CGUIWindowPVRChannels::ShowGroupManager(void)
{
/* Load group manager dialog */
@@ -62,6 +62,7 @@ namespace PVR
virtual bool OnContextButtonSetThumb(CFileItem *item, CONTEXT_BUTTON button);
virtual bool OnContextButtonShowHidden(CFileItem *item, CONTEXT_BUTTON button);
virtual bool OnContextButtonFilter(CFileItem *item, CONTEXT_BUTTON button);
+ virtual bool OnContextButtonUpdateEpg(CFileItem *item, CONTEXT_BUTTON button);
virtual void ShowGroupManager(void);
@@ -556,6 +556,17 @@ bool CGUIWindowPVRCommon::ActionDeleteChannel(CFileItem *item)
return true;
}
+bool CGUIWindowPVRCommon::UpdateEpgForChannel(CFileItem *item)
+{
+ CPVRChannel *channel = item->GetPVRChannelInfoTag();
+ CEpg *epg = channel->GetEPG();
+ if (!epg)
+ return false;
+
+ epg->ForceUpdate();
+ return true;
+}
+
bool CGUIWindowPVRCommon::ShowTimerSettings(CFileItem *item)
{
/* Check item is TV timer information tag */
@@ -116,6 +116,7 @@ namespace PVR
virtual bool StopRecordFile(CFileItem *item);
virtual void ShowEPGInfo(CFileItem *item);
virtual void ShowRecordingInfo(CFileItem *item);
+ virtual bool UpdateEpgForChannel(CFileItem *item);
virtual bool ShowTimerSettings(CFileItem *item);
virtual bool ShowNewTimerDialog(void);

0 comments on commit 7bc746d

Please sign in to comment.