Ejemplo n.º 1
0
        public void Add(IProgramInfo programInfo)
        {
            var list = (List <ProgramInfoModel>) this.ProgramInfoModels;

            list.Add(this.CreateProgramInfoModel(programInfo));
            this.RaisePropertyChanged(nameof(this.ProgramInfoModels));
        }
Ejemplo n.º 2
0
        private UPnPError OnGetNowNextProgramForGroup(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context)
        {
            outParams = new List <object>();
            IProgramInfo programInfo = ServiceRegistration.Get <ITvProvider>() as IProgramInfo;

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

            int channelGroupId        = (int)inParams[0];
            IList <IProgram> programs = new List <IProgram>();
            IDictionary <int, IProgram[]> nowNextPrograms;

            // Flatten to simple list for UPnP transfer
            if (programInfo.GetNowAndNextForChannelGroup(new ChannelGroup {
                ChannelGroupId = channelGroupId
            }, out nowNextPrograms))
            {
                foreach (KeyValuePair <int, IProgram[]> nowNextProgram in nowNextPrograms)
                {
                    foreach (var program in nowNextProgram.Value)
                    {
                        if (program != null)
                        {
                            programs.Add(program);
                        }
                    }
                }
            }
            outParams = new List <object> {
                true, programs
            };
            return(null);
        }
Ejemplo n.º 3
0
        private static ProgramBank ReadPrograms <T>(EndianBinaryReader reader, int numPRGISlots) where T : IProgramInfo
        {
            long chunkOffset = FindChunk(reader, "prgi");

            if (chunkOffset == -1)
            {
                return(null);
            }
            else
            {
                chunkOffset += 0x10;
                var programInfos = new IProgramInfo[numPRGISlots];
                for (int i = 0; i < programInfos.Length; i++)
                {
                    ushort offset = reader.ReadUInt16(chunkOffset + (2 * i));
                    if (offset != 0)
                    {
                        programInfos[i] = reader.ReadObject <T>(offset + chunkOffset);
                    }
                }
                return(new ProgramBank
                {
                    ProgramInfos = programInfos,
                    KeyGroups = ReadKeyGroups(reader)
                });
            }
        }
Ejemplo n.º 4
0
        public void PromoteStartup(IProgramInfo programInfo)
        {
            this.DelayedProgramInfosModel.Remove(programInfo);
            var programLogic = this.CreateProgramLogic(programInfo);

            programLogic.Undo();
            this.StartupProgramInfosModel.Add(programInfo);
        }
Ejemplo n.º 5
0
        public void Remove(IProgramInfo programInfo)
        {
            var list = (List <ProgramInfoModel>) this.ProgramInfoModels;
            Func <ProgramInfoModel, bool> condition = pim => pim.ProgramInfo == programInfo;
            var programInfoModel = this.ProgramInfoModels.Single(condition);

            list.Remove(programInfoModel);
            this.RaisePropertyChanged(nameof(this.ProgramInfoModels));
        }
Ejemplo n.º 6
0
        public SerializableProgramInfo(IProgramInfo copyFrom)
        {
            var fileOrigin     = copyFrom.Origin as IFileOrigin;
            var registryOrigin = copyFrom.Origin as IRegistryOrigin;

            if (fileOrigin != null)
            {
                this.Origin = new SerializableFileOrigin(fileOrigin);
            }
            else if (registryOrigin != null)
            {
                this.Origin = new SerializableRegistryOrigin(registryOrigin);
            }

            this.StartInfo = new SerializableStartInfo(copyFrom.StartInfo);
        }
Ejemplo n.º 7
0
        private static void GetOnDemandDates(HtmlDocument document, IProgramInfo program)
        {
            try
            {
                var onDemand  = document.DocumentNode.Descendants().Where(node => node.GetAttributeValue("class", string.Empty).Equals("on-demand")).Single();
                var timeNodes = onDemand.Descendants().Where(node => node.Name == "time").ToList();
                foreach (var timeNode in timeNodes)
                {
                    timeNode.Descendants().Where(node => node.Name == "span").First().Remove();
                }

                program.OnDemandStarts = Convert.ToDateTime(timeNodes[0].InnerText);
                program.OnDemandEnds   = Convert.ToDateTime(timeNodes[1].InnerText);
            }
            catch
            {
            }
        }
Ejemplo n.º 8
0
        private UPnPError OnRemoveSchedule(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"));
            }

            ISchedule schedule = (ISchedule)inParams[0];
            bool      result   = scheduleControl.RemoveSchedule(schedule);

            outParams = new List <object> {
                result
            };
            return(null);
        }
