예제 #1
0
 public static AddEntry GetInstance(Activity ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish)
 {
     return(new AddEntry(ctx, app, entry, parentGroup, finish));
 }
        void SaveEntry()
        {
            Database          db  = App.Kp2a.GetDb();
            EntryEditActivity act = this;

            if (!ValidateBeforeSaving())
            {
                return;
            }

            PwEntry initialEntry = State.EntryInDatabase.CloneDeep();

            PwEntry newEntry = State.EntryInDatabase;

            //Clone history and re-assign:
            newEntry.History = newEntry.History.CloneDeep();

            //Based on KeePass Desktop
            bool bCreateBackup = (!State.IsNew);

            if (bCreateBackup)
            {
                newEntry.CreateBackup(null);
            }

            if (State.SelectedIcon)
            {
                newEntry.IconId         = State.SelectedIconId;
                newEntry.CustomIconUuid = State.SelectedCustomIconId;
            }             //else the State.EntryInDatabase.Icon

            /* KPDesktop
             *      if(m_cbCustomForegroundColor.Checked)
             *              newEntry.ForegroundColor = m_clrForeground;
             *      else newEntry.ForegroundColor = Color.Empty;
             *      if(m_cbCustomBackgroundColor.Checked)
             *              newEntry.BackgroundColor = m_clrBackground;
             *      else newEntry.BackgroundColor = Color.Empty;
             *
             */

            UpdateEntryFromUi(newEntry);
            newEntry.Binaries = State.Entry.Binaries;
            newEntry.Expires  = State.Entry.Expires;
            if (newEntry.Expires)
            {
                newEntry.ExpiryTime = State.Entry.ExpiryTime;
            }


            newEntry.Touch(true, false);             // Touch *after* backup

            StrUtil.NormalizeNewLines(newEntry.Strings, true);

            bool             bUndoBackup = false;
            PwCompareOptions cmpOpt      = (PwCompareOptions.NullEmptyEquivStd |
                                            PwCompareOptions.IgnoreTimes);

            if (bCreateBackup)
            {
                cmpOpt |= PwCompareOptions.IgnoreLastBackup;
            }
            if (newEntry.EqualsEntry(initialEntry, cmpOpt, MemProtCmpMode.CustomOnly))
            {
                // No modifications at all => restore last mod time and undo backup
                newEntry.LastModificationTime = initialEntry.LastModificationTime;
                bUndoBackup = bCreateBackup;
            }
            else if (bCreateBackup)
            {
                // If only history items have been modified (deleted) => undo
                // backup, but without restoring the last mod time
                PwCompareOptions cmpOptNh = (cmpOpt | PwCompareOptions.IgnoreHistory);
                if (newEntry.EqualsEntry(initialEntry, cmpOptNh, MemProtCmpMode.CustomOnly))
                {
                    bUndoBackup = true;
                }
            }
            if (bUndoBackup)
            {
                newEntry.History.RemoveAt(newEntry.History.UCount - 1);
            }

            newEntry.MaintainBackups(db.KpDatabase);

            //if ( newEntry.Strings.ReadSafe (PwDefs.TitleField).Equals(State.Entry.Strings.ReadSafe (PwDefs.TitleField)) ) {
            //	SetResult(KeePass.EXIT_REFRESH);
            //} else {
            //it's safer to always update the title as we might add further information in the title like expiry etc.
            SetResult(KeePass.ExitRefreshTitle);
            //}

            RunnableOnFinish runnable;

            ActionOnFinish closeOrShowError = new ActionOnFinish((success, message) => {
                if (success)
                {
                    Finish();
                }
                else
                {
                    OnFinish.DisplayMessage(this, message);
                }
            });

            ActionOnFinish afterAddEntry = new ActionOnFinish((success, message) =>
            {
                if (success)
                {
                    _appTask.AfterAddNewEntry(this, newEntry);
                }
            }, closeOrShowError);

            if (State.IsNew)
            {
                runnable = AddEntry.GetInstance(this, App.Kp2a, newEntry, State.ParentGroup, afterAddEntry);
            }
            else
            {
                runnable = new UpdateEntry(this, App.Kp2a, initialEntry, newEntry, closeOrShowError);
            }
            ProgressTask pt = new ProgressTask(App.Kp2a, act, runnable);

            pt.Run();
        }
        public DeleteMultipleItems(Activity activity, Database db, List <IStructureItem> elementsToDelete, OnFinish finish, IKp2aApp app)
            : base(activity, finish, app)
        {
            _elementsToDelete = elementsToDelete;
            SetMembers(activity, db);

            //determine once. The property is queried for each delete operation, but might return false
            //after one entry/group is deleted (and thus in recycle bin and thus can't be recycled anymore)
            _canRecycle = DetermineCanRecycle();
        }
