Diffstat (limited to 'pwmanager/pwmanager/serializer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/serializer.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp index 2d6498e..ed0f754 100644 --- a/pwmanager/pwmanager/serializer.cpp +++ b/pwmanager/pwmanager/serializer.cpp @@ -141,65 +141,69 @@ Serializer::Serializer(const QCString &buffer) #else domDoc = new QDomDocument("mydoc"); #endif if (!parseXml(buffer)) { delete domDoc; #ifndef PWM_EMBEDDED throw PwMException(PwMException::EX_PARSE); #else qDebug("Serializer::Serializer : Parse Exception "); #endif } } Serializer::~Serializer() { delete_ifnot_null(domDoc); } void Serializer::clear() { delete_ifnot_null(domDoc); domDoc = new QDomDocument; } bool Serializer::parseXml(const QCString &buffer) { PWM_ASSERT(domDoc); #ifndef PWM_EMBEDDED if (!domDoc->setContent(buffer, true)) return false; #else +#ifdef DESKTOP_VERSION + if (!domDoc->setContent(buffer, true)) +#else if (!domDoc->setContent(buffer)) +#endif return false; #endif if (!checkValid()) return false; return true; } QCString Serializer::getXml() { PWM_ASSERT(domDoc); #ifndef PWM_EMBEDDED #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 QCString tmp(domDoc->toCString(8)); printDebug("<BEGIN Serializer::getXml() dump>\n"); cout << tmp << endl; printDebug("<END Serializer::getXml() dump>"); #endif // DEBUG QCString ret(domDoc->toCString(0)); ret.replace('\n', ""); return ret; #else #if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 QCString tmp(" " + domDoc->toCString()); printDebug("<BEGIN Serializer::getXml() dump>\n"); qDebug(tmp); cout << tmp << endl; printDebug("<END Serializer::getXml() dump>"); #endif // DEBUG @@ -703,65 +707,65 @@ QString Serializer::unescapeEntryData(QString dta) return dta; } //US ENH: the following methods are getting used to write/read sync entries /** read the syncentries in the node "n" */ bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta) { QDomNodeList nl(n.childNodes()); QDomNode cur; QString devicename, val; unsigned int numSync = nl.count(), i; PwMSyncItem curSync; bool ok = true; if (!numSync) { //no sync entries is a possible result printDebug("Serializer::readSyncData(): empty"); return true; } for (i = 0; i < numSync; ++i) { cur = nl.item(i); if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) { devicename = cur.toElement().attribute(SYNC_TARGET_NAME); val = cur.toElement().text(); if ((val == "") || (devicename == QString::null)) { printDebug("Serializer::readSyncData(): empty synctarget name or syncdate"); continue; } - curSync.syncName = devicename; + curSync.syncName = devicename.latin1(); #ifndef PWM_EMBEDDED curSync.lastSyncDate = QDateTime::fromString(val, Qt::ISODate); #else curSync.lastSyncDate = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); if (ok == false) qDebug("Serializer::readSyncData(): could not parse syncdate:%s",val.latin1()); #endif dta->push_back(curSync); } } return true; } bool Serializer::addSyncData(QDomElement *e, const vector<PwMSyncItem> &dta) { unsigned int numSync = dta.size(), i; QString curId, curDeviceName; QDomElement curSync; QDomText text; for (i = 0; i < numSync; ++i) { curId = SYNC_TARGET_PREFIX; curId += tostr(i).c_str(); curDeviceName = dta[i].syncName.c_str(); curSync = domDoc->createElement(curId); curSync.setAttribute(SYNC_TARGET_NAME, curDeviceName); |