summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/serializer.h
authorulf69 <ulf69>2004-09-15 17:53:22 (UTC)
committer ulf69 <ulf69>2004-09-15 17:53:22 (UTC)
commitd3925ba5bd25224bc4a60d3d6a107c464994a1ea (patch) (side-by-side diff)
tree60f69da1d2b79ee3081e7ef5c09a46470ca6eda0 /pwmanager/pwmanager/serializer.h
parentce83a3479d23b9e8a59c745ccd0a0b14f64ef4e8 (diff)
downloadkdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.zip
kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.gz
kdepimpi-d3925ba5bd25224bc4a60d3d6a107c464994a1ea.tar.bz2
initial revision
Diffstat (limited to 'pwmanager/pwmanager/serializer.h') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/serializer.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/serializer.h b/pwmanager/pwmanager/serializer.h
new file mode 100644
index 0000000..245fcee
--- a/dev/null
+++ b/pwmanager/pwmanager/serializer.h
@@ -0,0 +1,102 @@
+/***************************************************************************
+ * *
+ * copyright (C) 2004 by Michael Buesch *
+ * email: mbuesch@freenet.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License version 2 *
+ * as published by the Free Software Foundation. *
+ * *
+ ***************************************************************************/
+
+
+/***************************************************************************
+ * copyright (C) 2004 by Ulf Schenk
+ * This file is originaly based on version 2.0 of pwmanager
+ * and was modified to run on embedded devices that run microkde
+ *
+ * $Id$
+ **************************************************************************/
+
+#ifndef __SERIALIZER_H
+#define __SERIALIZER_H
+
+#include "pwmdoc.h"
+
+#include <qcstring.h>
+#include <qdom.h>
+
+#include <vector>
+
+using std::vector;
+
+/** This serializes its input data into
+ * the PwManager-XML-datastream, that becomes
+ * encrypted and maybe compressed
+ */
+class Serializer
+{
+public:
+ /** construct an empty serializer document */
+ Serializer();
+ /** construct a serializer document and parse "buffer" */
+ Serializer(const QCString &buffer);
+ /** destructor */
+ virtual ~Serializer();
+
+ /** clears all data */
+ void clear();
+ /** parse the given data buffer */
+ bool parseXml(const QCString &buffer);
+ /** returns the current XML data */
+ QCString getXml();
+ /** serialize "dta" and store it as XML data */
+ bool serialize(const vector<PwMCategoryItem> &dta);
+ /** deserialize the (parsed) XML data and store it in "dta" */
+ bool deSerialize(vector<PwMCategoryItem> *dta);
+ /** sets the initial default lockStat we should assign */
+ void setDefaultLockStat(bool stat)
+ { defaultLockStat = stat; }
+
+protected:
+ /** main data holder */
+ QDomDocument *domDoc;
+ /** default lockStat to assign */
+ bool defaultLockStat;
+
+protected:
+ /** check if this is valid PwManager XML data */
+ bool checkValid();
+ /** read the categories in the node "n" */
+ bool readCategories(const QDomNode &n,
+ vector<PwMCategoryItem> *dta);
+ /** read the entries in the node "n" */
+ bool readEntries(const QDomNode &n,
+ vector<PwMDataItem> *dta);
+ /** extract the data out of the given item at "n" */
+ bool extractEntry(const QDomNode &n,
+ PwMDataItem *dta);
+ /** extract the meta-data */
+ bool extractMeta(const QDomNode &n,
+ PwMMetaData *dta);
+ /** generates a new root node and sets all initial parameters */
+ QDomElement genNewRoot();
+ /** add new categories to the XML data stream in e */
+ bool addCategories(QDomElement *e,
+ const vector<PwMCategoryItem> &dta);
+ /** add the given new entries to the XML data stream in e */
+ bool addEntries(QDomElement *e,
+ const vector<PwMDataItem> &dta);
+ /** do serialize and write the given entry to the XML stream */
+ bool writeEntry(QDomElement *e,
+ const PwMDataItem &_dta);
+ /** write the entry meta data to the xml stream */
+ bool writeMeta(QDomElement *e,
+ const PwMMetaData &dta);
+ /** escape illegal characters out of the given entry data string */
+ QString escapeEntryData(QString dta);
+ /** un-escape illegal characters out of the given entry data string */
+ QString unescapeEntryData(QString dta);
+};
+
+#endif // __SERIALIZER_H