예제 #4
0
 public AfterEdit(Activity ctx, EditGroup editGroup, OnFinish finish)
     : base(ctx, finish)
 {
     _editGroup = editGroup;
 }
예제 #5
0
 public ActionOnFinish(Activity activity, ActionToPerformOnFinsh actionToPerform, OnFinish finish) : base(activity, finish)
 {
     _actionToPerform = actionToPerform;
 }
예제 #6
0
파일: OnFinish.cs 프로젝트: 77rusa/README
 protected OnFinish(Activity activeActivity, OnFinish finish)
 {
     ActiveActivity = activeActivity;
     BaseOnFinish   = finish;
     Handler        = null;
 }
예제 #7
0
 public AfterSave(Activity activity, CompositeKey backup, DateTime previousKeyChanged, PwDatabase db, OnFinish finish) : base(activity, finish)
 {
     _previousKeyChanged = previousKeyChanged;
     _backup             = backup;
     _db = db;
 }
 public static AddGroup GetInstance(Context ctx, IKp2aApp app, string name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave)
 {
     return(new AddGroup(ctx, app, name, iconid, groupCustomIconId, parent, finish, dontSave));
 }
        private AddGroup(Context ctx, IKp2aApp app, String name, int iconid, PwUuid groupCustomIconId, PwGroup parent, OnFinish finish, bool dontSave)
            : base(finish)
        {
            _ctx               = ctx;
            _name              = name;
            _iconId            = iconid;
            _groupCustomIconId = groupCustomIconId;
            Parent             = parent;
            DontSave           = dontSave;
            _app               = app;

            _onFinishToRun = new AfterAdd(this, OnFinishToRun);
        }
예제 #10
0
 public AfterAdd(Activity activity, Database db, List <PwEntry> entries, OnFinish finish) : base(activity, finish)
 {
     _db      = db;
     _entries = entries;
 }
 public SynchronizeCachedDatabase(Activity context, IKp2aApp app, OnFinish finish)
     : base(context, finish)
 {
     _context = context;
     _app     = app;
 }
예제 #12
0
 public AfterEdit(EditGroup editGroup, OnFinish finish)
     : base(finish)
 {
     _editGroup = editGroup;
 }
예제 #13
0
 public AfterAdd(Activity activity, Database db, PwEntry entry, IKp2aApp app, OnFinish finish) : base(activity, finish)
 {
     _db    = db;
     _entry = entry;
     _app   = app;
 }
예제 #14
0
        protected AddEntry(Activity ctx, IKp2aApp app, PwEntry entry, PwGroup parentGroup, OnFinish finish) : base(ctx, finish)
        {
            _ctx         = ctx;
            _parentGroup = parentGroup;
            _app         = app;
            _entry       = entry;

            _onFinishToRun = new AfterAdd(ctx, app.CurrentDb, entry, app, OnFinishToRun);
        }
예제 #15
0
파일: OnFinish.cs 프로젝트: 77rusa/README
 protected OnFinish(Activity activeActivity, Handler handler)
 {
     ActiveActivity = activeActivity;
     BaseOnFinish   = null;
     Handler        = handler;
 }
 public AfterAdd(AddGroup addGroup, OnFinish finish) : base(finish)
 {
     _addGroup = addGroup;
 }
