protected void ShowScheduleChangeNotifications(TvServerState oldState, TvServerState newState)
        {
            var sm       = ServiceRegistration.Get <ISettingsManager>();
            var settings = sm.Load <SlimTvClientSettings>();

            if (settings.RecordingNotificationDuration < 1 ||
                (!settings.ShowRecordingStartedNotifications && !settings.ShowRecordingEndedNotifications))
            {
                return;
            }

            IEnumerable <ISchedule> startedSchedules;
            IEnumerable <ISchedule> endedSchedules;

            GetChangedSchedules(oldState, newState, out startedSchedules, out endedSchedules);

            TimeSpan duration = TimeSpan.FromSeconds(settings.RecordingNotificationDuration);

            if (settings.ShowRecordingStartedNotifications)
            {
                foreach (ISchedule schedule in startedSchedules)
                {
                    ShowRecordingStartedNotification(schedule, duration);
                }
            }

            if (settings.ShowRecordingEndedNotifications)
            {
                foreach (ISchedule schedule in endedSchedules)
                {
                    ShowRecordingEndedNotification(schedule, duration);
                }
            }
        }
        protected void OnTvServerStateChanged(TvServerState newState)
        {
            TvServerState oldState = _currentTvServerState;

            _currentTvServerState = newState;
            ShowScheduleChangeNotifications(oldState, newState);
        }
Esempio n. 3
0
        protected void UpdateServerState()
        {
            var state = new TvServerState {
                IsRecording = _tvControl.IsAnyCardRecording()
            };

            ServiceRegistration.Get <IServerStateService>().UpdateState(TvServerState.STATE_ID, state);
        }
        protected void GetChangedSchedules(TvServerState oldState, TvServerState newState, out IEnumerable <ISchedule> started, out IEnumerable <ISchedule> ended)
        {
            IList <ISchedule> oldSchedules = oldState != null && oldState.CurrentlyRecordingSchedules != null ?
                                             oldState.CurrentlyRecordingSchedules : new List <ISchedule>();
            IList <ISchedule> newSchedules = newState != null && newState.CurrentlyRecordingSchedules != null ?
                                             newState.CurrentlyRecordingSchedules : new List <ISchedule>();

            started = newSchedules.Where(s => !oldSchedules.Any(os => os.ScheduleId == s.ScheduleId));
            ended   = oldSchedules.Where(s => !newSchedules.Any(ns => ns.ScheduleId == s.ScheduleId));
        }
        protected void InitServerState()
        {
            //Get an initial state to avoid showing notifications for events that happened before the client was started.
            var ssm = ServiceRegistration.Get <IServerStateManager>();

            if (!ssm.TryGetState(TvServerState.STATE_ID, out _currentTvServerState))
            {
                _currentTvServerState = null;
            }
        }
Esempio n. 6
0
        protected void UpdateServerState()
        {
            IList <ISchedule> currentlyRecordingSchedules = Recording.ListAllActive().Where(r => r.IsRecording)
                                                            .Select(r => r.ReferencedSchedule().ToSchedule()).ToList();

            TvServerState state = new TvServerState
            {
                IsRecording = _tvControl.IsAnyCardRecording(),
                CurrentlyRecordingSchedules = currentlyRecordingSchedules
            };

            ServiceRegistration.Get <IServerStateService>().UpdateState(TvServerState.STATE_ID, state);
        }
        protected void UpdateServerState()
        {
            IInternalControllerService controller = GlobalServiceProvider.Instance.Get <IInternalControllerService>();
            IRecordingService          recordings = GlobalServiceProvider.Get <IRecordingService>();
            IList <ISchedule>          currentlyRecordingSchedules = recordings.ListAllActiveRecordingsByMediaType(MediaTypeEnum.TV)
                                                                     .Union(recordings.ListAllActiveRecordingsByMediaType(MediaTypeEnum.Radio))
                                                                     .Select(r => r.Schedule.ToSchedule()).ToList();

            TvServerState state = new TvServerState
            {
                IsRecording = controller.IsAnyCardRecording(),
                CurrentlyRecordingSchedules = currentlyRecordingSchedules
            };

            ServiceRegistration.Get <IServerStateService>().UpdateState(TvServerState.STATE_ID, state);
        }