Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add timer conflict support #2

Closed
wants to merge 1 commit into from

2 participants

@Glenn-1990

This will add support for timer conflict notifications which was added in the 1.5 PVR API.
xbmc/xbmc#1577

@Red-F
Owner

Glenn, can you change this PR to the pvr_api_1_5_0 branch please? That way it will be part of the current pull request against my upstream repo.

@Glenn-1990 Glenn-1990 referenced this pull request
Merged

add timer conflict support #3

@Glenn-1990

ok, replaced by #3

@Glenn-1990 Glenn-1990 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 1, 2012
  1. @Glenn-1990

    add timer conflict support

    Glenn-1990 authored
This page is out of date. Refresh to see the latest.
View
38 addons/pvr.fortherecord.argus/src/fortherecordrpc.cpp
@@ -960,8 +960,9 @@ namespace ForTheRecord
return retval;
}
- /**
- * \brief Fetch the list of upcoming programs
+ /**
+ * \brief Fetch the list of upcoming programs from type 'recording'
+ * \currently not
*/
int GetUpcomingPrograms(Json::Value& response)
{
@@ -994,6 +995,39 @@ namespace ForTheRecord
}
/**
+ * \brief Fetch the list of upcoming recordings
+ */
+ int GetUpcomingRecordings(Json::Value& response)
+ {
+ int retval = -1;
+
+ XBMC->Log(LOG_DEBUG, "GetUpcomingRecordings");
+
+ // http://madcat:49943/ForTheRecord/Control/UpcomingRecordings/7?includeCancelled=true
+ retval = ForTheRecordJSONRPC("ForTheRecord/Control/UpcomingRecordings/7?includeActive=true", "", response);
+
+ if(retval >= 0)
+ {
+ if( response.type() == Json::arrayValue)
+ {
+ int size = response.size();
+ return size;
+ }
+ else
+ {
+ XBMC->Log(LOG_DEBUG, "Unknown response format. Expected Json::arrayValue\n");
+ return -1;
+ }
+ }
+ else
+ {
+ XBMC->Log(LOG_DEBUG, "GetUpcomingRecordings failed. Return value: %i\n", retval);
+ }
+
+ return retval;
+ }
+
+ /**
* \brief Fetch the list of currently active recordings
*/
int GetActiveRecordings(Json::Value& response)
View
8 addons/pvr.fortherecord.argus/src/fortherecordrpc.h
@@ -243,11 +243,17 @@ namespace ForTheRecord
int GetScheduleList(enum ChannelType channelType, Json::Value& response);
/**
- * \brief Fetch the list of upcoming programs
+ * \brief Fetch the list of upcoming programs from type 'recording'
+ * \currently not used
*/
int GetUpcomingPrograms(Json::Value& response);
/**
+ * \brief Fetch the list of upcoming recordings
+ */
+ int GetUpcomingRecordings(Json::Value& response);
+
+ /**
* \brief Fetch the list of currently active recordings
*/
int GetActiveRecordings(Json::Value& response);
View
27 addons/pvr.fortherecord.argus/src/pvrclient-fortherecord.cpp
@@ -811,7 +811,7 @@ int cPVRClientForTheRecord::GetNumTimers(void)
PVR_ERROR cPVRClientForTheRecord::GetTimers(ADDON_HANDLE handle)
{
- Json::Value activeRecordingsResponse, upcomingProgramsResponse;
+ Json::Value activeRecordingsResponse, upcomingRecordingsResponse;
int iNumberOfTimers = 0;
PVR_TIMER tag;
int numberoftimers;
@@ -827,7 +827,7 @@ PVR_ERROR cPVRClientForTheRecord::GetTimers(ADDON_HANDLE handle)
}
// pick up the upcoming recordings
- retval = ForTheRecord::GetUpcomingPrograms(upcomingProgramsResponse);
+ retval = ForTheRecord::GetUpcomingRecordings(upcomingRecordingsResponse);
if (retval < 0)
{
XBMC->Log(LOG_ERROR, "Unable to retrieve upcoming programs from server.");
@@ -835,12 +835,12 @@ PVR_ERROR cPVRClientForTheRecord::GetTimers(ADDON_HANDLE handle)
}
memset(&tag, 0 , sizeof(tag));
- numberoftimers = upcomingProgramsResponse.size();
+ numberoftimers = upcomingRecordingsResponse.size();
for (int i = 0; i < numberoftimers; i++)
{
cUpcomingRecording upcomingrecording;
- if (upcomingrecording.Parse(upcomingProgramsResponse[i]))
+ if (upcomingrecording.Parse(upcomingRecordingsResponse[i]))
{
tag.iClientIndex = iNumberOfTimers;
cChannel* pChannel = FetchChannel(upcomingrecording.ChannelId());
@@ -854,17 +854,34 @@ PVR_ERROR cPVRClientForTheRecord::GetTimers(ADDON_HANDLE handle)
tag.iClientChannelUid = pChannel->ID();
tag.startTime = upcomingrecording.StartTime();
tag.endTime = upcomingrecording.StopTime();
+
// build the XBMC PVR State
if (upcomingrecording.IsCancelled())
{
tag.state = PVR_TIMER_STATE_CANCELLED;
}
+ else if (upcomingrecording.IsInConflict())
+ {
+ if (upcomingrecording.IsAllocated())
+ tag.state = PVR_TIMER_STATE_CONFLICT_OK;
+ else
+ tag.state = PVR_TIMER_STATE_CONFLICT_NOK;
+ }
+ else if (!upcomingrecording.IsAllocated())
+ {
+ //not allocated --> won't be recorded
+ tag.state = PVR_TIMER_STATE_ERROR;
+ }
else
{
tag.state = PVR_TIMER_STATE_SCHEDULED;
+ }
+
+ if (tag.state == PVR_TIMER_STATE_SCHEDULED || tag.state == PVR_TIMER_STATE_CONFLICT_OK) //check if they are currently recording
+ {
if (activeRecordingsResponse.size() > 0)
{
- // Is the this upcoming program in the list of active recordings?
+ // Is the this upcoming recording in the list of active recordings?
for (Json::Value::UInt j = 0; j < activeRecordingsResponse.size(); j++)
{
cActiveRecording activerecording;
View
32 addons/pvr.fortherecord.argus/src/upcomingrecording.cpp
@@ -34,6 +34,8 @@ cUpcomingRecording::cUpcomingRecording(void)
stoptime = 0;
title = "";
iscancelled = false;
+ isallocated = true;
+ isinconflict = true;
}
cUpcomingRecording::~cUpcomingRecording(void)
@@ -43,26 +45,32 @@ bool cUpcomingRecording::Parse(const Json::Value& data)
{
int offset;
std::string t;
+ Json::Value channelobject,programobject;
+ programobject = data["Program"];
date = 0;
- t = data["StartTime"].asString();
+
+ t = programobject["StartTime"].asString();
starttime = ForTheRecord::WCFDateToTimeT(t, offset);
- t = data["StopTime"].asString();
+ t = programobject["StopTime"].asString();
stoptime = ForTheRecord::WCFDateToTimeT(t, offset);
- prerecordseconds = data["PreRecordSeconds"].asInt();
- postrecordseconds = data["PostRecordSeconds"].asInt();
- title = data["Title"].asString();
- iscancelled = data["IsCancelled"].asBool();
- upcomingprogramid = data["UpcomingProgramId"].asString();
- scheduleid = data["ScheduleId"].asString();
+ prerecordseconds = programobject["PreRecordSeconds"].asInt();
+ postrecordseconds = programobject["PostRecordSeconds"].asInt();
+ title = programobject["Title"].asString();
+ iscancelled = programobject["IsCancelled"].asBool();
+ upcomingprogramid = programobject["UpcomingProgramId"].asString();
+ scheduleid = programobject["ScheduleId"].asString();
// From the Program class pickup the C# Channel class
- Json::Value channelobject;
- channelobject = data["Channel"];
-
- // And -finally- our channel id
+ channelobject = programobject["Channel"];
channelid = channelobject["ChannelId"].asString();
channeldisplayname = channelobject["DisplayName"].asString();
+ if (data["CardChannelAllocation"].empty())
+ isallocated = false;
+
+ if (data["ConflictingPrograms"].empty())
+ isinconflict = false;
+
return true;
}
View
5 addons/pvr.fortherecord.argus/src/upcomingrecording.h
@@ -37,6 +37,9 @@ class cUpcomingRecording
bool iscancelled;
std::string upcomingprogramid;
std::string scheduleid;
+ bool isallocated;
+ bool isinconflict;
+
public:
cUpcomingRecording(void);
virtual ~cUpcomingRecording(void);
@@ -53,4 +56,6 @@ class cUpcomingRecording
bool IsCancelled(void) const { return iscancelled; }
const std::string& UpcomingProgramId(void) const { return upcomingprogramid; }
const std::string& ScheduleId(void) const { return scheduleid; }
+ bool IsAllocated(void) const { return isallocated; }
+ bool IsInConflict(void) const { return isinconflict; }
};
Something went wrong with that request. Please try again.