예제 #17
0
파일: OnFinish.cs 프로젝트: 77rusa/README
 protected OnFinish(Activity activeActivity, OnFinish finish, Handler handler)
 {
     ActiveActivity = activeActivity;
     BaseOnFinish   = finish;
     Handler        = handler;
 }
예제 #18
0
 public DeleteEntry(Activity activiy, IKp2aApp app, PwEntry entry, OnFinish finish) : base(activiy, finish, app)
 {
     Ctx    = activiy;
     Db     = app.FindDatabaseForElement(entry);
     _entry = entry;
 }
예제 #19
0
 public SetPassword(Activity ctx, IKp2aApp app, String password, String keyfile, OnFinish finish, bool dontSave)
     : base(ctx, finish)
 {
     _ctx      = ctx;
     _app      = app;
     _password = password;
     _keyfile  = keyfile;
     _dontSave = dontSave;
 }
 public SynchronizeCachedDatabase(Context context, IKp2aApp app, OnFinish finish)
     : base(finish)
 {
     _context = context;
     _app     = app;
 }
예제 #21
0
        public EditGroup(Activity ctx, IKp2aApp app, String name, PwIcon iconid, PwUuid customIconId, PwGroup group, OnFinish finish)
            : base(ctx, finish)
        {
            _ctx          = ctx;
            _name         = name;
            _iconId       = iconid;
            Group         = group;
            _customIconId = customIconId;
            _app          = app;

            _onFinishToRun = new AfterEdit(ctx, this, OnFinishToRun);
        }
 public CheckDatabaseForChanges(Activity context, IKp2aApp app, OnFinish finish)
     : base(context, finish)
 {
     _context = context;
     _app     = app;
 }
예제 #23
0
 public ExportDb(Activity activity, IKp2aApp app, OnFinish onFinish, FileFormatProvider fileFormat, IOConnectionInfo targetIoc) : base(activity, onFinish)
 {
     _app             = app;
     this._fileFormat = fileFormat;
     _targetIoc       = targetIoc;
 }
예제 #24
0
 public AfterTask(Activity activity, OnFinish finish, Handler handler, ProgressTask pt) : base(activity, finish, handler)
 {
     _progressTask = pt;
 }
예제 #25
0
 protected DeleteRunnable(Activity activity, OnFinish finish, IKp2aApp app)
     : base(activity, finish)
 {
     App = app;
 }
예제 #26
0
 protected RunnableOnFinish(Activity activeActivity, OnFinish finish)
 {
     _activeActivity = activeActivity;
     _onFinishToRun  = finish;
 }
예제 #27
0
 public WriteBinaryTask(Activity activity, IKp2aApp app, OnFinish onFinish, ProtectedBinary data, IOConnectionInfo targetIoc) : base(activity, onFinish)
 {
     _app       = app;
     _data      = data;
     _targetIoc = targetIoc;
 }
예제 #28
0
 public DeleteEntry(Activity activiy, IKp2aApp app, PwEntry entry, OnFinish finish) : base(activiy, finish, app)
 {
     Ctx    = activiy;
     Db     = app.GetDb();
     _entry = entry;
 }
예제 #29
0
        public LoadDb(Activity activity, IKp2aApp app, IOConnectionInfo ioc, Task <MemoryStream> databaseData, CompositeKey compositeKey, String keyfileOrProvider, OnFinish finish) : base(activity, finish)
        {
            _app               = app;
            _ioc               = ioc;
            _databaseData      = databaseData;
            _compositeKey      = compositeKey;
            _keyfileOrProvider = keyfileOrProvider;


            _rememberKeyfile = app.GetBooleanPreference(PreferenceKey.remember_keyfile);
        }
예제 #30
0
 public AfterUpdate(Activity activity, PwEntry backup, PwEntry updatedEntry, IKp2aApp app, OnFinish finish) : base(activity, finish)
 {
     _backup       = backup;
     _updatedEntry = updatedEntry;
     _app          = app;
 }