/// <summary> /// Triggered when a KeePass database is being saved /// </summary> private static async void MainWindowOnFileSaved(object sender, FileSavedEventArgs fileSavedEventArgs) { var config = Configuration.GetPasswordDatabaseConfiguration(fileSavedEventArgs.Database.IOConnectionInfo.Path); config.KeePassDatabase = fileSavedEventArgs.Database; // Check if we should sync this database if (config.DoNotSync) return; // Make sure it's not a remote database on i.e. an FTP or website if (!fileSavedEventArgs.Database.IOConnectionInfo.IsLocalFile()) { MessageBox.Show("KeePass OneDriveSync does not support synchronizing databases from remote locations and will therefore not be available for this database", "KeePass OneDriveSync", MessageBoxButtons.OK, MessageBoxIcon.Information); config.DoNotSync = true; Configuration.Save(); return; } await KeePassDatabase.SyncDatabase(fileSavedEventArgs.Database.IOConnectionInfo.Path, KeePassDatabase.UpdateStatus); // If the OneDrive Refresh Token is stored in the KeePass database, we must trigger a save of the database here so to ensure that the actual value gets saved into the KDBX if (config.RefreshTokenStorage == OneDriveRefreshTokenStorage.KeePassDatabase) { fileSavedEventArgs.Database.Save(null); } }
private void OnFileSaved(object sender, FileSavedEventArgs e) { if(ShouldAutoSync(KeePassQiniuConfig.Default.SyncOnFileSaved)) { AutoSync(); m_databaseModified = false; } }
// Public for plugins public void SaveDatabaseAs(PwDatabase pdToSave, IOConnectionInfo iocTo, bool bOnline, object sender, bool bCopy) { PwDatabase pd = (pdToSave ?? m_docMgr.ActiveDatabase); if(!pd.IsOpen) return; if(!AppPolicy.Try(AppPolicyId.SaveFile)) return; Guid eventGuid = Guid.NewGuid(); if(this.FileSaving != null) { FileSavingEventArgs args = new FileSavingEventArgs(true, bCopy, pd, eventGuid); this.FileSaving(sender, args); if(args.Cancel) return; } DialogResult dr; IOConnectionInfo ioc = iocTo; if((ioc != null) && (ioc.Path.Length > 0)) { dr = DialogResult.OK; // Caller (plugin) specified target file } else if(bOnline) { IOConnectionForm iocf = new IOConnectionForm(); iocf.InitEx(true, pd.IOConnectionInfo.CloneDeep(), true, true); dr = iocf.ShowDialog(); ioc = iocf.IOConnectionInfo; UIUtil.DestroyForm(iocf); } else { SaveFileDialogEx sfdDb = UIUtil.CreateSaveFileDialog(KPRes.SaveDatabase, UrlUtil.GetFileName(pd.IOConnectionInfo.Path), UIUtil.CreateFileTypeFilter(AppDefs.FileExtension.FileExt, KPRes.KdbxFiles, true), 1, AppDefs.FileExtension.FileExt, AppDefs.FileDialogContext.Database); GlobalWindowManager.AddDialog(sfdDb.FileDialog); dr = sfdDb.ShowDialog(); GlobalWindowManager.RemoveDialog(sfdDb.FileDialog); if(dr == DialogResult.OK) ioc = IOConnectionInfo.FromPath(sfdDb.FileName); } if(dr == DialogResult.OK) { EcasPropertyDictionary dProps = new EcasPropertyDictionary(); dProps.Set(EcasProperty.IOConnectionInfo, ioc); dProps.Set(EcasProperty.Database, pd); Program.TriggerSystem.RaiseEvent(EcasEventIDs.SavingDatabaseFile, dProps); UIBlockInteraction(true); ShowWarningsLogger swLogger = CreateShowWarningsLogger(); swLogger.StartLogging(KPRes.SavingDatabase, true); ShutdownBlocker sdb = new ShutdownBlocker(this.Handle, KPRes.SavingDatabase); bool bSuccess = true; try { PreSavingEx(pd, ioc); pd.SaveAs(ioc, !bCopy, swLogger); PostSavingEx(!bCopy, pd, ioc, swLogger); } catch(Exception exSaveAs) { MessageService.ShowSaveWarning(ioc, exSaveAs, true); bSuccess = false; } sdb.Dispose(); swLogger.EndLogging(); // Immediately after the UIBlockInteraction call the form might // be closed and UpdateUIState might crash, if the order of the // two methods is swapped; so first update state, then unblock UpdateUIState(false); UIBlockInteraction(false); // Calls Application.DoEvents() if(this.FileSaved != null) { FileSavedEventArgs args = new FileSavedEventArgs(bSuccess, pd, eventGuid); this.FileSaved(sender, args); } if(bSuccess) Program.TriggerSystem.RaiseEvent(EcasEventIDs.SavedDatabaseFile, dProps); } }
private void OnFileSave(object sender, EventArgs e) { PwDatabase pd = m_docMgr.ActiveDatabase; if(!pd.IsOpen) return; if(!AppPolicy.Try(AppPolicyId.SaveFile)) return; if((pd.IOConnectionInfo == null) || (pd.IOConnectionInfo.Path.Length == 0)) { OnFileSaveAs(sender, e); return; } UIBlockInteraction(true); if(PreSaveValidate(pd) == false) { UIBlockInteraction(false); return; } Guid eventGuid = Guid.NewGuid(); if(this.FileSaving != null) { FileSavingEventArgs args = new FileSavingEventArgs(false, false, pd, eventGuid); this.FileSaving(sender, args); if(args.Cancel) { UIBlockInteraction(false); return; } } Program.TriggerSystem.RaiseEvent(EcasEventIDs.SavingDatabaseFile, pd.IOConnectionInfo.Path); ShowWarningsLogger swLogger = CreateShowWarningsLogger(); swLogger.StartLogging(KPRes.SavingDatabase, true); bool bSuccess = true; try { PreSavingEx(pd); pd.Save(swLogger); PostSavingEx(true, pd, pd.IOConnectionInfo, swLogger); } catch(Exception exSave) { MessageService.ShowSaveWarning(pd.IOConnectionInfo, exSave, true); bSuccess = false; } swLogger.EndLogging(); // Immediately after the UIBlockInteraction call the form might // be closed and UpdateUIState might crash, if the order of the // two methods is swapped; so first update state, then unblock UpdateUIState(false); UIBlockInteraction(false); // Calls Application.DoEvents() if(this.FileSaved != null) { FileSavedEventArgs args = new FileSavedEventArgs(bSuccess, pd, eventGuid); this.FileSaved(sender, args); } if(bSuccess) Program.TriggerSystem.RaiseEvent(EcasEventIDs.SavedDatabaseFile, pd.IOConnectionInfo.Path); }
private void OnKPDBSaved(object sender, FileSavedEventArgs e) { EnsureDBIconIsInKPRPCIconCache(); SignalAllManagedRPCClients(KeePassRPC.DataExchangeModel.Signal.DATABASE_SAVED); }
/// <summary> /// Triggered when a KeePass database is being saved /// </summary> private static async void MainWindowOnFileSaved(object sender, FileSavedEventArgs fileSavedEventArgs) { await KeePass.SyncDatabase(fileSavedEventArgs.Database.IOConnectionInfo.Path, KeePass.UpdateStatus); }
private void OnFileSaved(object sender, FileSavedEventArgs e) { }
private void OnKPDBSaved(object sender, FileSavedEventArgs e) { SignalAllManagedRPCClients(KeePassRPC.DataExchangeModel.Signal.DATABASE_SAVED); }
private void SaveDatabaseAs(bool bOnline, object sender, bool bCopy) { if(!m_docMgr.ActiveDatabase.IsOpen) return; if(!AppPolicy.Try(AppPolicyId.SaveFile)) return; PwDatabase pd = m_docMgr.ActiveDatabase; Guid eventGuid = Guid.NewGuid(); if(this.FileSaving != null) { FileSavingEventArgs args = new FileSavingEventArgs(true, bCopy, pd, eventGuid); this.FileSaving(sender, args); if(args.Cancel) return; } DialogResult dr; IOConnectionInfo ioc = new IOConnectionInfo(); if(bOnline) { IOConnectionForm iocf = new IOConnectionForm(); iocf.InitEx(true, pd.IOConnectionInfo.CloneDeep(), true, true); dr = iocf.ShowDialog(); ioc = iocf.IOConnectionInfo; } else { SaveFileDialog sfdDb = UIUtil.CreateSaveFileDialog(KPRes.SaveDatabase, UrlUtil.GetFileName(pd.IOConnectionInfo.Path), UIUtil.CreateFileTypeFilter("kdbx", KPRes.KdbxFiles, true), 1, "kdbx", false); GlobalWindowManager.AddDialog(sfdDb); dr = sfdDb.ShowDialog(); GlobalWindowManager.RemoveDialog(sfdDb); if(dr == DialogResult.OK) ioc = IOConnectionInfo.FromPath(sfdDb.FileName); } if(dr == DialogResult.OK) { ShowWarningsLogger swLogger = CreateShowWarningsLogger(); swLogger.StartLogging(KPRes.SavingDatabase, true); bool bSuccess = true; try { pd.SaveAs(ioc, !bCopy, swLogger); PostSavingEx(!bCopy, pd, ioc); } catch(Exception exSaveAs) { MessageService.ShowSaveWarning(ioc, exSaveAs, true); bSuccess = false; } swLogger.EndLogging(); if(this.FileSaved != null) { FileSavedEventArgs args = new FileSavedEventArgs(bSuccess, pd, eventGuid); this.FileSaved(sender, args); } } UpdateUIState(false); }
/// <summary> /// Handler for when the database file is saved from the KeePass GUI. /// If we are setup to do automatic backup, we go ahead and do the /// backup. If we do the backup, we also clear the database modified /// flag since we now have the latest database in the backup directory. /// </summary> /// <param name="sender">Information about the sender of the event.</param> /// <param name="e">Event information.</param> private void OnFileSaved(object sender, FileSavedEventArgs e) { if (ShouldAutoBackup(Properties.Settings.Default.BackupOnFileSaved)) { AutoBackup(); m_databaseModified = false; } }
private void SaveDatabaseAs(bool bOnline, object sender, bool bCopy) { if(!m_docMgr.ActiveDatabase.IsOpen) return; if(!AppPolicy.Try(AppPolicyId.SaveFile)) return; PwDatabase pd = m_docMgr.ActiveDatabase; Guid eventGuid = Guid.NewGuid(); if(this.FileSaving != null) { FileSavingEventArgs args = new FileSavingEventArgs(true, bCopy, pd, eventGuid); this.FileSaving(sender, args); if(args.Cancel) return; } DialogResult dr; IOConnectionInfo ioc = new IOConnectionInfo(); if(bOnline) { IOConnectionForm iocf = new IOConnectionForm(); iocf.InitEx(true, pd.IOConnectionInfo.CloneDeep(), true, true); dr = iocf.ShowDialog(); ioc = iocf.IOConnectionInfo; } else { SaveFileDialog sfdDb = UIUtil.CreateSaveFileDialog(KPRes.SaveDatabase, UrlUtil.GetFileName(pd.IOConnectionInfo.Path), UIUtil.CreateFileTypeFilter(AppDefs.FileExtension.FileExt, KPRes.KdbxFiles, true), 1, AppDefs.FileExtension.FileExt, false, true); GlobalWindowManager.AddDialog(sfdDb); dr = sfdDb.ShowDialog(); GlobalWindowManager.RemoveDialog(sfdDb); if(dr == DialogResult.OK) ioc = IOConnectionInfo.FromPath(sfdDb.FileName); } if(dr == DialogResult.OK) { Program.TriggerSystem.RaiseEvent(EcasEventIDs.SavingDatabaseFile, ioc.Path); UIBlockInteraction(true); ShowWarningsLogger swLogger = CreateShowWarningsLogger(); swLogger.StartLogging(KPRes.SavingDatabase, true); bool bSuccess = true; try { PreSavingEx(pd); pd.SaveAs(ioc, !bCopy, swLogger); PostSavingEx(!bCopy, pd, ioc, swLogger); } catch(Exception exSaveAs) { MessageService.ShowSaveWarning(ioc, exSaveAs, true); bSuccess = false; } swLogger.EndLogging(); // Immediately after the UIBlockInteraction call the form might // be closed and UpdateUIState might crash, if the order of the // two methods is swapped; so first update state, then unblock UpdateUIState(false); UIBlockInteraction(false); // Calls Application.DoEvents() if(this.FileSaved != null) { FileSavedEventArgs args = new FileSavedEventArgs(bSuccess, pd, eventGuid); this.FileSaved(sender, args); } if(bSuccess) Program.TriggerSystem.RaiseEvent(EcasEventIDs.SavedDatabaseFile, ioc.Path); } }
private void OnFileSaved(object sender, FileSavedEventArgs e) { // nothing todo }
private void OnFileSave(object sender, EventArgs e) { PwDatabase pd = m_docMgr.ActiveDatabase; if(!pd.IsOpen) return; if(!AppPolicy.Try(AppPolicyId.SaveFile)) return; if((pd.IOConnectionInfo == null) || (pd.IOConnectionInfo.Path.Length == 0)) { OnFileSaveAs(sender, e); return; } if(PreSaveValidate(pd) == false) return; Guid eventGuid = Guid.NewGuid(); if(FileSaving != null) { FileSavingEventArgs args = new FileSavingEventArgs(false, false, pd, eventGuid); FileSaving(sender, args); if(args.Cancel) return; } ShowWarningsLogger swLogger = CreateShowWarningsLogger(); swLogger.StartLogging(KPRes.SavingDatabase, true); bool bSuccess = true; try { pd.Save(swLogger); PostSavingEx(true, pd, pd.IOConnectionInfo); } catch(Exception exSave) { bSuccess = false; MessageService.ShowSaveWarning(pd.IOConnectionInfo, exSave, true); } swLogger.EndLogging(); if(this.FileSaved != null) { FileSavedEventArgs args = new FileSavedEventArgs(bSuccess, pd, eventGuid); this.FileSaved(sender, args); } UpdateUIState(false); }