コード例 #1
0
 private void InitPassword(ConfigFileData config)
 {
     if (config.password.Get <string>() != null)
     {
         Password.IsChecked = true;
     }
 }
コード例 #2
0
        public static async Task <Task> Action(ServerHandler shandler, HTTPRequest request, Stream body, IProxyHTTPEncoder encoder)
        {
            var auth = await Helpers.ReadMessageFromStreamAndAuthenticate(shandler, 1024 * 16, body);

            if (!auth.success)
            {
                await encoder.WriteQuickHeader(403, "Must be authenticated.");

                await encoder.BodyWriteSingleChunk(JsonConvert.SerializeObject(new CommitConfigurationResponse()
                {
                    success = false,
                }));

                return(Task.CompletedTask);
            }

            if (!auth.user.admin)
            {
                await encoder.WriteQuickHeader(403, "Must be admin.");

                await encoder.BodyWriteSingleChunk(JsonConvert.SerializeObject(new CommitConfigurationResponse()
                {
                    success = false,
                }));

                return(Task.CompletedTask);
            }

            var req = JsonConvert.DeserializeObject <CommitConfigurationRequest>(auth.payload);

            var fp = File.OpenWrite(
                Path.Combine(shandler.config_path, $"config_{req.deviceid}.data")
                );

            var file_data = new ConfigFileData()
            {
                userid      = req.userid,
                config_data = req.config_data,
            };

            // TODO: *think* reliable operation and atomic as possible
            var config_bytes_utf8 = Encoding.UTF8.GetBytes(
                JsonConvert.SerializeObject(file_data)
                );
            await fp.WriteAsync(config_bytes_utf8, 0, config_bytes_utf8.Length);

            fp.Dispose();

            await encoder.WriteQuickHeader(200, "OK");

            await encoder.BodyWriteSingleChunk(JsonConvert.SerializeObject(new CommitConfigurationResponse()
            {
                success = true,
            }));

            return(Task.CompletedTask);
        }
コード例 #3
0
        public Settings()
        {
            InitializeComponent();
            ConfigFile     cfg    = new ConfigFile();
            ConfigFileData config = cfg.Load();

            InitFolderName(config);
            InitPassword(config);
            InitEncrypt(config);
            InitTitle(config);
            InitTags(config);
        }
コード例 #4
0
        public bool Execute(string[] args, string results)
        {
            ConfigFileData data = JsonConvertor.ConvertToConfigFileData(results);

            model.InputDirs    = data.InputDirs;
            model.LogName      = data.LogName;
            model.OutputDir    = data.OutputDir;
            model.SourceDir    = data.SourceDir;
            model.ThumnailSize = data.ThumnailSize;

            return(true);
        }
コード例 #5
0
        private void InitTags(ConfigFileData config)
        {
            BlockTags.IsChecked = config.block_tags.Get <bool>();
            List <string> tags = config.except_tags.Get <List <string> >();

            if (tags != null)
            {
                foreach (string tag in tags)
                {
                    ExceptTagList.Add(tag);
                }
            }
            TagList2ListBox();
        }
コード例 #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ConfigFile     config = new ConfigFile();
            ConfigFileData data   = Global.config;
            string         pwd    = null;

            if (Password.IsChecked ?? false)
            {
                pwd = FilePassword.Default(new InputBox("비밀번호를 입력해주세요.", "비밀번호 설정", "").ShowDialog());
            }
            data.password.Set(pwd);
            config.config = data;
            config.Save();
        }
コード例 #7
0
        public string Execute(string[] args, out bool result)
        {
            ConfigFileData cfd = new ConfigFileData();

            try
            {
                cfd.OutputDir    = ReadAppConfig.ReadSetting("OutPutDir");
                cfd.SourceDir    = ReadAppConfig.readAppSettings("ImageServiceSource");
                cfd.LogName      = ReadAppConfig.readAppSettings("ImageServiceLog");
                cfd.ThumnailSize = ReadAppConfig.ReadThumbnailSize("ThumbnailSize");
                cfd.InputDirs    = ReadAppConfig.ReadSetting("Handlers").Split(';');
                result           = true;
                return(JsonConvertor.ConvertToJson(cfd));
            }
            catch
            {
                result = false;
                return("problem occured");
            }
        }
コード例 #8
0
 /// <summary>
 /// executes the command
 /// <param name= args> command's args </param>
 /// <param name= results> a string containing the necessary info
 /// from the appconfig</param>
 /// <return> true if successful, false for exception
 /// </summary>
 public bool Execute(string[] args, string results)
 {
     try
     {
         //gets the appsettings in order to update the values of the gui view
         ConfigFileData settings = JsonConvertor.ConvertToConfigFileData(results);
         this.model.OutputDirectory   = settings.OutputDir;
         this.model.ServiceLogName    = settings.LogName;
         this.model.ServiceSourceName = settings.SourceDir;
         this.model.ThumbSize         = settings.ThumnailSize.ToString();
         foreach (string handler in settings.InputDirs)
         {
             this.model.DirectoriesCollection.Add(handler);
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
コード例 #9
0
ファイル: HitomiPanel.cs プロジェクト: 2dongsik2/HitomiViewer
        public override void ContextSetup()
        {
            Folder_Remove.Visibility        = Visibility.Collapsed;
            Folder_Hiyobi_Search.Visibility = Visibility.Collapsed;
            Hiyobi_Download.Visibility      = Visibility.Collapsed;
            Pixiv_Download.Visibility       = Visibility.Collapsed;
            AtHitomi.Visibility             = Visibility.Collapsed;
            Encrypt.Visibility    = Visibility.Collapsed;
            Decrypt.Visibility    = Visibility.Collapsed;
            CopyNumber.Visibility = Visibility.Visible;
            if (file)
            {
                Folder_Remove.Visibility = Visibility.Visible;
                if (Global.config.password.Get <string>() != null)
                {
                    Encrypt.Visibility = Visibility.Visible;
                    Decrypt.Visibility = Visibility.Visible;
                }
            }
            if (h.id == null || h.id == "")
            {
                DownloadData.Visibility  = Visibility.Collapsed;
                DownloadImage.Visibility = Visibility.Collapsed;
                CopyNumber.Visibility    = Visibility.Collapsed;
            }
            ConfigFile     cfg  = new ConfigFile();
            ConfigFileData obj  = cfg.config;
            List <string>  favs = obj.favorites.Get <List <string> >();

            if (favs.Contains(h.id))
            {
                Favorite.Visibility       = Visibility.Collapsed;
                FavoriteRemove.Visibility = Visibility.Visible;
            }
            else
            {
                Favorite.Visibility       = Visibility.Visible;
                FavoriteRemove.Visibility = Visibility.Collapsed;
            }
        }
コード例 #10
0
 private void InitTitle(ConfigFileData config)
 {
     EncryptTitle.IsChecked = config.encrypt_title.Get <bool>();
     RandomTitle.IsChecked  = config.random_title.Get <bool>();
 }
コード例 #11
0
 private void InitEncrypt(ConfigFileData config)
 {
     FileEncrypt.IsChecked    = config.file_encrypt.Get <bool>();
     AutoEncryption.IsChecked = config.download_file_encrypt.Get <bool>();
 }
コード例 #12
0
 private void InitFolderName(ConfigFileData config)
 {
     FolderName.Content = config.download_folder.Get <string>();
 }