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
@@ -39,7 +39,7 @@
#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"
@@ -56,6 +56,9 @@
#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"
@@ -73,6 +76,9 @@
#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"
@@ -91,6 +97,10 @@
# 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
@@ -108,6 +118,10 @@
# 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
@@ -271,6 +285,7 @@ bool Serializer::readCategories(const QDomNode &n,
QDomNodeList nl(n.childNodes());
QDomNode cur;
QString name;
+ QString text;
unsigned int numCat = nl.count(), i;
PwMCategoryItem curCat;
vector<PwMDataItem> curEntr;
@@ -290,6 +305,23 @@ bool Serializer::readCategories(const QDomNode &n,
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;
@@ -501,6 +533,16 @@ bool Serializer::addCategories(QDomElement *e,
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;
}