summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-24 22:21:25 (UTC)
committer ulf69 <ulf69>2004-09-24 22:21:25 (UTC)
commite695903cc49b33e63505b651b13d830e318fc29a (patch) (side-by-side diff)
treefd210e2defbdcb3f3d9d739d0b00e6853705af29
parenta884dac6f756b3702a10ae97aa8782e4d2a84b20 (diff)
downloadkdepimpi-e695903cc49b33e63505b651b13d830e318fc29a.zip
kdepimpi-e695903cc49b33e63505b651b13d830e318fc29a.tar.gz
kdepimpi-e695903cc49b33e63505b651b13d830e318fc29a.tar.bz2
fixed bug with QDomDocument handling, plus some GUI enhancements
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp8
-rw-r--r--pwmanager/pwmanager/pwmexception.cpp7
-rw-r--r--pwmanager/pwmanager/serializer.cpp12
3 files changed, 23 insertions, 4 deletions
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index e42dd9d..5e675fc 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -395,63 +395,63 @@ bool PwMDocUi::openDocUi(PwMDoc *doc,
}
if (ret == e_fileFormat) {
KMessageBox::error(getCurrentView(),
i18n
("Sorry, this file has not been recognized "
"as a PwM Password file.\n"
"Probably you have selected the wrong file."),
i18n
("no PwM password-file"));
goto cancelOpen;
}
if (ret == e_fileCorrupt) {
KMessageBox::error(getCurrentView(),
i18n
("File corrupt!\n"
"Maybe the media, you stored this file on, "
"had bad sectors?"),
i18n
("checksum error"));
goto cancelOpen;
}
}
break;
}
return true;
cancelOpen:
return false;
}
QString PwMDocUi::string_defaultCategory()
{
return i18n("Default");
}
QString PwMDocUi::string_locked()
{
return i18n("<LOCKED>");
}
QString PwMDocUi::string_deepLockedShort()
{
return i18n("DEEP-LOCKED");
}
QString PwMDocUi::string_deepLockedLong()
{
return i18n("This file is DEEP-LOCKED!\n"
- "That means all data has been encrypted "
- "and written out to the file. If you want "
- "to see the entries, please UNLOCK the file. "
- "While unlocking, you will be prompted for the "
+ "That means all data has been encrypted\n"
+ "and written out to the file. If you want\n"
+ "to see the entries, please UNLOCK the file.\n"
+ "While unlocking, you will be prompted for the\n"
"master-password or the key-card.");
}
QString PwMDocUi::string_defaultTitle()
{
return i18n("Untitled");
}
#ifndef PWM_EMBEDDED
#include "pwmdocui.moc"
#endif
diff --git a/pwmanager/pwmanager/pwmexception.cpp b/pwmanager/pwmanager/pwmexception.cpp
index 4c00b04..c0dbb39 100644
--- a/pwmanager/pwmanager/pwmexception.cpp
+++ b/pwmanager/pwmanager/pwmexception.cpp
@@ -1,58 +1,65 @@
/***************************************************************************
* *
* copyright (C) 2003, 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 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "pwmexception.h"
#include <kmessagebox.h>
void pwmFatal(const char *id,
const char *file,
int line)
{
cerr << PROG_NAME " " << id << " at "
<< file << ":" << line
<< endl;
}
void __printError(const string &msg)
{
QString __msg(PROG_NAME " generated a fatal fault:\n");
__msg += msg.c_str();
cerr << "\n\n" << __msg.latin1() << endl;
KMessageBox::error(0, __msg, PROG_NAME " fatal ERROR!");
}
void __printInfo(const string &msg)
{
cout << PROG_NAME " INFO: " << msg << endl;
+#ifdef PWM_DEBUG
+ qDebug("%s INFO: %s", PROG_NAME, msg.c_str()) ;
+#endif
}
void __printWarn(const string &msg)
{
cerr << PROG_NAME " WARNING: " << msg << endl;
+#ifdef PWM_DEBUG
+ qDebug("%s WARNING: %s", PROG_NAME, msg.c_str()) ;
+#endif
}
#ifdef PWM_DEBUG
void __printDebug(const string &msg)
{
cout << PROG_NAME " DEBUG: " << msg << endl;
+ qDebug("%s DEBUG: %s", PROG_NAME, msg.c_str()) ;
}
#endif // PWM_DEBUG
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 2810b48..fcdcec3 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -75,159 +75,171 @@
#define ENTRY_PW_NEW "p"
#define ENTRY_COMMENT_NEW "c"
#define ENTRY_URL_NEW "u"
#define ENTRY_LAUNCHER_NEW "l"
#define ENTRY_LVP_NEW "v"
#define ENTRY_BIN_NEW ENTRY_BIN_OLD
#define ENTRY_META_NEW ENTRY_META_OLD
#if USE_OLD_TAGS != 0
# 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
# 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
# define ENTRY_LAUNCHER_WR ENTRY_LAUNCHER_OLD
# define ENTRY_LVP_WR ENTRY_LVP_OLD
# define ENTRY_BIN_WR ENTRY_BIN_OLD
# define ENTRY_META_WR ENTRY_META_OLD
#else
# 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
# 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
# define ENTRY_LAUNCHER_WR ENTRY_LAUNCHER_NEW
# define ENTRY_LVP_WR ENTRY_LVP_NEW
# define ENTRY_BIN_WR ENTRY_BIN_NEW
# define ENTRY_META_WR ENTRY_META_NEW
#endif
Serializer::Serializer()
{
defaultLockStat = true;
+//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
+#ifndef PWM_EMBEDDED
domDoc = new QDomDocument;
+#else
+ domDoc = new QDomDocument("mydoc");
+#endif
}
Serializer::Serializer(const QCString &buffer)
{
defaultLockStat = true;
+//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
+#ifndef PWM_EMBEDDED
domDoc = new QDomDocument;
+#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
if (!domDoc->setContent(buffer))
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
QCString ret(domDoc->toCString());
ret.replace(QRegExp("\n"), "");
return ret;
#endif
}
bool Serializer::serialize(const vector<PwMCategoryItem> &dta)
{
PWM_ASSERT(domDoc);
QDomElement root(genNewRoot());
QDomElement catNode(domDoc->createElement(CAT_ROOT_WR));
root.appendChild(catNode);
if (!addCategories(&catNode, dta))
return false;
return true;
}
bool Serializer::deSerialize(vector<PwMCategoryItem> *dta)
{
PWM_ASSERT(domDoc);
PWM_ASSERT(dta);
QDomElement root(domDoc->documentElement());
QDomNode n;
dta->clear();
for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) {
// find <categories> ... </categories>
// <c> ... </c>
if (n.nodeName() == CAT_ROOT_NEW ||
n.nodeName() == CAT_ROOT_OLD) {
if (!readCategories(n, dta)) {
return false;
}
/* NOTE: We can stop processing here, as we
* don't have more nodes in root, yet.
*/
return true;
}
}
return false;
}