summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/pwmdoc.h
Side-by-side diff
Diffstat (limited to 'pwmanager/pwmanager/pwmdoc.h') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmdoc.h70
1 files changed, 62 insertions, 8 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index ea4d687..91277f6 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -197,40 +197,66 @@ struct PwMDataItem
desc = "";
name = "";
pw = "";
comment = "";
url = "";
launcher = "";
lockStat = true;
listViewPos = -1;
binary = false;
if (clearMeta)
meta.clear();
}
+
};
struct PwMCategoryItem
{
/** all PwMDataItems (all passwords) within this category */
vector<PwMDataItem> d;
/** category name/description */
string name;
void clear()
{
d.clear();
name = "";
}
};
+struct PwMSyncItem
+{
+ string syncName;
+ QDateTime lastSyncDate;
+
+ void clear()
+ {
+ lastSyncDate = QDateTime();
+ syncName = "";
+ }
+};
+
+struct PwMItem
+{
+ vector<PwMCategoryItem> dta;
+ vector<PwMSyncItem> syncDta;
+
+ void clear()
+ {
+ dta.clear();
+ syncDta.clear();
+ }
+};
+
+
/** "Function Object" for sort()ing PwMDataItem::listViewPos */
class dta_lvp_greater
{
public:
bool operator() (const pair<unsigned int, unsigned int> &d1,
const pair<unsigned int, unsigned int> &d2)
{
return d1.second > d2.second;
}
};
/** list of PwMDoc documents and it's IDs */
@@ -431,31 +457,32 @@ public:
void findEntry(unsigned int category, PwMDataItem find, unsigned int searchIn,
vector<unsigned int> *foundPositions, bool breakAfterFound = false,
bool caseSensitive = true, bool exactWordMatch = true,
bool sortByLvp = false);
/** see the above funtion. This function allows to set the category by name. */
void findEntry(const QString &category, PwMDataItem find, unsigned int searchIn,
vector<unsigned int> *foundPositions, bool breakAfterFound = false,
bool caseSensitive = true, bool exactWordMatch = true,
bool sortByLvp = false);
/** returns number of entries */
unsigned int numEntries(const QString &category);
unsigned int numEntries(unsigned int category)
- { return dta[category].d.size(); }
+ { return dti.dta[category].d.size(); }
/** returns number of categories */
unsigned int numCategories()
- { return dta.size(); }
+ { return dti.dta.size(); }
/** returns the name of the category at "index" */
const string* getCategory(unsigned int index)
- { return (&(dta[index].name)); }
+ { return (&(dti.dta[index].name)); }
+
/** returns the data of item at "index".
* It unlocks the entry if it's locked and unlockIfLocked is true.
* If the entry is locked, but unlockIfLocked is false, it'll not return
* the pw.
*/
bool getEntry(const QString &category, unsigned int index,
PwMDataItem *d, bool unlockIfLocked = false);
bool getEntry(unsigned int category, unsigned int index,
PwMDataItem *d, bool unlockIfLocked = false);
/** returns the comment-string by looking at the category
* and the listViewPos
*/
@@ -463,25 +490,25 @@ public:
string *foundComment);
/** checks if a password is already available. (currentPw) */
bool isPwAvailable()
{ return (currentPw != ""); }
/** un/lock entry at "index". If needed, ask for password. */
bool lockAt(const QString &category, unsigned int index,
bool lock = true);
bool lockAt(unsigned int category, unsigned int index,
bool lock = true);
/** returns the lock-status at "index" */
bool isLocked(const QString &category, unsigned int index);
bool isLocked(unsigned int category, unsigned int index)
- { return dta[category].d[index].lockStat; }
+ { return dti.dta[category].d[index].lockStat; }
/** returns the deeplock status */
bool isDeepLocked()
{ return getDocStatFlag(DOC_STAT_DEEPLOCKED); }
/** (un)lock all entries */
bool lockAll(bool lock);
/** unlocks all entries tempoarly.
* 1st NOTE: Be very careful with this function! :)
* 2nd NOTE: After you have called unlockAll_Tempoary(); ,
* please DON'T forget to call unlockAll_Tempoary(true);
* _before_ the user (or someone else) is able to change
* the document!
* 3rd NOTE: Please DON'T change "dta" while the data is tempoary
@@ -565,31 +592,31 @@ public:
DocTimer * timer()
{ return _timer; }
/** get a lock on the dataChanged signal.
* If someone is holding a lock, the signal is not emitted.
*/
void getDataChangedLock()
{ ++dataChangedLock; }
/** put the dataChanged lock */
void putDataChangedLock()
{ --dataChangedLock; }
/** returns the revision count of the item at cat/index */
unsigned int getEntryRevCnt(unsigned int category, unsigned int index)
- { return dta[category].d[index].rev; }
+ { return dti.dta[category].d[index].rev; }
/** returns a const pointer to the entries meta */
const PwMMetaData * getEntryMeta(unsigned int category, unsigned int index)
- { return &(dta[category].d[index].meta); }
+ { return &(dti.dta[category].d[index].meta); }
/** is the entry at "category" "index" a binary entry? */
bool isBinEntry(unsigned int category, unsigned int index)
- { return dta[category].d[index].binary; }
+ { return dti.dta[category].d[index].binary; }
public slots:
/** wrapper for PwMTray */
void _deepUnlock();
signals:
/** the data of the document has changed and must be updated
* in all views.
* NOTE: use emitDataChanged(PwMDoc *document) to emit this signal!
*/
void dataChanged(PwMDoc *document);
/** the document class is going to close. This signal may be
@@ -604,26 +631,28 @@ signals:
public:
/** emit the dataChanged signal after checking for a lock */
void emitDataChanged(PwMDoc *document)
{
if (!dataChangedLock)
emit dataChanged(document);
}
protected:
/** current file for this doc */
QString filename;
+//US ENH: we need a place where we keep the syncentries. So I invented
+// struct PwMItem, that has a vector of PwMCategoryItem and vector of PwMSyncItem
/** holds all data */
- vector<PwMCategoryItem> dta;
+ PwMItem dti;
/** maximum number of entries */
unsigned int maxEntries;
/** currently used password to encrypt data */
QString currentPw;
/** current global document status flags */
unsigned int curDocStat;
/** browser process for goToURL() */
KProcess browserProc;
/** pointer to the list-view, using this document.
* As there can only be one list-view per doc, we
* don't need a list here.
*/
@@ -698,27 +727,52 @@ protected:
}
/** make a backup-copy of the given file */
bool backupFile(const QString &filePath);
/** copy a file from src to dst */
bool copyFile(const QString &src, const QString &dst);
public:
#ifdef PWM_EMBEDDED
//US ENH: this is the magic function that syncronizes the local doc with the remote doc.
PwMerror syncronize(KSyncManager* manager, PwMDoc* syncLocal, PwMDoc* syncRemote, int mode );
+ //takePwMDataItem returns the following values
+ // 0 equal
+ // 1 take local
+ // 2 take remote
+ // 3 cancel
+ int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full );
//the following methods are the overwritten callbackmethods from the syncinterface
virtual bool sync(KSyncManager* manager, QString filename, int mode);
//called by the syncmanager to indicate that the work has to be marked as dirty.
virtual void sync_setModified();
//called by the syncmanager to ask if the dirty flag is set.
virtual bool sync_isModified();
//called by the syncmanager to indicate that the work has to be saved.
virtual void sync_save();
+
#endif
+ private:
+ //US ENH: helpermethods to access the sync data for a certain syncname.
+ // It returns the syncdatas index
+ bool findSyncData(const QString &syncname, unsigned int *index);
+
+ /** add new syncdataentry */
+ PwMerror addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty = false);
+
+ /** returns a pointer to the syncdata */
+ PwMSyncItem* getSyncDataEntry(unsigned int index)
+ { return &(dti.syncDta[index]); }
+
+ /** delete entry */
+ bool delSyncDataEntry(unsigned int index, bool dontFlagDirty = false);
+
+ PwMDataItem* findEntryByID(const QString &uid, unsigned int *category, unsigned int *index);
+
+ QStringList getIDEntryList();
};
#endif