summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/serializer.cpp
Side-by-side diff
Diffstat (limited to 'pwmanager/pwmanager/serializer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/serializer.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 5753c1d..507fa30 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -36,13 +36,13 @@
#define META_CREATE_DATE "c"
#define META_VALID_DATE "v"
#define META_EXPIRE_DATE "e"
#define META_UPDATE_DATE "u"
#define META_UPDATE_INT "i"
-//US ENH : uniqueid
+//US ENH : uniqueid and sync information
#define META_UNIQUEID "n"
#define SYNC_ROOT "s"
#define SYNC_TARGET_PREFIX "t"
#define SYNC_TARGET_NAME "n"
@@ -53,12 +53,15 @@
#define ROOT_MAGIC_OLD "PwM-xml-dat"
#define VER_STR_OLD "ver"
#define COMPAT_VER_OLD "0x02"
#define CAT_ROOT_OLD "categories"
#define CAT_PREFIX_OLD "cat_"
#define CAT_NAME_OLD "name"
+//US ENH : optional text for categories
+#define CAT_TEXT_OLD "text"
+
#define ENTRY_PREFIX_OLD "entry_"
#define ENTRY_DESC_OLD "desc"
#define ENTRY_NAME_OLD "name"
#define ENTRY_PW_OLD "pw"
#define ENTRY_COMMENT_OLD "comment"
#define ENTRY_URL_OLD "url"
@@ -70,12 +73,15 @@
#define ROOT_MAGIC_NEW "P"
#define VER_STR_NEW "v"
#define COMPAT_VER_NEW "2"
#define CAT_ROOT_NEW "c"
#define CAT_PREFIX_NEW "c"
#define CAT_NAME_NEW "n"
+//US ENH : optional text for categories
+#define CAT_TEXT_NEW "t"
+
#define ENTRY_PREFIX_NEW "e"
#define ENTRY_DESC_NEW "d"
#define ENTRY_NAME_NEW "n"
#define ENTRY_PW_NEW "p"
#define ENTRY_COMMENT_NEW "c"
#define ENTRY_URL_NEW "u"
@@ -88,12 +94,16 @@
# define ROOT_MAGIC_WR ROOT_MAGIC_OLD
# define VER_STR_WR VER_STR_OLD
# define COMPAT_VER_WR COMPAT_VER_OLD
# define CAT_ROOT_WR CAT_ROOT_OLD
# define CAT_PREFIX_WR CAT_PREFIX_OLD
# define CAT_NAME_WR CAT_NAME_OLD
+
+//US ENH : optional text for categories
+# define CAT_TEXT_WR CAT_TEXT_OLD
+
# define ENTRY_PREFIX_WR ENTRY_PREFIX_OLD
# define ENTRY_DESC_WR ENTRY_DESC_OLD
# define ENTRY_NAME_WR ENTRY_NAME_OLD
# define ENTRY_PW_WR ENTRY_PW_OLD
# define ENTRY_COMMENT_WR ENTRY_COMMENT_OLD
# define ENTRY_URL_WR ENTRY_URL_OLD
@@ -105,12 +115,16 @@
# define ROOT_MAGIC_WR ROOT_MAGIC_NEW
# define VER_STR_WR VER_STR_NEW
# define COMPAT_VER_WR COMPAT_VER_NEW
# define CAT_ROOT_WR CAT_ROOT_NEW
# define CAT_PREFIX_WR CAT_PREFIX_NEW
# define CAT_NAME_WR CAT_NAME_NEW
+
+//US ENH : optional text for categories
+# define CAT_TEXT_WR CAT_TEXT_NEW
+
# define ENTRY_PREFIX_WR ENTRY_PREFIX_NEW
# define ENTRY_DESC_WR ENTRY_DESC_NEW
# define ENTRY_NAME_WR ENTRY_NAME_NEW
# define ENTRY_PW_WR ENTRY_PW_NEW
# define ENTRY_COMMENT_WR ENTRY_COMMENT_NEW
# define ENTRY_URL_WR ENTRY_URL_NEW
@@ -268,12 +282,13 @@ bool Serializer::deSerialize(PwMItem *dta)
bool Serializer::readCategories(const QDomNode &n,
vector<PwMCategoryItem> *dta)
{
QDomNodeList nl(n.childNodes());
QDomNode cur;
QString name;
+ QString text;
unsigned int numCat = nl.count(), i;
PwMCategoryItem curCat;
vector<PwMDataItem> curEntr;
if (!numCat) {
printDebug("Serializer::readCategories(): empty");
@@ -287,12 +302,29 @@ bool Serializer::readCategories(const QDomNode &n,
if (name == QString::null)
name = cur.toElement().attribute(CAT_NAME_OLD);
PWM_ASSERT(name != QString::null);
PWM_ASSERT(name != "");
curCat.clear();
curCat.name = name.latin1();
+
+ //US ENH: new version might include text for description, name and pw
+ text = cur.toElement().attribute(CAT_TEXT_NEW);
+ if (text == QString::null)
+ text = cur.toElement().attribute(CAT_TEXT_OLD);
+ if (text != QString::null)
+ {
+ QStringList textlist = QStringList::split(";", text, true);
+ unsigned int num = textlist.count();
+ if (num > 0)
+ curCat.desc_text = textlist[0].latin1();
+ if (num > 1)
+ curCat.name_text = textlist[1].latin1();
+ if (num > 2)
+ curCat.pw_text = textlist[2].latin1();
+ }
+
if (!readEntries(cur, &curEntr)) {
dta->clear();
return false;
}
curCat.d = curEntr;
dta->push_back(curCat);
@@ -498,12 +530,22 @@ bool Serializer::addCategories(QDomElement *e,
for (i = 0; i < numCat; ++i) {
curId = CAT_PREFIX_WR;
curId += tostr(i).c_str();
curName = dta[i].name.c_str();
curCat = domDoc->createElement(curId);
curCat.setAttribute(CAT_NAME_WR, curName);
+
+ //US ENH: new version includes text for description, name and pw
+ QStringList curTextList;
+ curTextList << dta[i].desc_text.c_str();
+ curTextList << dta[i].name_text.c_str();
+ curTextList << dta[i].pw_text.c_str();
+ QString text = curTextList.join(";");
+ curCat.setAttribute(CAT_TEXT_WR, text);
+
+
if (!addEntries(&curCat, dta[i].d)) {
return false;
}
e->appendChild(curCat);
}
return true;