示例#1
0
        public bool?WriteProfiles(string devices, [FromBody] ProfileSettings settings)
        {
            // Validate
            ServerRuntime.TestAdminAccess();

            // List of profiles to use
            var profiles = settings.SystemProfiles.Where(profile => profile.UsedForRecording).Select(profile => profile.Name).ToList();

            // Move default to the front
            var defaultIndex = profiles.IndexOf(settings.DefaultProfile);

            if (defaultIndex >= 0)
            {
                // Insert at the very beginning
                profiles.Insert(0, profiles[defaultIndex]);
                profiles.RemoveAt(defaultIndex + 1);
            }

            // Prepare
            var update = VCRConfiguration.Current.BeginUpdate(SettingNames.Profiles);

            // Fill
            update[SettingNames.Profiles].NewValue = string.Join("|", profiles);

            // Process
            return(ServerRuntime.Update(update.Values, ServerRuntime.VCRServer.UpdateProfiles(settings.SystemProfiles, profile => profile.Name, (profile, device) => profile.WriteBack(device))));
        }
示例#2
0
        public OtherSettings ReadOtherSettings(string other)
        {
            // Validate
            ServerRuntime.TestAdminAccess();

            // Create response
            return
                (new OtherSettings
            {
                DelayAfterForcedHibernation = (uint)VCRConfiguration.Current.DelayAfterForcedHibernation.TotalMinutes,
                SuppressDelayAfterForcedHibernation = VCRConfiguration.Current.SuppressDelayAfterForcedHibernation,
                DisablePCRFromMPEG2 = VCRConfiguration.Current.DisablePCRFromMPEG2Generation,
                DisablePCRFromH264 = VCRConfiguration.Current.DisablePCRFromH264Generation,
                AllowBasic = VCRConfiguration.Current.EnableBasicAuthentication,
                AllowHibernate = VCRConfiguration.Current.MayHibernateSystem,
                HibernationDelay = VCRConfiguration.Current.HibernationDelay,
                SSLPort = VCRConfiguration.Current.WebServerSecureTcpPort,
                UseSSL = VCRConfiguration.Current.EncryptWebCommunication,
                UseStandBy = VCRConfiguration.Current.UseS3ForHibernate,
                ArchiveTime = VCRConfiguration.Current.ArchiveLifeTime,
                ProtocolTime = VCRConfiguration.Current.LogLifeTime,
                WebPort = VCRConfiguration.Current.WebServerTcpPort,
                Logging = VCRConfiguration.Current.LoggingLevel,
            });
        }
示例#3
0
        public ProfileSettings ReadProfiles(string devices)
        {
            // Validate
            ServerRuntime.TestAdminAccess();

            // Helper
            string defaultName;

            // Create response
            var settings =
                new ProfileSettings
            {
                SystemProfiles =
                    ServerRuntime
                    .VCRServer
                    .GetProfiles(ConfigurationProfile.Create, out defaultName)
                    .OrderBy(profile => profile.Name, ProfileManager.ProfileNameComparer)
                    .ToArray()
            };

            // Merge default
            settings.DefaultProfile = defaultName;

            // Report
            return(settings);
        }
示例#4
0
        public string[] Browse(string browse, bool toParent = false, string root = null)
        {
            // Validate
            ServerRuntime.TestAdminAccess();

            // See if we can move up
            if (!string.IsNullOrEmpty(root))
            {
                if (toParent)
                {
                    if (StringComparer.InvariantCultureIgnoreCase.Equals(root, Path.GetPathRoot(root)))
                    {
                        root = null;
                    }
                    else
                    {
                        root = Path.GetDirectoryName(root);
                    }
                }
            }

            // Devices
            var names = string.IsNullOrEmpty(root)
                ? DriveInfo
                        .GetDrives()
                        .Where(drive => drive.DriveType == DriveType.Fixed)
                        .Where(drive => drive.IsReady)
                        .Select(drive => drive.RootDirectory.FullName)
                : Directory
                        .GetDirectories(root);

            // Report
            return(new[] { root }.Concat(names.OrderBy(name => name, StringComparer.InvariantCultureIgnoreCase)).ToArray());
        }
示例#5
0
        public SecuritySettings ReadSecurity(string security)
        {
            // Validate
            ServerRuntime.TestAdminAccess();

            // Report
            return
                (new SecuritySettings
            {
                AdminRole = VCRConfiguration.Current.AdminRole,
                UserRole = VCRConfiguration.Current.UserRole,
            });
        }
示例#6
0
        public DirectorySettings ReadDirectory(string directory)
        {
            // Validate
            ServerRuntime.TestAdminAccess();

            // Report
            return
                (new DirectorySettings
            {
                TargetDirectories = VCRConfiguration.Current.TargetDirectoriesNames.ToArray(),
                RecordingPattern = VCRConfiguration.Current.FileNamePattern,
            });
        }
示例#7
0
        public bool Validate(string validate, string directory)
        {
            // Validate
            ServerRuntime.TestAdminAccess();

            // Be safe
            try
            {
                // Test
                return(Directory.Exists(directory));
            }
            catch (Exception)
            {
                // Nope
                return(false);
            }
        }
示例#8
0
        public SourceScanSettings ReadSoureScan(string scan)
        {
            // Validate
            ServerRuntime.TestAdminAccess();

            // Load
            var interval = VCRConfiguration.Current.SourceListUpdateInterval;
            var join     = VCRConfiguration.Current.SourceListJoinThreshold;

            // Report
            return
                (new SourceScanSettings
            {
                Hours = VCRConfiguration.Current.SourceListUpdateHoursAsArray.OrderBy(hour => hour).ToArray(),
                Threshold = join.HasValue ? (int)join.Value.TotalDays : default(int?),
                MergeLists = VCRConfiguration.Current.MergeSourceListUpdateResult,
                Duration = VCRConfiguration.Current.SourceListUpdateDuration,
                Interval = (interval != 0) ? interval : default(int?),
            });
        }
示例#9
0
        public GuideSettings ReadGuide(string guide)
        {
            // Validate
            ServerRuntime.TestAdminAccess();

            // Load
            var interval = VCRConfiguration.Current.ProgramGuideUpdateInterval;
            var join     = VCRConfiguration.Current.ProgramGuideJoinThreshold;

            // Report
            return
                (new GuideSettings
            {
                Sources = VCRConfiguration.Current.ProgramGuideSourcesAsArray.OrderBy(name => name, StringComparer.InvariantCultureIgnoreCase).ToArray(),
                Hours = VCRConfiguration.Current.ProgramGuideUpdateHoursAsArray.OrderBy(hour => hour).ToArray(),
                Interval = interval.HasValue ? (int)interval.Value.TotalHours : default(int?),
                Threshold = join.HasValue ? (int)join.Value.TotalHours : default(int?),
                Duration = VCRConfiguration.Current.ProgramGuideUpdateDuration,
                WithUKGuide = VCRConfiguration.Current.EnableFreeSat,
            });
        }