public override void Run() { // Commit to disk SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { StatusLogger.UpdateMessage(UiStringKey.SettingPassword); PwDatabase pm = _app.GetDb().KpDatabase; CompositeKey newKey = new CompositeKey(); if (String.IsNullOrEmpty(_password) == false) { newKey.AddUserKey(new KcpPassword(_password)); } if (String.IsNullOrEmpty(_keyfile) == false) { try { newKey.AddUserKey(new KcpKeyFile(_keyfile)); } catch (Exception) { //TODO MessageService.ShowWarning (strKeyFile, KPRes.KeyFileError, exKF); return; } } DateTime previousMasterKeyChanged = pm.MasterKeyChanged; CompositeKey previousKey = pm.MasterKey; pm.MasterKeyChanged = DateTime.Now; pm.MasterKey = newKey; // Save Database _onFinishToRun = new AfterSave(previousKey, previousMasterKeyChanged, pm, OnFinishToRun); SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, _dontSave); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { // Commit to disk SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { // modify group: Group.Name = _name; Group.IconId = _iconId; Group.CustomIconUuid = _customIconId; Group.Touch(true); // Commit to disk SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { // modify group: Group.Name = _name; Group.IconId = _iconId; Group.CustomIconUuid = _customIconId; Group.Touch(true); // Commit to disk SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { StatusLogger.UpdateMessage(UiStringKey.AddingEntry); //make sure we're not adding the entry if it was added before. //(this might occur in very rare cases where the user dismissis the save dialog //by rotating the screen while saving and then presses save again) if (_parentGroup.FindEntry(_entry.Uuid, false) == null) { _parentGroup.AddEntry(_entry, true); } // Commit to disk SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { StatusLogger.UpdateMessage(UiStringKey.AddingGroup); // Generate new group Group = new PwGroup(true, true, _name, (PwIcon)_iconId); if (_groupCustomIconId != null) { Group.CustomIconUuid = _groupCustomIconId; } Parent.AddGroup(Group, true); // Commit to disk SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, DontSave); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { StatusLogger.UpdateMessage(UiStringKey.AddingEntry); List <PwEntry> addedEntries; var templateGroup = AddTemplates(out addedEntries); if (addedEntries.Any()) { _app.DirtyGroups.Add(templateGroup); // Commit to disk SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun); save.SetStatusLogger(StatusLogger); save.Run(); } }
public override void Run() { StatusLogger.UpdateMessage(UiStringKey.progress_create); Database db = _app.CreateNewDatabase(_makeCurrent); db.KpDatabase = new KeePassLib.PwDatabase(); if (_key == null) { _key = new CompositeKey(); //use a temporary key which should be changed after creation } db.KpDatabase.New(_ioc, _key, _app.GetFileStorage(_ioc).GetFilenameWithoutPathAndExt(_ioc)); db.KpDatabase.KdfParameters = (new AesKdf()).GetDefaultParameters(); db.KpDatabase.Name = "Keepass2Android Password Database"; //re-set the name of the root group because the PwDatabase uses UrlUtil which is not appropriate for all file storages: db.KpDatabase.RootGroup.Name = _app.GetFileStorage(_ioc).GetFilenameWithoutPathAndExt(_ioc); // Set Database state db.Root = db.KpDatabase.RootGroup; db.SearchHelper = new SearchDbHelper(_app); // Add a couple default groups AddGroup internet = AddGroup.GetInstance(_ctx, _app, "Internet", 1, null, db.KpDatabase.RootGroup, null, true); internet.Run(); AddGroup email = AddGroup.GetInstance(_ctx, _app, "eMail", 19, null, db.KpDatabase.RootGroup, null, true); email.Run(); List <PwEntry> addedEntries; AddTemplateEntries addTemplates = new AddTemplateEntries(_ctx, _app, null); addTemplates.AddTemplates(out addedEntries); // Commit changes SaveDb save = new SaveDb(_ctx, _app, db, OnFinishToRun, _dontSave); save.SetStatusLogger(StatusLogger); _onFinishToRun = null; save.Run(); db.UpdateGlobals(); }
public override void Run() { StatusLogger.UpdateMessage(UiStringKey.AddingEntry); //make sure we're not adding the entry if it was added before. //(this might occur in very rare cases where the user dismissis the save dialog //by rotating the screen while saving and then presses save again) if (_parentGroup.FindEntry(_entry.Uuid, false) == null) { _parentGroup.AddEntry(_entry, true); } // Commit to disk SaveDb save = new SaveDb(_ctx, _app, _app.CurrentDb, OnFinishToRun); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { StatusLogger.UpdateMessage(StatusMessage); List <PwGroup> touchedGroups = new List <PwGroup>(); List <PwGroup> permanentlyDeletedGroups = new List <PwGroup>(); Android.Util.Log.Debug("KP2A", "Calling PerformDelete.."); PerformDelete(touchedGroups, permanentlyDeletedGroups); _onFinishToRun = new ActionOnFinish(ActiveActivity, (success, message, activity) => { if (success) { foreach (var g in touchedGroups) { App.DirtyGroups.Add(g); } foreach (var g in permanentlyDeletedGroups) { //remove groups from global lists if present there App.DirtyGroups.Remove(g); Db.GroupsById.Remove(g.Uuid); Db.Elements.Remove(g); } } else { // Let's not bother recovering from a failure to save. It is too much work. App.Lock(false); } }, OnFinishToRun); // Commit database SaveDb save = new SaveDb(Ctx, App, Db, OnFinishToRun, false); save.ShowDatabaseIocInStatus = ShowDatabaseIocInStatus; save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { StatusLogger.UpdateMessage(UiStringKey.DeletingEntry); PwDatabase pd = Db.KpDatabase; PwGroup pgRecycleBin = pd.RootGroup.FindGroup(pd.RecycleBinUuid, true); bool bUpdateGroupList = false; DateTime dtNow = DateTime.Now; PwEntry pe = _entry; PwGroup pgParent = pe.ParentGroup; if(pgParent != null) { pgParent.Entries.Remove(pe); //TODO check if RecycleBin is deleted //TODO no recycle bin in KDB if ((DeletePermanently) || (!CanRecycle)) { PwDeletedObject pdo = new PwDeletedObject(pe.Uuid, dtNow); pd.DeletedObjects.Add(pdo); _onFinishToRun = new ActionOnFinish((success, message) => { if (success) { // Mark parent dirty Db.Dirty.Add(pgParent); } else { // Let's not bother recovering from a failure to save a deleted entry. It is too much work. App.LockDatabase(false); } }, OnFinishToRun); } else // Recycle { EnsureRecycleBinExists(ref pgRecycleBin, ref bUpdateGroupList); pgRecycleBin.AddEntry(pe, true, true); pe.Touch(false); _onFinishToRun = new ActionOnFinish( (success, message) => { if ( success ) { // Mark previous parent dirty Db.Dirty.Add(pgParent); // Mark new parent dirty Db.Dirty.Add(pgRecycleBin); // mark root dirty if recycle bin was created if (bUpdateGroupList) Db.Dirty.Add(Db.Root); } else { // Let's not bother recovering from a failure to save a deleted entry. It is too much work. App.LockDatabase(false); } }, OnFinishToRun); } } // Commit database SaveDb save = new SaveDb(Ctx, App, OnFinishToRun, false); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { StatusLogger.UpdateMessage(UiStringKey.AddingGroup); // Generate new group Group = new PwGroup(true, true, _name, (PwIcon)_iconId); Parent.AddGroup(Group, true); // Commit to disk SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, DontSave); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { StatusLogger.UpdateMessage(UiStringKey.progress_create); Database db = _app.CreateNewDatabase(); db.KpDatabase = new KeePassLib.PwDatabase(); if (_key == null) { _key = new CompositeKey(); //use a temporary key which should be changed after creation } db.KpDatabase.New(_ioc, _key); db.KpDatabase.KeyEncryptionRounds = DefaultEncryptionRounds; db.KpDatabase.Name = "Keepass2Android Password Database"; //re-set the name of the root group because the PwDatabase uses UrlUtil which is not appropriate for all file storages: db.KpDatabase.RootGroup.Name = _app.GetFileStorage(_ioc).GetFilenameWithoutPathAndExt(_ioc); // Set Database state db.Root = db.KpDatabase.RootGroup; db.Loaded = true; db.SearchHelper = new SearchDbHelper(_app); // Add a couple default groups AddGroup internet = AddGroup.GetInstance(_ctx, _app, "Internet", 1, db.KpDatabase.RootGroup, null, true); internet.Run(); AddGroup email = AddGroup.GetInstance(_ctx, _app, "eMail", 19, db.KpDatabase.RootGroup, null, true); email.Run(); // Commit changes SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, _dontSave); save.SetStatusLogger(StatusLogger); _onFinishToRun = null; save.Run(); }