Ejemplo n.º 9
0
        private void ProgramInfoProvider_ProgramInfoReceived(object sender, IProgramInfo e)
        {
            var metadata = new Metadata
            {
                Title = e.Title,
            };

            RaiseMetadataUpdated(metadata);

            _vposBaseAt = e.VposBaseAt;

            var newRooms = Tools.Distinct(_rooms, e.Rooms.Cast <IXmlWsRoomInfo>().ToList());

            if (newRooms.Count > 0)
            {
                _mainRoomThreadId = Math.Min(int.Parse(_mainRoomThreadId), newRooms.Select(r => int.Parse(r.ThreadId)).Min()).ToString();
                _rooms.AddRange(newRooms);
                _chatProvider.Add(newRooms);
            }
        }
Ejemplo n.º 10
0
        private UPnPError OnCreateSchedule(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];
            IProgram program;
            bool     result = programInfo.GetProgram(programId, out program) && scheduleControl.CreateSchedule(program);

            outParams = new List <object> {
                result
            };
            return(null);
        }
Ejemplo n.º 11
0
        private UPnPError OnGetRecordingStatus(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];
            IProgram        program;
            RecordingStatus recordingStatus = RecordingStatus.None;
            bool            result          = programInfo.GetProgram(programId, out program) && scheduleControl.GetRecordingStatus(program, out recordingStatus);

            outParams = new List <object> {
                result, recordingStatus.ToString()
            };
            return(null);
        }
Ejemplo n.º 12
0
        private UPnPError OnGetProgramsByTitle(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context)
        {
            outParams = new List <object>();
            IProgramInfo programInfo = ServiceRegistration.Get <ITvProvider>() as IProgramInfo;

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

            string   title    = (string)inParams[0];
            DateTime timeFrom = (DateTime)inParams[1];
            DateTime timeTo   = (DateTime)inParams[2];

            IList <IProgram> programs;
            bool             result = programInfo.GetPrograms(title, timeFrom, timeTo, out programs);

            outParams = new List <object> {
                result, programs
            };
            return(null);
        }
Ejemplo n.º 13
0
        private UPnPError OnGetNowNextProgram(DvAction action, IList <object> inParams, out IList <object> outParams, CallContext context)
        {
            outParams = new List <object>();
            IProgramInfo programInfo = ServiceRegistration.Get <ITvProvider>() as IProgramInfo;

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

            int      channelId = (int)inParams[0];
            IProgram programNow;
            IProgram programNext;
            bool     result = programInfo.GetNowNextProgram(new Channel {
                ChannelId = channelId
            }, out programNow, out programNext);

            outParams = new List <object> {
                result, programNow, programNext
            };
            return(null);
        }
Ejemplo n.º 14
0
        private string GetSearchParamsString(IProgramInfo program)
        {
            string result = $"?apikey={omdbKey}&t=";

            var titleWords = program.Title.Split(' ');

            for (int index = 0; index < titleWords.Length; index++)
            {
                result += titleWords[index];
                if (index + 1 < titleWords.Length)
                {
                    result += "+";
                }
            }

            if (program.Year > -1)
            {
                result = $"{result}&&y={program.Year}";
            }

            return(result);
        }
Ejemplo n.º 15
0
        public async Task <Program> GetProgramDetails(IProgramInfo program)
        {
            var searchString = GetSearchParamsString(program);

            try
            {
                var response = await _httpClient.GetAsync(searchString);

                var deserializedProgram = await response.Content.ReadAsAsync <Program>();

                deserializedProgram.OnDemandStarts = program.OnDemandStarts;
                deserializedProgram.OnDemandEnds   = program.OnDemandEnds;
                return(deserializedProgram);
            }
            catch (Exception)
            {
                return(new Program()
                {
                    Title = program.Title,
                    Year = program.Year
                });
            }
        }
Ejemplo n.º 16
0
 public FileProgramLogic(IProgramInfo programInfo) : base(programInfo)
 {
 }
Ejemplo n.º 17
0
        private IProgramLogic CreateProgramLogic(IProgramInfo programInfo)
        {
            var programLogic = this._dependencies.ProgramLogicFactory.Get(programInfo);

            return(programLogic);
        }
Ejemplo n.º 18
0
 public ProgramInfoModel(IProgramInfo programInfo)
 {
     this.ProgramInfo = programInfo;
 }
Ejemplo n.º 19
0
 public RegistryProgramLogic(IProgramInfo programInfo) : base(programInfo)
 {
 }
Ejemplo n.º 20
0
 protected AbstractProgramLogic(IProgramInfo programInfo)
 {
     this._programInfo = programInfo;
 }
Ejemplo n.º 21
0
 private ProgramInfoModel CreateProgramInfoModel(IProgramInfo programInfo)
 {
     return(new ProgramInfoModel(programInfo));
 }
Ejemplo n.º 22
0
 public ProxyProgramLogic(IProgramInfo programInfo)
 {
     this._programInfo          = programInfo;
     this._serializationManager = new ProxySerializationManager();
 }