summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwm.cpp10
-rw-r--r--pwmanager/pwmanager/pwmdocui.cpp10
-rw-r--r--pwmanager/pwmanager/serializer.cpp8
3 files changed, 18 insertions, 10 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 9798e8e..b7b5307 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -3,48 +3,50 @@
3 * copyright (C) 2003, 2004 by Michael Buesch * 3 * copyright (C) 2003, 2004 by Michael Buesch *
4 * email: mbuesch@freenet.de * 4 * email: mbuesch@freenet.de *
5 * * 5 * *
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License version 2 * 7 * it under the terms of the GNU General Public License version 2 *
8 * as published by the Free Software Foundation. * 8 * as published by the Free Software Foundation. *
9 * * 9 * *
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include <klocale.h> 20#include <klocale.h>
21#include <klistview.h> 21#include <klistview.h>
22#include <ktoolbar.h> 22#include <ktoolbar.h>
23#include <kfiledialog.h> 23#include <kfiledialog.h>
24#include <kiconloader.h> 24#include <kiconloader.h>
25#include <kmessagebox.h> 25#include <kmessagebox.h>
26 26
27#include <qstatusbar.h>
28
27#ifndef PWM_EMBEDDED 29#ifndef PWM_EMBEDDED
28#include <kmenubar.h> 30#include <kmenubar.h>
29#include <kstatusbar.h> 31#include <kstatusbar.h>
30#include <dcopclient.h> 32#include <dcopclient.h>
31#include "configwndimpl.h" 33#include "configwndimpl.h"
32#include "configuration.h" 34#include "configuration.h"
33#else 35#else
34#include <qmenubar.h> 36#include <qmenubar.h>
35#include <qmessagebox.h> 37#include <qmessagebox.h>
36#include <pwmprefs.h> 38#include <pwmprefs.h>
37#include <kpimglobalprefs.h> 39#include <kpimglobalprefs.h>
38#include <kcmconfigs/kcmpwmconfig.h> 40#include <kcmconfigs/kcmpwmconfig.h>
39#include <kcmconfigs/kcmkdepimconfig.h> 41#include <kcmconfigs/kcmkdepimconfig.h>
40#include <kcmultidialog.h> 42#include <kcmultidialog.h>
41#endif 43#endif
42 44
43 45
44#ifndef DESKTOP_VERSION 46#ifndef DESKTOP_VERSION
45#include <qpe/global.h> 47#include <qpe/global.h>
46#endif 48#endif
47 49
48#include <qpixmap.h> 50#include <qpixmap.h>
49#include <qcheckbox.h> 51#include <qcheckbox.h>
50#include <qspinbox.h> 52#include <qspinbox.h>
@@ -1337,59 +1339,57 @@ void PwM::goToURL_slot()
1337 if (!view->getCurEntryIndex(&curEntryIndex)) 1339 if (!view->getCurEntryIndex(&curEntryIndex))
1338 return; 1340 return;
1339 bool ret = curDoc()->goToURL(view->getCurrentCategory(), 1341 bool ret = curDoc()->goToURL(view->getCurrentCategory(),
1340 curEntryIndex); 1342 curEntryIndex);
1341 if (ret) 1343 if (ret)
1342 showStatMsg(i18n("started browser with current URL.")); 1344 showStatMsg(i18n("started browser with current URL."));
1343 else 1345 else
1344 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?")); 1346 showStatMsg(i18n("ERROR: Couldn't start browser! Maybe invalid URL?"));
1345} 1347}
1346 1348
1347void PwM::copyToClipboard(const QString &s) 1349void PwM::copyToClipboard(const QString &s)
1348{ 1350{
1349 QClipboard *cb = QApplication::clipboard(); 1351 QClipboard *cb = QApplication::clipboard();
1350#ifndef PWM_EMBEDDED 1352#ifndef PWM_EMBEDDED
1351 if (cb->supportsSelection()) 1353 if (cb->supportsSelection())
1352 cb->setText(s, QClipboard::Selection); 1354 cb->setText(s, QClipboard::Selection);
1353 cb->setText(s, QClipboard::Clipboard); 1355 cb->setText(s, QClipboard::Clipboard);
1354#else 1356#else
1355 cb->setText(s); 1357 cb->setText(s);
1356 1358
1357#endif 1359#endif
1358 1360
1359} 1361}
1360 1362
1363
1361void PwM::showStatMsg(const QString &msg) 1364void PwM::showStatMsg(const QString &msg)
1362{ 1365{
1363#ifndef PWM_EMBEDDED 1366#ifdef DESKTOP_VERSION
1364 KStatusBar *statBar = statusBar(); 1367 statusBar()->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1365 statBar->message(msg, STATUSBAR_MSG_TIMEOUT * 1000);
1366#else 1368#else
1367 qDebug("Statusbar : %s",msg.latin1()); 1369 qDebug("Statusbar : %s",msg.latin1());
1368#ifndef DESKTOP_VERSION
1369 Global::statusMessage(msg); 1370 Global::statusMessage(msg);
1370#endif 1371#endif
1371#endif
1372} 1372}
1373 1373
1374void PwM::focusInEvent(QFocusEvent *e) 1374void PwM::focusInEvent(QFocusEvent *e)
1375{ 1375{
1376 if (e->gotFocus()) { 1376 if (e->gotFocus()) {
1377 emit gotFocus(this); 1377 emit gotFocus(this);
1378 } else if (e->lostFocus()) { 1378 } else if (e->lostFocus()) {
1379 emit lostFocus(this); 1379 emit lostFocus(this);
1380 } 1380 }
1381} 1381}
1382 1382
1383 1383
1384#ifdef PWM_EMBEDDED 1384#ifdef PWM_EMBEDDED
1385 1385
1386void PwM::whatsnew_slot() 1386void PwM::whatsnew_slot()
1387{ 1387{
1388 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1388 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1389} 1389}
1390 1390
1391void PwM::showLicense_slot() 1391void PwM::showLicense_slot()
1392{ 1392{
1393 KApplication::showLicence(); 1393 KApplication::showLicence();
1394} 1394}
1395 1395
diff --git a/pwmanager/pwmanager/pwmdocui.cpp b/pwmanager/pwmanager/pwmdocui.cpp
index 6ddb6f5..71b4a8d 100644
--- a/pwmanager/pwmanager/pwmdocui.cpp
+++ b/pwmanager/pwmanager/pwmdocui.cpp
@@ -358,90 +358,90 @@ bool PwMDocUi::openDocUi(PwMDoc *doc,
358#endif 358#endif
359 } 359 }
360 if (filename.isEmpty()) 360 if (filename.isEmpty())
361 goto cancelOpen; 361 goto cancelOpen;
362 PwMerror ret; 362 PwMerror ret;
363 while (true) { 363 while (true) {
364 int lockStat = -1; 364 int lockStat = -1;
365 if (openDeepLocked) { 365 if (openDeepLocked) {
366 lockStat = 2; 366 lockStat = 2;
367 } else { 367 } else {
368 if (conf()->confGlobUnlockOnOpen()) { 368 if (conf()->confGlobUnlockOnOpen()) {
369 lockStat = 0; 369 lockStat = 0;
370 } else { 370 } else {
371 lockStat = 1; 371 lockStat = 1;
372 } 372 }
373 } 373 }
374 ret = doc->openDoc(&filename, lockStat); 374 ret = doc->openDoc(&filename, lockStat);
375 //qDebug("pwmdocui::OpenDocui %i", ret); 375 //qDebug("pwmdocui::OpenDocui %i", ret);
376 if (ret != e_success) { 376 if (ret != e_success) {
377 if (ret == e_readFile || ret == e_openFile) { 377 if (ret == e_readFile || ret == e_openFile) {
378 KMessageBox::error(getCurrentView(), 378 KMessageBox::error(getCurrentView(),
379 i18n("Could not read file!") 379 i18n("Could not read file!")
380 + "\n" 380 + "\n"
381 + filename, 381 + filename,
382 i18n("file error")); 382 i18n("File error"));
383 goto cancelOpen; 383 goto cancelOpen;
384 } 384 }
385 if (ret == e_alreadyOpen) { 385 if (ret == e_alreadyOpen) {
386 KMessageBox::error(getCurrentView(), 386 KMessageBox::error(getCurrentView(),
387 i18n("This file is already open."), 387 i18n("This file is already open."),
388 i18n("already open")); 388 i18n("Already open"));
389 goto cancelOpen; 389 goto cancelOpen;
390 } 390 }
391 if (ret == e_fileVer) { 391 if (ret == e_fileVer) {
392 KMessageBox::error(getCurrentView(), 392 KMessageBox::error(getCurrentView(),
393 i18n 393 i18n
394 ("File-version is not supported!\n" 394 ("File-version is not supported!\n"
395 "Did you create this file with an\nolder or newer version of PwM?"), 395 "Did you create this file with an\nolder or newer version of PwM?"),
396 i18n 396 i18n
397 ("incompatible version")); 397 ("Incompatible version"));
398 goto cancelOpen; 398 goto cancelOpen;
399 } 399 }
400 if (ret == e_wrongPw) { 400 if (ret == e_wrongPw) {
401 continue; 401 continue;
402 } 402 }
403 if (ret == e_noPw) { 403 if (ret == e_noPw) {
404 goto cancelOpen; 404 goto cancelOpen;
405 } 405 }
406 if (ret == e_fileFormat) { 406 if (ret == e_fileFormat) {
407 KMessageBox::error(getCurrentView(), 407 KMessageBox::error(getCurrentView(),
408 i18n 408 i18n
409 ("Sorry, this file has not been recognized\n" 409 ("Sorry, this file has not been recognized\n"
410 "as a PwM Password file.\n" 410 "as a PwM Password file.\n"
411 "Probably you have selected the wrong file."), 411 "Probably you have selected the wrong file."),
412 i18n 412 i18n
413 ("no PwM password-file")); 413 ("No PwM password-file"));
414 goto cancelOpen; 414 goto cancelOpen;
415 } 415 }
416 if (ret == e_fileCorrupt) { 416 if (ret == e_fileCorrupt) {
417 KMessageBox::error(getCurrentView(), 417 KMessageBox::error(getCurrentView(),
418 i18n 418 i18n
419 ("File corrupt!\n" 419 ("File corrupt!\n"
420 "Maybe the media, you stored this file on,\n" 420 "Maybe the media, you stored this file on,\n"
421 "had bad sectors?"), 421 "had bad sectors?"),
422 i18n 422 i18n
423 ("checksum error")); 423 ("Checksum error"));
424 goto cancelOpen; 424 goto cancelOpen;
425 } 425 }
426 } 426 }
427 break; 427 break;
428 } 428 }
429 return true; 429 return true;
430 430
431 cancelOpen: 431 cancelOpen:
432 return false; 432 return false;
433} 433}
434 434
435QString PwMDocUi::string_defaultCategory() 435QString PwMDocUi::string_defaultCategory()
436{ 436{
437 return i18n("Default"); 437 return i18n("Default");
438} 438}
439 439
440QString PwMDocUi::string_locked() 440QString PwMDocUi::string_locked()
441{ 441{
442 return i18n("<LOCKED>"); 442 return i18n("<LOCKED>");
443} 443}
444 444
445QString PwMDocUi::string_deepLockedShort() 445QString PwMDocUi::string_deepLockedShort()
446{ 446{
447 return i18n("DEEP-LOCKED"); 447 return i18n("DEEP-LOCKED");
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index ed0f754..5753c1d 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -144,48 +144,50 @@ Serializer::Serializer(const QCString &buffer)
144 144
145 if (!parseXml(buffer)) { 145 if (!parseXml(buffer)) {
146 delete domDoc; 146 delete domDoc;
147#ifndef PWM_EMBEDDED 147#ifndef PWM_EMBEDDED
148 throw PwMException(PwMException::EX_PARSE); 148 throw PwMException(PwMException::EX_PARSE);
149#else 149#else
150 qDebug("Serializer::Serializer : Parse Exception "); 150 qDebug("Serializer::Serializer : Parse Exception ");
151#endif 151#endif
152 } 152 }
153} 153}
154 154
155Serializer::~Serializer() 155Serializer::~Serializer()
156{ 156{
157 delete_ifnot_null(domDoc); 157 delete_ifnot_null(domDoc);
158} 158}
159 159
160void Serializer::clear() 160void Serializer::clear()
161{ 161{
162 delete_ifnot_null(domDoc); 162 delete_ifnot_null(domDoc);
163 domDoc = new QDomDocument; 163 domDoc = new QDomDocument;
164} 164}
165 165
166bool Serializer::parseXml(const QCString &buffer) 166bool Serializer::parseXml(const QCString &buffer)
167{ 167{
168 //abort();
169 //qDebug("parse %s ", buffer.data());
168 PWM_ASSERT(domDoc); 170 PWM_ASSERT(domDoc);
169#ifndef PWM_EMBEDDED 171#ifndef PWM_EMBEDDED
170 if (!domDoc->setContent(buffer, true)) 172 if (!domDoc->setContent(buffer, true))
171 return false; 173 return false;
172#else 174#else
173#ifdef DESKTOP_VERSION 175#ifdef DESKTOP_VERSION
174 if (!domDoc->setContent(buffer, true)) 176 if (!domDoc->setContent(buffer, true))
175#else 177#else
176 if (!domDoc->setContent(buffer)) 178 if (!domDoc->setContent(buffer))
177#endif 179#endif
178 return false; 180 return false;
179#endif 181#endif
180 if (!checkValid()) 182 if (!checkValid())
181 return false; 183 return false;
182 return true; 184 return true;
183} 185}
184 186
185QCString Serializer::getXml() 187QCString Serializer::getXml()
186{ 188{
187 PWM_ASSERT(domDoc); 189 PWM_ASSERT(domDoc);
188 190
189#ifndef PWM_EMBEDDED 191#ifndef PWM_EMBEDDED
190#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 192#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
191 QCString tmp(domDoc->toCString(8)); 193 QCString tmp(domDoc->toCString(8));
@@ -335,48 +337,49 @@ bool Serializer::extractEntry(const QDomNode &n,
335 QDomNodeList nl(n.childNodes()); 337 QDomNodeList nl(n.childNodes());
336 QDomNode cur, cdata; 338 QDomNode cur, cdata;
337 unsigned int cnt = nl.count(), i; 339 unsigned int cnt = nl.count(), i;
338 QString name, text; 340 QString name, text;
339 341
340 if (!cnt) { 342 if (!cnt) {
341 printDebug("Serializer::extractEntry(): empty"); 343 printDebug("Serializer::extractEntry(): empty");
342 return false; 344 return false;
343 } 345 }
344 dta->clear(); 346 dta->clear();
345 for (i = 0; i < cnt; ++i) { 347 for (i = 0; i < cnt; ++i) {
346 cur = nl.item(i); 348 cur = nl.item(i);
347 name = cur.nodeName(); 349 name = cur.nodeName();
348 cdata = cur.firstChild(); 350 cdata = cur.firstChild();
349 if (unlikely(cdata.isCDATASection())) { 351 if (unlikely(cdata.isCDATASection())) {
350 text = cdata.toCDATASection().data(); 352 text = cdata.toCDATASection().data();
351 } else if (likely(cur.isElement())) { 353 } else if (likely(cur.isElement())) {
352 text = cur.toElement().text(); 354 text = cur.toElement().text();
353 } else { 355 } else {
354 printDebug("Serializer::extractEntry(): neither CDATA nor element."); 356 printDebug("Serializer::extractEntry(): neither CDATA nor element.");
355 return false; 357 return false;
356 } 358 }
357 if (text == " ") 359 if (text == " ")
358 text = ""; // for backward compatibility. 360 text = ""; // for backward compatibility.
361 //qDebug("entry %s ",unescapeEntryData(text).latin1());
359 if (name == ENTRY_DESC_NEW || 362 if (name == ENTRY_DESC_NEW ||
360 name == ENTRY_DESC_OLD) { 363 name == ENTRY_DESC_OLD) {
361 dta->desc = unescapeEntryData(text).latin1(); 364 dta->desc = unescapeEntryData(text).latin1();
362 } else if (name == ENTRY_NAME_NEW || 365 } else if (name == ENTRY_NAME_NEW ||
363 name == ENTRY_NAME_OLD) { 366 name == ENTRY_NAME_OLD) {
364 dta->name = unescapeEntryData(text).latin1(); 367 dta->name = unescapeEntryData(text).latin1();
365 } else if (name == ENTRY_PW_NEW || 368 } else if (name == ENTRY_PW_NEW ||
366 name == ENTRY_PW_OLD) { 369 name == ENTRY_PW_OLD) {
367 dta->pw = unescapeEntryData(text).latin1(); 370 dta->pw = unescapeEntryData(text).latin1();
368 } else if (name == ENTRY_COMMENT_NEW || 371 } else if (name == ENTRY_COMMENT_NEW ||
369 name == ENTRY_COMMENT_OLD) { 372 name == ENTRY_COMMENT_OLD) {
370 dta->comment = unescapeEntryData(text).latin1(); 373 dta->comment = unescapeEntryData(text).latin1();
371 } else if (name == ENTRY_URL_NEW || 374 } else if (name == ENTRY_URL_NEW ||
372 name == ENTRY_URL_OLD) { 375 name == ENTRY_URL_OLD) {
373 dta->url = unescapeEntryData(text).latin1(); 376 dta->url = unescapeEntryData(text).latin1();
374 } else if (name == ENTRY_LAUNCHER_NEW || 377 } else if (name == ENTRY_LAUNCHER_NEW ||
375 name == ENTRY_LAUNCHER_OLD) { 378 name == ENTRY_LAUNCHER_OLD) {
376 dta->launcher = unescapeEntryData(text).latin1(); 379 dta->launcher = unescapeEntryData(text).latin1();
377 } else if (name == ENTRY_LVP_NEW || 380 } else if (name == ENTRY_LVP_NEW ||
378 name == ENTRY_LVP_OLD) { 381 name == ENTRY_LVP_OLD) {
379 dta->listViewPos = strtol(text.latin1(), 0, 10); 382 dta->listViewPos = strtol(text.latin1(), 0, 10);
380 } else if (name == ENTRY_BIN_NEW) { 383 } else if (name == ENTRY_BIN_NEW) {
381 // ENTRY_BIN_NEW == ENTRY_BIN_OLD 384 // ENTRY_BIN_NEW == ENTRY_BIN_OLD
382 if (text == "0") { 385 if (text == "0") {
@@ -680,51 +683,56 @@ bool Serializer::writeMeta(QDomElement *e,
680 e->appendChild(tag); 683 e->appendChild(tag);
681 684
682#undef new_text 685#undef new_text
683 return true; 686 return true;
684} 687}
685 688
686QString Serializer::escapeEntryData(QString dta) 689QString Serializer::escapeEntryData(QString dta)
687{ 690{
688#ifndef PWM_EMBEDDED 691#ifndef PWM_EMBEDDED
689 dta.replace('\n', "$>--endl--<$"); 692 dta.replace('\n', "$>--endl--<$");
690 dta.replace("]]>", "||>"); 693 dta.replace("]]>", "||>");
691#else 694#else
692 dta.replace(QRegExp("\n"), "$>--endl--<$"); 695 dta.replace(QRegExp("\n"), "$>--endl--<$");
693 dta.replace(QRegExp("]]>"), "||>"); 696 dta.replace(QRegExp("]]>"), "||>");
694#endif 697#endif
695 return dta; 698 return dta;
696} 699}
697 700
698QString Serializer::unescapeEntryData(QString dta) 701QString Serializer::unescapeEntryData(QString dta)
699{ 702{
700#ifndef PWM_EMBEDDED 703#ifndef PWM_EMBEDDED
701 dta.replace("$>--endl--<$", "\n"); 704 dta.replace("$>--endl--<$", "\n");
702 dta.replace("||>", "]]>"); 705 dta.replace("||>", "]]>");
703#else 706#else
707#ifdef DESKTOP_VERSION
708 dta.replace("$>--endl--<$", "\n");
709 dta.replace("||>", "]]>");
710#else
704 dta.replace(QRegExp("\\$>--endl--<\\$"), "\n"); 711 dta.replace(QRegExp("\\$>--endl--<\\$"), "\n");
705 dta.replace(QRegExp("||>"), "]]>"); 712 dta.replace(QRegExp("||>"), "]]>");
706#endif 713#endif
714#endif
707 return dta; 715 return dta;
708} 716}
709 717
710 718
711//US ENH: the following methods are getting used to write/read sync entries 719//US ENH: the following methods are getting used to write/read sync entries
712/** read the syncentries in the node "n" */ 720/** read the syncentries in the node "n" */
713bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta) 721bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta)
714{ 722{
715 QDomNodeList nl(n.childNodes()); 723 QDomNodeList nl(n.childNodes());
716 QDomNode cur; 724 QDomNode cur;
717 725
718 QString devicename, val; 726 QString devicename, val;
719 unsigned int numSync = nl.count(), i; 727 unsigned int numSync = nl.count(), i;
720 PwMSyncItem curSync; 728 PwMSyncItem curSync;
721 bool ok = true; 729 bool ok = true;
722 730
723 if (!numSync) { 731 if (!numSync) {
724 //no sync entries is a possible result 732 //no sync entries is a possible result
725 printDebug("Serializer::readSyncData(): empty"); 733 printDebug("Serializer::readSyncData(): empty");
726 return true; 734 return true;
727 } 735 }
728 for (i = 0; i < numSync; ++i) { 736 for (i = 0; i < numSync; ++i) {
729 cur = nl.item(i); 737 cur = nl.item(i);
730 if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) { 738 if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) {