Permalink
Browse files

pvr: add a Start/Stop Recording context menu item to pvr channels in …

…channel list view
  • Loading branch information...
1 parent 111d12e commit 67e3c3c270f4d65ea29178ebe1e4a42860930992 @nemphys nemphys committed with Lars Op den Kamp Apr 18, 2012
@@ -1811,6 +1811,8 @@
<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="19255">Start recording</string>
+ <string id="19256">Stop recording</string>
<string id="19499">Other/Unknown</string>
<string id="19500">Movie/Drama</string>
@@ -123,6 +123,7 @@ enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0,
CONTEXT_BUTTON_MENU_HOOKS,
CONTEXT_BUTTON_PLAY_AND_QUEUE,
CONTEXT_BUTTON_UPDATE_EPG,
+ CONTEXT_BUTTON_RECORD_ITEM,
CONTEXT_BUTTON_USER1,
CONTEXT_BUTTON_USER2,
CONTEXT_BUTTON_USER3,
View
@@ -582,6 +582,36 @@ int CPVRManager::GetPreviousChannel(void)
return iReturn;
}
+bool CPVRManager::ToggleRecordingOnChannel(unsigned int iChannelId)
+{
+ bool bReturn = false;
+
+ CPVRChannel *channel;
+ channel = m_channelGroups->GetChannelById(iChannelId);
+ if (!channel)
+ return bReturn;
+
+ if (m_addons->HasTimerSupport(channel->ClientID()))
+ {
+ /* timers are supported on this channel */
+ if (!channel->IsRecording())
+ {
+ CPVRTimerInfoTag *newTimer = m_timers->InstantTimer(channel);
+ if (!newTimer)
+ CGUIDialogOK::ShowAndGetInput(19033,0,19164,0);
+ else
+ bReturn = true;
+ }
+ else
+ {
+ /* delete active timers */
+ bReturn = m_timers->DeleteTimersOnChannel(*channel, false, true);
+ }
+ }
+
+ return bReturn;
+}
+
bool CPVRManager::StartRecordingOnPlayingChannel(bool bOnOff)
{
bool bReturn = false;
View
@@ -237,6 +237,13 @@ namespace PVR
bool OpenRecordedStream(const CPVRRecording &tag);
/*!
+ * @brief Start recording on a given channel if it is not already recording, stop if it is.
+ * @param channel the channel to start/stop recording.
+ * @return True if the recording was started or stopped successfully, false otherwise.
+ */
+ bool ToggleRecordingOnChannel(unsigned int iChannelId);
+
+ /*!
* @brief Start or stop recording on the channel that is currently being played.
* @param bOnOff True to start recording, false to stop.
* @return True if the recording was started or stopped successfully, false otherwise.
@@ -86,6 +86,7 @@ void CGUIWindowPVRChannels::GetContextButtons(int itemNumber, CContextButtons &b
if (itemNumber < 0 || itemNumber >= m_parent->m_vecItems->Size())
return;
CFileItemPtr pItem = m_parent->m_vecItems->Get(itemNumber);
+ CPVRChannel *channel = pItem->GetPVRChannelInfoTag();
if (pItem->GetPath() == "pvr://channels/.add.channel")
{
@@ -97,6 +98,7 @@ void CGUIWindowPVRChannels::GetContextButtons(int itemNumber, CContextButtons &b
buttons.Add(CONTEXT_BUTTON_INFO, 19047); /* channel info */
buttons.Add(CONTEXT_BUTTON_FIND, 19003); /* find similar program */
buttons.Add(CONTEXT_BUTTON_PLAY_ITEM, 19000); /* switch to channel */
+ buttons.Add(CONTEXT_BUTTON_RECORD_ITEM, channel->IsRecording() ? 19256 : 19255); /* start/stop recording on channel */
buttons.Add(CONTEXT_BUTTON_SET_THUMB, 20019); /* change icon */
buttons.Add(CONTEXT_BUTTON_GROUP_MANAGER, 19048); /* group manager */
buttons.Add(CONTEXT_BUTTON_HIDE, m_bShowHiddenChannels ? 19049 : 19054); /* show/hide channel */
@@ -131,6 +133,7 @@ bool CGUIWindowPVRChannels::OnContextButton(int itemNumber, CONTEXT_BUTTON butto
OnContextButtonGroupManager(pItem.get(), button) ||
OnContextButtonFilter(pItem.get(), button) ||
OnContextButtonUpdateEpg(pItem.get(), button) ||
+ OnContextButtonRecord(pItem.get(), button) ||
CGUIWindowPVRCommon::OnContextButton(itemNumber, button);
}
@@ -506,6 +509,17 @@ bool CGUIWindowPVRChannels::OnContextButtonFilter(CFileItem *item, CONTEXT_BUTTO
return bReturn;
}
+bool CGUIWindowPVRChannels::OnContextButtonRecord(CFileItem *item, CONTEXT_BUTTON button)
+{
+ bool bReturn(false);
+ CPVRChannel *channel = item->GetPVRChannelInfoTag();
+
+ if (channel)
+ return g_PVRManager.ToggleRecordingOnChannel(channel->ChannelID());
+
+ return bReturn;
+}
+
bool CGUIWindowPVRChannels::OnContextButtonUpdateEpg(CFileItem *item, CONTEXT_BUTTON button)
{
bool bReturn = false;
@@ -63,6 +63,7 @@ namespace PVR
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 bool OnContextButtonRecord(CFileItem *item, CONTEXT_BUTTON button);
virtual void ShowGroupManager(void);

0 comments on commit 67e3c3c

Please sign in to comment.