public LowResImageCache(BookRenamedEvent bookRenamedEvent) { _bookRenamedEvent = bookRenamedEvent; _paths = new Dictionary <string, string>(); _cacheFolder = new TemporaryFolder("Bloom"); _bookRenamedEvent.Subscribe(OnBookRenamed); }
public LowResImageCache(BookRenamedEvent bookRenamedEvent) { _bookRenamedEvent = bookRenamedEvent; _paths = new Dictionary <string, string>(); _cacheFolder = Path.Combine(Path.GetTempPath(), "Bloom"); _bookRenamedEvent.Subscribe(OnBookRenamed); }
public LowResImageCache(BookRenamedEvent bookRenamedEvent) { _bookRenamedEvent = bookRenamedEvent; _paths = new Dictionary<string, string>(); _cacheFolder = new TemporaryFolder("Bloom"); _bookRenamedEvent.Subscribe(OnBookRenamed); }
public LowResImageCache(BookRenamedEvent bookRenamedEvent) { _bookRenamedEvent = bookRenamedEvent; _paths = new Dictionary<string, string>(); _cacheFolder = Path.Combine(Path.GetTempPath(), "Bloom"); _bookRenamedEvent.Subscribe(OnBookRenamed); }
public RuntimeImageProcessor(BookRenamedEvent bookRenamedEvent) { _bookRenamedEvent = bookRenamedEvent; _originalPathToProcessedVersionPath = new ConcurrentDictionary <string, string>(); _imageFilesToReturnUnprocessed = new ConcurrentDictionary <string, bool>(); _cacheFolder = Path.Combine(Path.GetTempPath(), "Bloom"); _bookRenamedEvent.Subscribe(OnBookRenamed); }
public RuntimeImageProcessor(BookRenamedEvent bookRenamedEvent) { _bookRenamedEvent = bookRenamedEvent; _originalPathToProcessedVersionPath = new ConcurrentDictionary <string, string>(); _imageFilesToReturnUnprocessed = new ConcurrentDictionary <string, bool>(); _cacheFolder = Path.Combine(Path.GetTempPath(), "Bloom"); _bookRenamedEvent.Subscribe(OnBookRenamed); _convertWhiteToTransparent = new ImageAttributes(); _convertWhiteToTransparent.SetColorKey(Color.FromArgb(253, 253, 253), Color.White); }
public RuntimeImageProcessor(BookRenamedEvent bookRenamedEvent) { _bookRenamedEvent = bookRenamedEvent; _originalPathToProcessedVersionPath = new ConcurrentDictionary<string, string>(); _imageFilesToReturnUnprocessed = new ConcurrentDictionary<string, bool>(); _cacheFolder = Path.Combine(Path.GetTempPath(), "Bloom"); _bookRenamedEvent.Subscribe(OnBookRenamed); _convertWhiteToTransparent = new ImageAttributes(); _convertWhiteToTransparent.SetColorKey(Color.FromArgb(253, 253, 253), Color.White); }
public BookStorage(string folderPath, Palaso.IO.IChangeableFileLocator baseFileLocator, BookRenamedEvent bookRenamedEvent, CollectionSettings collectionSettings) { _folderPath = folderPath; //we clone becuase we'll be customizing this for use by just this book _fileLocator = (IChangeableFileLocator)baseFileLocator.CloneAndCustomize(new string[] {}); _bookRenamedEvent = bookRenamedEvent; _collectionSettings = collectionSettings; ExpensiveInitialization(); }
public AccessibilityCheckApi(BloomWebSocketServer webSocketServer, BookSelection bookSelection, BookRenamedEvent bookRenamedEvent, BookSavedEvent bookSavedEvent, EpubMaker.Factory epubMakerFactory, PublishEpubApi epubApi) { _webSocketServer = webSocketServer; var progress = new WebSocketProgress(_webSocketServer, kWebSocketContext); _webSocketProgress = progress.WithL10NPrefix("AccessibilityCheck."); _epubApi = epubApi; bookSelection.SelectionChanged += (unused1, unused2) => { _webSocketServer.SendEvent(kWebSocketContext, kBookSelectionChanged); }; // we get this when the book is renamed bookRenamedEvent.Subscribe((book) => { RefreshClient(); }); // we get this when the contents of the page might have changed bookSavedEvent.Subscribe((book) => { RefreshClient(); }); }
public BookStorage(string folderPath, Palaso.IO.IChangeableFileLocator baseFileLocator, BookRenamedEvent bookRenamedEvent, CollectionSettings collectionSettings) { _folderPath = folderPath; //we clone becuase we'll be customizing this for use by just this book _fileLocator = (IChangeableFileLocator) baseFileLocator.CloneAndCustomize(new string[]{}); _bookRenamedEvent = bookRenamedEvent; _collectionSettings = collectionSettings; ExpensiveInitialization(); }
public TeamCollectionManager(string localCollectionPath, BloomWebSocketServer webSocketServer, BookRenamedEvent bookRenamedEvent, BookStatusChangeEvent bookStatusChangeEvent, BookSelection bookSelection, CollectionClosing collectionClosingEvent, BookCollectionHolder bookCollectionHolder) { _webSocketServer = webSocketServer; _bookStatusChangeEvent = bookStatusChangeEvent; _localCollectionFolder = Path.GetDirectoryName(localCollectionPath); _bookCollectionHolder = bookCollectionHolder; BookSelection = bookSelection; collectionClosingEvent?.Subscribe((x) => { // When closing the collection...especially if we're restarting due to // changed settings!...we need to save any settings changes to the repo. // In such cases we can't safely wait for the change watcher to write things, // because (a) if we're shutting down for good, we just might not detect the // change before everything shuts down; and (b) if we're reopening the collection, // we might overwrite the change with current collection settings before we // save the new ones. if (CurrentCollection != null) { CurrentCollection.SyncLocalAndRepoCollectionFiles(false); } else if (Settings.HaveEnterpriseFeatures && CurrentCollectionEvenIfDisconnected != null && CurrentCollectionEvenIfDisconnected is DisconnectedTeamCollection disconnectedTC && disconnectedTC.DisconnectedBecauseNoEnterprise) { // We were disconnected because of Enterprise being off, but now the user has // turned Enterprise on again. We really need to save that, even though we usually don't // save settings changes when disconnected. Otherwise, restarting will restore the // no-enterprise state, and we will be stuck. // Note: We don't need to check for admin privileges here. If the user isn't an admin, // he could not have made any changes to settings, including turning on enterprise. var tempCollectionLinkPath = GetTcLinkPathFromLcPath(_localCollectionFolder); if (RobustFile.Exists(tempCollectionLinkPath)) { try { var repoFolderPath = RepoFolderPathFromLinkPath(tempCollectionLinkPath); var tempCollection = new FolderTeamCollection(this, _localCollectionFolder, repoFolderPath, bookCollectionHolder: _bookCollectionHolder); var problemWithConnection = tempCollection.CheckConnection(); if (problemWithConnection == null) { tempCollection.SyncLocalAndRepoCollectionFiles(false); } else { NonFatalProblem.Report(ModalIf.All, PassiveIf.All, "Bloom could not save your settings to the Team Collection: " + problemWithConnection.TextForDisplay, null, null, true); } } catch (Exception ex) { NonFatalProblem.Report(ModalIf.All, PassiveIf.All, "Bloom could not save your settings to the Team Collection", null, ex, true); } } // What if there's NOT a TC link file? Then it would be pathological to have a CurrentCollectionEvenIfDisconnected. // It's no longer a TC, so we don't need to save the settings to the TC. For now I'm just not going to do anything. } }); bookRenamedEvent.Subscribe(pair => { CurrentCollectionEvenIfDisconnected?.HandleBookRename(Path.GetFileName(pair.Key), Path.GetFileName(pair.Value)); }); var impersonatePath = Path.Combine(_localCollectionFolder, "impersonate.txt"); if (RobustFile.Exists(impersonatePath)) { var lines = RobustFile.ReadAllLines(impersonatePath); _overrideCurrentUser = lines.FirstOrDefault(); if (lines.Length > 1) { _overrideMachineName = lines[1]; } if (lines.Length > 2) { _overrideCurrentUserFirstName = lines[2]; } if (lines.Length > 3) { _overrideCurrentUserSurname = lines[3]; } } var localCollectionLinkPath = GetTcLinkPathFromLcPath(_localCollectionFolder); if (RobustFile.Exists(localCollectionLinkPath)) { try { var repoFolderPath = RepoFolderPathFromLinkPath(localCollectionLinkPath); CurrentCollection = new FolderTeamCollection(this, _localCollectionFolder, repoFolderPath, bookCollectionHolder: _bookCollectionHolder); // will be replaced if CheckConnection fails // BL-10704: We set this to the CurrentCollection BEFORE checking the connection, // so that there will be a valid MessageLog if we need it during CheckConnection(). // If CheckConnection() fails, it will reset this to a DisconnectedTeamCollection. CurrentCollectionEvenIfDisconnected = CurrentCollection; if (CheckConnection()) { CurrentCollection.SocketServer = SocketServer; CurrentCollection.TCManager = this; // Later, we will sync everything else, but we want the current collection settings before // we create the CollectionSettings object. if (ForceNextSyncToLocal) { ForceNextSyncToLocal = false; CurrentCollection.CopyRepoCollectionFilesToLocal(_localCollectionFolder); } else { CurrentCollection.SyncLocalAndRepoCollectionFiles(); } } // else CheckConnection has set up a DisconnectedRepo if that is relevant. } catch (Exception ex) { NonFatalProblem.Report(ModalIf.All, PassiveIf.All, "Bloom found Team Collection settings but could not process them", null, ex, true); CurrentCollection = null; CurrentCollectionEvenIfDisconnected = null; } } }