public void DecryptImage() { if (!OnmemoryImageManager.Instance.Exists(this.ID)) { var image = EncryptImageFacade.FindBy(this.ID); Encryptor.Decrypt(image.EncryptFilePath, Configuration.Password); } }
private static bool InternalGenerateThumbnail(ImageViewModel target, DataOperationUnit dataOpUnit) { lock (target) { //暗号化している場合は無視する if (!Configuration.ApplicationConfiguration.LibraryIsEncrypted && !File.Exists(target.AbsoluteMasterPath)) { throw new FileNotFoundException(target.AbsoluteMasterPath); } var thumbnail = new ThumbnailViewModel(); thumbnail.ID = target.ID; thumbnail.ImageID = target.ID; var encryptImage = EncryptImageFacade.FindBy(target.ID); if (encryptImage != null) { //暗号化実施時はサムネイル画像を出力しない s_logger.Info($"Sunctum will not output a thumbnail image because it is in encrypted. {target.ID}"); } else { try { thumbnail.RelativeMasterPath = ThumbnailGenerator.SaveThumbnail(target.AbsoluteMasterPath, target.ID.ToString("N") + System.IO.Path.GetExtension(target.AbsoluteMasterPath)); } catch (Exception e) { s_logger.Warn(e); return(false); } s_logger.Debug($"Generate thumbnail ImageID={target.ID}"); } Task.Factory.StartNew(() => RecordThumbnail(thumbnail)); //Apply thumbnail target.Thumbnail = thumbnail; return(true); } }
public bool UnlockIfLocked() { var encryptedItems = EncryptImageFacade.FindAll(); if (encryptedItems.Count() == 0) { return(false); } InputPasswordDialog dialog = new InputPasswordDialog("このライブラリは暗号化されています。閲覧するにはパスワードが必要です。"); if (dialog.ShowDialog() == true) { Configuration.ApplicationConfiguration.Password = dialog.Password; return(true); } else { return(false); } }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { var books = LibraryManager.Value.BookSource; foreach (var book in books) { ContentsLoadTask.FillContents(LibraryManager.Value, book); var images = book.Contents; foreach (var image in images) { ContentsLoadTask.Load(image); sequence.Add(() => _TargetEncryptImage = EncryptImageFacade.FindBy(image.Image.ID)); sequence.Add(() => Encryptor.Decrypt(_TargetEncryptImage.EncryptFilePath, image.Image.AbsoluteMasterPath, Password)); sequence.Add(() => File.Delete($"{Configuration.ApplicationConfiguration.WorkingDirectory}\\{Specifications.MASTER_DIRECTORY}\\{image.Image.ID}{Path.GetExtension(image.Image.AbsoluteMasterPath)}")); sequence.Add(() => EncryptImageFacade.DeleteBy(image.Image.ID)); } } sequence.Add(() => OnmemoryImageManager.Instance.Clear()); sequence.Add(() => Configuration.ApplicationConfiguration.Password = null); sequence.Add(() => Configuration.ApplicationConfiguration.LibraryIsEncrypted = false); }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(() => TaskManager.Enqueue(LibraryResettingService.GetTaskSequence())); sequence.Add(() => TaskManager.Enqueue(RecentOpenedLibraryUpdating.GetTaskSequence())); sequence.Add(() => TagManager.Load()); sequence.Add(() => AuthorManager.LoadAsync()); sequence.Add(() => TaskManager.Enqueue(BookLoadingService.GetTaskSequence())); sequence.Add(() => Configuration.ApplicationConfiguration.LibraryIsEncrypted = EncryptImageFacade.AnyEncrypted()); }