Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[3d7492]: src / core / PWScore.h Maximize Restore History

Download this file

PWScore.h    664 lines (564 with data), 27.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
/*
* Copyright (c) 2003-2014 Rony Shapiro <ronys@users.sourceforge.net>.
* All rights reserved. Use of the code is allowed under the
* Artistic License 2.0 terms, as specified in the LICENSE file
* distributed with this code, or available from
* http://www.opensource.org/licenses/artistic-license-2.0.php
*/
#ifndef __PWSCORE_H
#define __PWSCORE_H
// PWScore.h
//-----------------------------------------------------------------------------
#include "os/pws_tchar.h"
#include "ItemData.h"
#include "StringX.h"
#include "PWSfile.h"
#include "PWSFilters.h"
#include "os/UUID.h"
#include "Report.h"
#include "Proxy.h"
#include "UIinterface.h"
#include "Command.h"
#include "CommandInterface.h"
#include "DBCompareData.h"
#include "ExpiredList.h"
#include "coredefs.h"
// Parameter list for ParseBaseEntryPWD
struct BaseEntryParms {
// All fields except "InputType" are 'output'.
StringX csPwdGroup;
StringX csPwdTitle;
StringX csPwdUser;
pws_os::CUUID base_uuid;
CItemData::EntryType InputType;
CItemData::EntryType TargetType;
int ibasedata;
bool bMultipleEntriesFound;
BaseEntryParms() : base_uuid(pws_os::CUUID::NullUUID()) {}
};
// Formatted Database properties
struct st_DBProperties {
StringX database;
StringX databaseformat;
StringX numgroups;
StringX numentries;
StringX whenlastsaved;
StringX wholastsaved;
StringX whatlastsaved;
StringX file_uuid;
StringX unknownfields;
StringX db_name;
StringX db_description;
};
// Results of a database verification
struct st_ValidateResults {
int num_invalid_UUIDs;
int num_duplicate_UUIDs;
int num_empty_titles;
int num_empty_passwords;
int num_duplicate_GTU_fixed;
int num_PWH_fixed;
int num_excessivetxt_found;
int num_alias_warnings;
int num_shortcuts_warnings;
st_ValidateResults()
: num_invalid_UUIDs(0), num_duplicate_UUIDs(0),
num_empty_titles(0), num_empty_passwords(0),
num_duplicate_GTU_fixed(0),
num_PWH_fixed(0), num_excessivetxt_found(0),
num_alias_warnings(0), num_shortcuts_warnings(0)
{}
st_ValidateResults(const st_ValidateResults &that)
: num_invalid_UUIDs(that.num_invalid_UUIDs),
num_duplicate_UUIDs(that.num_duplicate_UUIDs),
num_empty_titles(that.num_empty_titles),
num_empty_passwords(that.num_empty_passwords),
num_duplicate_GTU_fixed(that.num_duplicate_GTU_fixed),
num_PWH_fixed(that.num_PWH_fixed),
num_excessivetxt_found(that.num_excessivetxt_found),
num_alias_warnings(that.num_alias_warnings),
num_shortcuts_warnings(that.num_shortcuts_warnings)
{}
st_ValidateResults &operator=(const st_ValidateResults &that) {
if (this != &that) {
num_invalid_UUIDs = that.num_invalid_UUIDs;
num_duplicate_UUIDs = that.num_duplicate_UUIDs;
num_empty_titles = that.num_empty_titles;
num_empty_passwords = that.num_empty_passwords;
num_duplicate_GTU_fixed = that.num_duplicate_GTU_fixed;
num_PWH_fixed = that.num_PWH_fixed;
num_excessivetxt_found = that.num_excessivetxt_found;
num_alias_warnings = that.num_alias_warnings;
num_shortcuts_warnings = that.num_shortcuts_warnings;
}
return *this;
}
int TotalIssues()
{
return (num_invalid_UUIDs + num_duplicate_UUIDs +
num_empty_titles + num_empty_passwords +
num_duplicate_GTU_fixed +
num_PWH_fixed + num_excessivetxt_found +
num_alias_warnings + num_shortcuts_warnings);
}
};
class PWScore : public CommandInterface
{
public:
enum {
SUCCESS = 0,
FAILURE = 1,
USER_DECLINED_SAVE = 2,
CANT_GET_LOCK = 3,
DB_HAS_CHANGED = 4,
CANT_OPEN_FILE = PWSfile::CANT_OPEN_FILE, // -10
USER_CANCEL = -9, // -9
WRONG_PASSWORD = PWSfile::WRONG_PASSWORD, // 5
BAD_DIGEST = PWSfile::BAD_DIGEST, // 6
TRUNCATED_FILE = PWSfile::TRUNCATED_FILE, // 8 (or maybe corrupt?)
READ_FAIL = PWSfile::READ_FAIL, // 9
WRITE_FAIL = PWSfile::WRITE_FAIL, // 10
UNKNOWN_VERSION, // 11
NOT_SUCCESS, // 12
ALREADY_OPEN, // 13
INVALID_FORMAT, // 14
USER_EXIT, // 15
XML_FAILED_VALIDATION, // 16
XML_FAILED_IMPORT, // 17
LIMIT_REACHED, // 18
UNIMPLEMENTED, // 19
NO_ENTRIES_EXPORTED, // 20
DB_HAS_DUPLICATES, // 21
OK_WITH_ERRORS, // 22
OK_WITH_VALIDATION_ERRORS // 23
};
PWScore();
~PWScore();
bool SetUIInterFace(UIInterFace *pUIIF, size_t num_supported,
std::bitset<UIInterFace::NUM_SUPPORTED> bsSupportedFunctions);
// Set following to a Reporter-derived object
// so that we can inform user of events of interest
static void SetReporter(Reporter *pReporter) {m_pReporter = pReporter;}
static void SetAsker(Asker *pAsker) {m_pAsker = pAsker;}
static bool IsAskerSet() {return m_pAsker != NULL;}
static bool IsReporterSet() {return m_pReporter != NULL;}
// Get/Set File UUIDs
void ClearFileUUID() { m_hdr.m_file_uuid = pws_os::CUUID::NullUUID(); }
void SetFileUUID(const pws_os::CUUID &fu) { m_hdr.m_file_uuid = fu; }
const pws_os::CUUID &GetFileUUID() const { return m_hdr.m_file_uuid; }
// Get/Set Unknown Fields info
bool HasHeaderUnknownFields() const
{return !m_UHFL.empty();}
int GetNumRecordsWithUnknownFields() const
{return m_nRecordsWithUnknownFields;}
void DecrementNumRecordsWithUnknownFields()
{m_nRecordsWithUnknownFields--;}
void IncrementNumRecordsWithUnknownFields()
{m_nRecordsWithUnknownFields++;}
// Clear out database structures and associated fields
void ClearData();
void ReInit(bool bNewfile = false);
// Following used to read/write databases and Get/Set file name
StringX GetCurFile() const {return m_currfile;}
void SetCurFile(const StringX &file) {m_currfile = file;}
int ReadCurFile(const StringX &passkey, const bool bValidate = false,
const size_t iMAXCHARS = 0, CReport *pRpt = NULL)
{return ReadFile(m_currfile, passkey, bValidate, iMAXCHARS, pRpt);}
int ReadFile(const StringX &filename, const StringX &passkey,
const bool bValidate = false, const size_t iMAXCHARS = 0,
CReport *pRpt = NULL);
PWSfile::VERSION GetReadFileVersion() const {return m_ReadFileVersion;}
bool BackupCurFile(int maxNumIncBackups, int backupSuffix,
const stringT &userBackupPrefix,
const stringT &userBackupDir, stringT &bu_fname);
void NewFile(const StringX &passkey);
int WriteCurFile() {return WriteFile(m_currfile);}
int WriteFile(const StringX &filename, const bool bUpdateSig = true,
PWSfile::VERSION version = PWSfile::VCURRENT);
int WriteV17File(const StringX &filename)
{return WriteFile(filename, true, PWSfile::V17);}
int WriteV2File(const StringX &filename)
{return WriteFile(filename, true, PWSfile::V20);}
// R/O file status
void SetReadOnly(bool state) {m_IsReadOnly = state;}
bool IsReadOnly() const {return m_IsReadOnly;};
// Check/Change master passphrase
int CheckPasskey(const StringX &filename, const StringX &passkey);
void ChangePasskey(const StringX &newPasskey);
void SetPassKey(const StringX &new_passkey);
// Database functions
int TestSelection(const bool bAdvanced,
const stringT &subgroup_name,
const int &subgroup_object,
const int &subgroup_function,
const OrderedItemList *il);
void Compare(PWScore *pothercore,
const CItemData::FieldBits &bsFields, const bool &subgroup_bset,
const bool &bTreatWhiteSpaceasEmpty, const stringT &subgroup_name,
const int &subgroup_object, const int &subgroup_function,
CompareData &list_OnlyInCurrent, CompareData &list_OnlyInComp,
CompareData &list_Conflicts, CompareData &list_Identical,
bool *pbCancel = NULL);
stringT Merge(PWScore *pothercore,
const bool &subgroup_bset,
const stringT &subgroup_name,
const int &subgroup_object, const int &subgroup_function,
CReport *pRpt, bool *pbCancel = NULL);
void Synchronize(PWScore *pothercore,
const CItemData::FieldBits &bsFields, const bool &subgroup_bset,
const stringT &subgroup_name,
const int &subgroup_object, const int &subgroup_function,
int &numUpdated, CReport *pRpt, bool *pbCancel = NULL);
// Export databases
int WritePlaintextFile(const StringX &filename,
const CItemData::FieldBits &bsExport,
const stringT &subgroup, const int &iObject,
const int &iFunction, const TCHAR &delimiter,
int &numExported, const OrderedItemList *il = NULL,
CReport *pRpt = NULL);
int WriteXMLFile(const StringX &filename,
const CItemData::FieldBits &bsExport,
const stringT &subgroup, const int &iObject,
const int &iFunction, const TCHAR &delimiter,
int &numExported, const OrderedItemList *il = NULL,
const bool &bFilterActive = false,
CReport *pRpt = NULL);
// Import databases
// If returned status is SUCCESS, then returned Command * can be executed.
int ImportPlaintextFile(const StringX &ImportedPrefix,
const StringX &filename,
const TCHAR &fieldSeparator, const TCHAR &delimiter,
const bool &bImportPSWDsOnly,
stringT &strErrors,
int &numImported, int &numSkipped,
int &numPWHErrors, int &numRenamed, int &numNoPolicy,
CReport &rpt, Command *&pcommand);
int ImportXMLFile(const stringT &ImportedPrefix,
const stringT &strXMLFileName,
const stringT &strXSDFileName,
const bool &bImportPSWDsOnly,
stringT &strXMLErrors, stringT &strSkippedList,
stringT &strPWHErrorList, stringT &strRenameList,
int &numValidated, int &numImported, int &numSkipped,
int &numPWHErrors, int &numRenamed,
int &numNoPolicy, int &numRenamedPolicies,
int &numShortcutsRemoved,
CReport &rpt, Command *&pcommand);
int ImportKeePassV1TXTFile(const StringX &filename,
int &numImported, int &numSkipped, int &numRenamed,
UINT &uiReasonCode, CReport &rpt, Command *&pcommand);
int ImportKeePassV1CSVFile(const StringX &filename,
int &numImported, int &numSkipped, int &numRenamed,
UINT &uiReasonCode, CReport &rpt, Command *&pcommand);
// Locking files open in R/W mode
bool LockFile(const stringT &filename, stringT &locker);
bool IsLockedFile(const stringT &filename) const;
void UnlockFile(const stringT &filename);
// Following 3 routines only for SaveAs to use a temporary lock handle
// LockFile2, UnLockFile2 & MoveLock
bool LockFile2(const stringT &filename, stringT &locker);
void UnlockFile2(const stringT &filename);
void MoveLock()
{m_lockFileHandle = m_lockFileHandle2; m_lockFileHandle2 = INVALID_HANDLE_VALUE;
m_LockCount = m_LockCount2; m_LockCount2 = 0;}
// Set application data
void SetApplicationNameAndVersion(const stringT &appName, DWORD dwMajorMinor);
// Return list of unique groups
void GetUniqueGroups(std::vector<stringT> &vUniqueGroups) const;
// Construct unique title
StringX GetUniqueTitle(const StringX &group, const StringX &title,
const StringX &user, const int IDS_MESSAGE);
// Get all password policy names
void GetPolicyNames(std::vector<stringT> &vNames) const;
bool GetPolicyFromName(const StringX &sxPolicyName, PWPolicy &st_pp) const;
Command *ProcessPolicyName(PWScore *pothercore, CItemData &updtEntry,
std::map<StringX, StringX> &mapRenamedPolicies,
std::vector<StringX> &vs_PoliciesAdded,
StringX &sxOtherPolicyName, bool &bUpdated,
const StringX &sxDateTime, const UINT &IDS_MESSAGE);
// This routine should only be directly called from XML import
void MakePolicyUnique(std::map<StringX, StringX> &mapRenamedPolicies,
StringX &sxPolicyName, const StringX &sxDateTime,
const UINT IDS_MESSAGE);
// Populate setGTU & setUUID from m_pwlist. Returns false & empty set if
// m_pwlist had one or more entries with same GTU/UUID respectively.
bool InitialiseGTU(GTUSet &setGTU);
bool InitialiseGTU(GTUSet &setGTU, const StringX &sxPolicyName);
bool InitialiseUUID(UUIDSet &setUUID);
// Adds an st_GroupTitleUser to setGTU, possible modifying title
// to ensure uniqueness. Returns false if title was modified.
bool MakeEntryUnique(GTUSet &setGTU, const StringX &group, StringX &title,
const StringX &user, const int IDS_MESSAGE);
void SetUniqueGTUValidated(bool bState)
{m_bUniqueGTUValidated = bState;}
bool GetUniqueGTUValidated() const
{return m_bUniqueGTUValidated;}
// Access to individual entries in database
ItemListIter GetEntryIter()
{return m_pwlist.begin();}
ItemListConstIter GetEntryIter() const
{return m_pwlist.begin();}
ItemListIter GetEntryEndIter()
{return m_pwlist.end();}
ItemListConstIter GetEntryEndIter() const
{return m_pwlist.end();}
CItemData &GetEntry(ItemListIter iter)
{return iter->second;}
const CItemData &GetEntry(ItemListConstIter iter) const
{return iter->second;}
ItemList::size_type GetNumEntries() const {return m_pwlist.size();}
// Command functions
int Execute(Command *pcmd);
void Undo();
void Redo();
void ClearCommands();
void ResetStateAfterSave();
bool AnyToUndo() const;
bool AnyToRedo() const;
// Find in m_pwlist by group, title and user name, exact match
ItemListIter Find(const StringX &a_group,
const StringX &a_title, const StringX &a_user);
ItemListIter Find(const pws_os::CUUID &entry_uuid)
{return m_pwlist.find(entry_uuid);}
ItemListConstIter Find(const pws_os::CUUID &entry_uuid) const
{return m_pwlist.find(entry_uuid);}
bool ConfirmDelete(const CItemData *pci); // ask user when about to delete a base,
// otherwise just return true
// General routines for aliases and shortcuts
void GetAllDependentEntries(const pws_os::CUUID &base_uuid,
UUIDVector &dependentslist,
const CItemData::EntryType type);
bool GetDependentEntryBaseUUID(const pws_os::CUUID &entry_uuid,
pws_os::CUUID &base_uuid,
const CItemData::EntryType type) const;
// Takes apart a 'special' password into its components:
bool ParseBaseEntryPWD(const StringX &passwd, BaseEntryParms &pl);
const CItemData *GetBaseEntry(const CItemData *pAliasOrSC) const;
CItemData *GetBaseEntry(const CItemData *pAliasOrSC);
// alias/base and shortcut/base handling
void SortDependents(UUIDVector &dlist, StringX &csDependents);
size_t NumAliases(const pws_os::CUUID &base_uuid) const
{return m_base2aliases_mmap.count(base_uuid);}
size_t NumShortcuts(const pws_os::CUUID &base_uuid) const
{return m_base2shortcuts_mmap.count(base_uuid);}
ItemListIter GetUniqueBase(const StringX &title, bool &bMultiple);
ItemListIter GetUniqueBase(const StringX &grouptitle,
const StringX &titleuser, bool &bMultiple);
// Use following calls to 'SetChanged' & 'SetDBChanged' sparingly
// outside of core
void SetChanged(const bool bDBChanged, const bool bDBprefschanged)
{m_bDBChanged = bDBChanged;
m_bDBPrefsChanged = bDBprefschanged;
NotifyDBModified();}
void SetDBChanged(bool bDBChanged, bool bNotify = true)
{m_bDBChanged = bDBChanged;
if (bNotify) NotifyDBModified();}
void SetDBPrefsChanged(bool bDBprefschanged)
{m_bDBPrefsChanged = bDBprefschanged;
NotifyDBModified();}
bool ChangeMode(stringT &locker, int &iErrorCode);
PWSFileSig& GetCurrentFileSig() {return *m_pFileSig;}
bool IsChanged() const {return m_bDBChanged;}
bool HaveDBPrefsChanged() const {return m_bDBPrefsChanged;}
bool HaveHeaderPreferencesChanged(const StringX &prefString)
{return _tcscmp(prefString.c_str(), m_hdr.m_prefString.c_str()) != 0;}
// Callback to be notified if the database changes
void NotifyDBModified();
void SuspendOnDBNotification()
{m_bNotifyDB = false;}
void ResumeOnDBNotification()
{m_bNotifyDB = true;}
void GUISetupDisplayInfo(CItemData &ci);
void GUIRefreshEntry(const CItemData &ci);
void UpdateWizard(const stringT &s);
// Get/Set Display information from/to database
void SetDisplayStatus(const std::vector<bool> &s);
const std::vector<bool> &GetDisplayStatus() const;
bool WasDisplayStatusChanged() const;
const PWSfile::HeaderRecord &GetHeader() const {return m_hdr;}
void GetDBProperties(st_DBProperties &st_dbp);
void SetHeaderUserFields(st_DBProperties &st_dbp);
StringX &GetDBPreferences() {return m_hdr.m_prefString;}
// Filters
PWSFilters m_MapFilters;
// Changed nodes
void ClearChangedNodes()
{m_vnodes_modified.clear();}
bool IsNodeModified(StringX &path) const;
void GetRUEList(UUIDList &RUElist)
{RUElist = m_RUEList;}
void SetRUEList(const UUIDList &RUElist)
{m_RUEList = RUElist;}
size_t GetExpirySize() {return m_ExpireCandidates.size();}
ExpiredList GetExpired(int idays) {return m_ExpireCandidates.GetExpired(idays);}
// Yubi support:
const unsigned char *GetYubiSK() const;
void SetYubiSK(const unsigned char *);
// Password Policies
bool IncrementPasswordPolicy(const StringX &sxPolicyName);
bool DecrementPasswordPolicy(const StringX &sxPolicyName);
const PSWDPolicyMap &GetPasswordPolicies()
{return m_MapPSWDPLC;}
void SetPasswordPolicies(const PSWDPolicyMap &MapPSWDPLC)
{m_MapPSWDPLC = MapPSWDPLC; SetDBChanged(true);}
void AddPolicy(const StringX &sxPolicyName, const PWPolicy &st_pp,
const bool bAllowReplace = false);
// Empty Groups
void SetEmptyGroups(const std::vector<StringX> &vEmptyGroups)
{m_vEmptyGroups = vEmptyGroups; SetDBChanged(true);}
const std::vector<StringX> &GetEmptyGroups() {return m_vEmptyGroups;}
bool IsEmptyGroup(const StringX &sxEmptyGroup);
// Keyboard shortcuts
bool AddKBShortcut(const int32 &iKBShortcut, const pws_os::CUUID &uuid);
bool DelKBShortcut(const int32 &iKBShortcut, const pws_os::CUUID &uuid);
const pws_os::CUUID & GetKBShortcut(const int32 &iKBShortcut);
const KBShortcutMap &GetAllKBShortcuts() {return m_KBShortcutMap;}
void SetAppHotKey(const int32 &iAppHotKey) {m_iAppHotKey = iAppHotKey;}
int32 GetAppHotKey() const {return m_iAppHotKey;}
uint32 GetHashIters() const;
void SetHashIters(uint32 value);
protected:
bool m_isAuxCore; // set in c'tor, if true, never update prefs from DB.
private:
// Database update routines
// NOTE: Member functions starting with 'Do' or 'Undo' are meant to
// be executed ONLY via Command subclasses. These are implementations of
// the CommandInterface mixin, where they're declared public.
virtual void DoAddEntry(const CItemData &item);
virtual void DoDeleteEntry(const CItemData &item);
virtual void DoReplaceEntry(const CItemData &old_ci, const CItemData &new_ci);
// General routines for aliases and shortcuts
virtual void DoAddDependentEntry(const pws_os::CUUID &base_uuid,
const pws_os::CUUID &entry_uuid,
const CItemData::EntryType type);
virtual void DoRemoveDependentEntry(const pws_os::CUUID &base_uuid,
const pws_os::CUUID &entry_uuid,
const CItemData::EntryType type);
virtual void DoRemoveAllDependentEntries(const pws_os::CUUID &base_uuid,
const CItemData::EntryType type);
virtual int DoAddDependentEntries(UUIDVector &dependentslist, CReport *pRpt,
const CItemData::EntryType type,
const int &iVia,
ItemList *pmapDeletedItems = NULL,
SaveTypePWMap *pmapSaveTypePW = NULL);
virtual void UndoAddDependentEntries(ItemList *pmapDeletedItems,
SaveTypePWMap *pmapSaveTypePW);
virtual void DoMoveDependentEntries(const pws_os::CUUID &from_baseuuid,
const pws_os::CUUID &to_baseuuid,
const CItemData::EntryType type);
virtual int DoUpdatePasswordHistory(int iAction, int new_default_max,
SavePWHistoryMap &mapSavedHistory);
virtual void UndoUpdatePasswordHistory(SavePWHistoryMap &mapSavedHistory);
virtual int DoRenameGroup(const StringX &sxOldPath, const StringX &sxNewPath);
virtual void UndoRenameGroup(const StringX &sxOldPath, const StringX &sxNewPath);
virtual bool AddEmptyGroup(const StringX &sxEmptyGroup);
virtual bool RemoveEmptyGroup(const StringX &sxEmptyGroup);
virtual void RenameEmptyGroup(const StringX &sxOldPath, const StringX &sxNewPath);
// End of Command Interface implementations
// Validate() returns true if data modified, false if all OK
bool Validate(const size_t iMAXCHARS, CReport *pRpt, st_ValidateResults &st_vr);
void ParseDependants(); // populate data structures as needed - called in ReadFile()
void ResetAllAliasPasswords(const pws_os::CUUID &base_uuid);
StringX GetPassKey() const; // returns cleartext - USE WITH CARE
// Following used by SetPassKey
void EncryptPassword(const unsigned char *plaintext, size_t len,
unsigned char *ciphertext) const;
int MergeDependents(PWScore *pothercore, MultiCommands *pmulticmds,
uuid_array_t &base_uuid, uuid_array_t &new_base_uuid,
const bool bTitleRenamed, stringT &timeStr,
const CItemData::EntryType et, std::vector<StringX> &vs_added);
StringX m_currfile; // current pw db filespec
unsigned char *m_passkey; // encrypted by session key
size_t m_passkey_len; // Length of cleartext passkey
uint32 m_hashIters; // for new or currently open db.
static unsigned char m_session_key[32];
static unsigned char m_session_initialized;
HANDLE m_lockFileHandle;
HANDLE m_lockFileHandle2;
int m_LockCount;
int m_LockCount2;
stringT m_AppNameAndVersion;
PWSfile::VERSION m_ReadFileVersion;
bool m_bDBChanged;
bool m_bDBPrefsChanged;
bool m_IsReadOnly;
bool m_bUniqueGTUValidated;
PWSfile::HeaderRecord m_hdr;
std::vector<bool> m_OrigDisplayStatus;
// THE password database
// Key = entry's uuid; Value = entry's CItemData
ItemList m_pwlist;
// Alias/Shortcut structures
// Permanent Multimap: since potentially more than one alias/shortcut per base
// Key = base uuid; Value = multiple alias/shortcut uuids
ItemMMap m_base2aliases_mmap;
ItemMMap m_base2shortcuts_mmap;
// Permanent Map: since an alias only has one base
// Key = alias/shortcut uuid; Value = base uuid
ItemMap m_alias2base_map;
ItemMap m_shortcut2base_map;
// Following are private in PWScore, public in CommandInterface:
const ItemMMap &GetBase2AliasesMmap() const {return m_base2aliases_mmap;}
void SetBase2AliasesMmap(ItemMMap &b2amm) {m_base2aliases_mmap = b2amm;}
const ItemMMap &GetBase2ShortcutsMmap() const {return m_base2shortcuts_mmap;}
void SetBase2ShortcutsMmap(ItemMMap &b2smm) {m_base2shortcuts_mmap = b2smm;}
const ItemMap &GetAlias2BaseMap() const {return m_alias2base_map;}
void SetAlias2BaseMap(const ItemMap &a2bm) {m_alias2base_map = a2bm;}
const ItemMap &GetShortcuts2BaseMap() const {return m_shortcut2base_map;}
void SetShortcuts2BaseMap(const ItemMap &s2bm) {m_shortcut2base_map = s2bm;}
// Changed groups
std::vector<StringX> m_vnodes_modified;
// Following are private in PWScore, public in CommandInterface:
virtual const std::vector<StringX> &GetVnodesModified() const
{return m_vnodes_modified;}
virtual void SetVnodesModified(const std::vector<StringX> &mvm)
{m_vnodes_modified = mvm;}
void AddChangedNodes(StringX path);
// EmptyGroups
std::vector<StringX> m_vEmptyGroups;
UnknownFieldList m_UHFL;
int m_nRecordsWithUnknownFields;
UUIDList m_RUEList;
bool m_bNotifyDB;
UIInterFace *m_pUIIF; // pointer to UI interface abtraction
std::bitset<UIInterFace::NUM_SUPPORTED> m_bsSupportedFunctions;
void NotifyGUINeedsUpdating(UpdateGUICommand::GUI_Action, const pws_os::CUUID &,
CItemData::FieldType ft = CItemData::START,
bool bUpdateGUI = true);
// Create header for included(Text) and excluded(XML) exports
StringX BuildHeader(const CItemData::FieldBits &bsFields, const bool bIncluded);
// Command list for Undo/Redo
std::vector<Command *> m_vpcommands;
std::vector<Command *>::iterator m_undo_iter;
std::vector<Command *>::iterator m_redo_iter;
static Reporter *m_pReporter; // set as soon as possible to show errors
static Asker *m_pAsker;
PWSFileSig *m_pFileSig;
// Entries with an expiry date
ExpiredList m_ExpireCandidates;
void AddExpiryEntry(const CItemData &ci)
{m_ExpireCandidates.Add(ci);}
void UpdateExpiryEntry(const CItemData &ci)
{m_ExpireCandidates.Update(ci);}
void UpdateExpiryEntry(const pws_os::CUUID &uuid, const CItemData::FieldType ft,
const StringX &value);
void RemoveExpiryEntry(const CItemData &ci)
{m_ExpireCandidates.Remove(ci);}
stringT GetXMLPWPolicies();
PSWDPolicyMap m_MapPSWDPLC;
KBShortcutMap m_KBShortcutMap;
int32 m_iAppHotKey;
// ValidateKBShortcut() returns true if data modified, false if all OK
bool ValidateKBShortcut(int32 &iKBShortcut);
};
/**
* Use this for "other" cores that we want concurrently.
* This class does not update the database preferences
* when reading a database, so there's no need to save/restore
* the "main" db prefs.
*/
class PWSAuxCore : public PWScore {
public:
PWSAuxCore() : PWScore() {m_isAuxCore = true;}
};
#endif /* __PWSCORE_H */