Exemplo n.º 1
0
        protected virtual RecordingStatus?CreateOrDeleteSchedule(IProgram program, ScheduleRecordingType recordingType = ScheduleRecordingType.Once)
        {
            IScheduleControl scheduleControl = _tvHandler.ScheduleControl;
            RecordingStatus? newStatus       = null;

            if (scheduleControl != null)
            {
                RecordingStatus?recordingStatus = GetRecordingStatus(program);
                if (!recordingStatus.HasValue)
                {
                    return(null);
                }
                if (recordingStatus.Value.HasFlag(RecordingStatus.Scheduled) || recordingStatus.Value.HasFlag(RecordingStatus.SeriesScheduled))
                {
                    if (scheduleControl.RemoveScheduleForProgram(program, recordingType))
                    {
                        newStatus = RecordingStatus.None;
                    }
                }
                else
                {
                    ISchedule schedule;
                    if (scheduleControl.CreateSchedule(program, recordingType, out schedule))
                    {
                        newStatus = recordingType == ScheduleRecordingType.Once ? RecordingStatus.Scheduled : RecordingStatus.SeriesScheduled;
                    }
                }
            }
            return(newStatus);
        }
        private UPnPError OnRemoveScheduleForProgram(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context)
        {
            outParams = new List <object>();
            IProgramInfo     programInfo     = ServiceRegistration.Get <ITvProvider>() as IProgramInfo;
            IScheduleControl scheduleControl = ServiceRegistration.Get <ITvProvider>() as IScheduleControl;

            if (programInfo == null || scheduleControl == null)
            {
                return(new UPnPError(500, "IProgramInfo or IScheduleControl service not available"));
            }

            int programId = (int)inParams[0];
            ScheduleRecordingType recordingType = (ScheduleRecordingType)inParams[1];
            IProgram program;
            bool     result = programInfo.GetProgram(programId, out program) && scheduleControl.RemoveScheduleForProgram(program, recordingType);

            outParams = new List <object> {
                result
            };
            return(null);
        }