summaryrefslogtreecommitdiffabout
path: root/pwmanager
authorzautrix <zautrix>2004-10-19 23:38:16 (UTC)
committer zautrix <zautrix>2004-10-19 23:38:16 (UTC)
commitf013ff3c0108100c6dbf037a05502ed493361fbf (patch) (unidiff)
treebf274ac58b55cea0e2f609db8ae5f27f4418a2df /pwmanager
parentf605b2d40ff0f90b132ca880afa83ac751162a2e (diff)
downloadkdepimpi-f013ff3c0108100c6dbf037a05502ed493361fbf.zip
kdepimpi-f013ff3c0108100c6dbf037a05502ed493361fbf.tar.gz
kdepimpi-f013ff3c0108100c6dbf037a05502ed493361fbf.tar.bz2
desktop fixes
Diffstat (limited to 'pwmanager') (more/less context) (show whitespace changes)
-rw-r--r--pwmanager/pwmanager/main.cpp1
-rw-r--r--pwmanager/pwmanager/pwm.cpp12
-rw-r--r--pwmanager/pwmanager/pwm.h8
-rw-r--r--pwmanager/pwmanager/pwmanager.pro33
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp8
-rw-r--r--pwmanager/pwmanager/pwminit.cpp16
-rw-r--r--pwmanager/pwmanager/serializer.cpp6
7 files changed, 52 insertions, 32 deletions
diff --git a/pwmanager/pwmanager/main.cpp b/pwmanager/pwmanager/main.cpp
index 3f2d055..9d1d863 100644
--- a/pwmanager/pwmanager/main.cpp
+++ b/pwmanager/pwmanager/main.cpp
@@ -110,104 +110,105 @@ static void addAuthors(KAboutData *aboutData)
110 "Gentoo ebuild maintainer."), 110 "Gentoo ebuild maintainer."),
111 "elias.probst@gmx.de"); 111 "elias.probst@gmx.de");
112 aboutData->addCredit("George Staikos", 112 aboutData->addCredit("George Staikos",
113 I18N_NOOP("KWallet"), 113 I18N_NOOP("KWallet"),
114 "staikos@kde.org"); 114 "staikos@kde.org");
115 aboutData->addCredit("Matthew Palmer", 115 aboutData->addCredit("Matthew Palmer",
116 I18N_NOOP("rc2 code"), 116 I18N_NOOP("rc2 code"),
117 "mjp16@uow.edu.au"); 117 "mjp16@uow.edu.au");
118 aboutData->addCredit("Olivier Sessink", 118 aboutData->addCredit("Olivier Sessink",
119 I18N_NOOP("gpasman"), 119 I18N_NOOP("gpasman"),
120 "gpasman@nl.linux.org"); 120 "gpasman@nl.linux.org");
121 aboutData->addCredit("The libgcrypt developers", 121 aboutData->addCredit("The libgcrypt developers",
122 I18N_NOOP("Blowfish and SHA1 algorithms"), 122 I18N_NOOP("Blowfish and SHA1 algorithms"),
123 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/"); 123 0, "ftp://ftp.gnupg.org/gcrypt/alpha/libgcrypt/");
124 aboutData->addCredit("Troy Engel", 124 aboutData->addCredit("Troy Engel",
125 I18N_NOOP("kpasman"), 125 I18N_NOOP("kpasman"),
126 "tengel@sonic.net"); 126 "tengel@sonic.net");
127 aboutData->addCredit("Wickey", 127 aboutData->addCredit("Wickey",
128 I18N_NOOP("graphics-design in older versions."), 128 I18N_NOOP("graphics-design in older versions."),
129 "wickey@gmx.at"); 129 "wickey@gmx.at");
130 aboutData->addCredit("Ian MacGregor", 130 aboutData->addCredit("Ian MacGregor",
131 I18N_NOOP( 131 I18N_NOOP(
132 "original documentation author.")); 132 "original documentation author."));
133} 133}
134#endif 134#endif
135 135
136int main(int argc, char *argv[]) 136int main(int argc, char *argv[])
137{ 137{
138 printDebugConfigureInfo(); 138 printDebugConfigureInfo();
139#ifndef PWM_EMBEDDED 139#ifndef PWM_EMBEDDED
140 KAboutData aboutData(PACKAGE_NAME, PROG_NAME, 140 KAboutData aboutData(PACKAGE_NAME, PROG_NAME,
141 PACKAGE_VER, description, KAboutData::License_File, 141 PACKAGE_VER, description, KAboutData::License_File,
142 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0, 142 "(c) 2003, 2004 Michael Buesch and the PwManager Team", 0,
143 "http://passwordmanager.sourceforge.net/", 143 "http://passwordmanager.sourceforge.net/",
144 "mbuesch@freenet.de"); 144 "mbuesch@freenet.de");
145 addAuthors(&aboutData); 145 addAuthors(&aboutData);
146 146
147 KCmdLineArgs::init(argc, argv, &aboutData); 147 KCmdLineArgs::init(argc, argv, &aboutData);
148 KCmdLineArgs::addCmdLineOptions(options); 148 KCmdLineArgs::addCmdLineOptions(options);
149 149
150 KUniqueApplication::addCmdLineOptions(); 150 KUniqueApplication::addCmdLineOptions();
151 if (!KUniqueApplication::start()) { 151 if (!KUniqueApplication::start()) {
152 printInfo("already running."); 152 printInfo("already running.");
153 return EXIT_SUCCESS; 153 return EXIT_SUCCESS;
154 } 154 }
155 PwMApplication a; 155 PwMApplication a;
156 aboutData.setLicenseTextFile(LICENSE_FILE); 156 aboutData.setLicenseTextFile(LICENSE_FILE);
157 return a.exec(); 157 return a.exec();
158#else 158#else
159 159
160 bool exitHelp = false; 160 bool exitHelp = false;
161 if ( argc > 1 ) { 161 if ( argc > 1 ) {
162 QString command = argv[1]; 162 QString command = argv[1];
163 if ( command == "-help" ){ 163 if ( command == "-help" ){
164 printf("PWM/PI command line commands:\n"); 164 printf("PWM/PI command line commands:\n");
165 printf(" no command: Start PWM/PI in usual way\n"); 165 printf(" no command: Start PWM/PI in usual way\n");
166 printf(" -help: This output\n"); 166 printf(" -help: This output\n");
167 printf(" PWM/PI is exiting now. Bye!\n"); 167 printf(" PWM/PI is exiting now. Bye!\n");
168 exitHelp = true; 168 exitHelp = true;
169 } 169 }
170 } 170 }
171 if ( ! exitHelp ) { 171 if ( ! exitHelp ) {
172 172
173 PwMApplication a(argc, argv); 173 PwMApplication a(argc, argv);
174 174
175 KGlobal::setAppName( "pwmanager" ); 175 KGlobal::setAppName( "pwmanager" );
176#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
177 //qDebug("width %d ",QApplication::desktop()->width() ); 177 //qDebug("width %d ",QApplication::desktop()->width() );
178 if ( QApplication::desktop()->width() > 320 ) 178 if ( QApplication::desktop()->width() > 320 )
179 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/"); 179 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons22/");
180 else 180 else
181 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/"); 181 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/pwmanager/icons16/");
182#else 182#else
183 QString fileName ; 183 QString fileName ;
184 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/"; 184 fileName = qApp->applicationDirPath () + "/kdepim/pwmanager/icons22/";
185 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 185 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
186 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 186 QApplication::addLibraryPath ( qApp->applicationDirPath () );
187 187
188#endif 188#endif
189 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager"))); 189 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "pwmanager")));
190 KPimGlobalPrefs::instance()->setGlobalConfig(); 190 KPimGlobalPrefs::instance()->setGlobalConfig();
191 191
192 a.newInstance(); 192 a.newInstance();
193 193
194 //US KAddressBookMain m ; 194 //US KAddressBookMain m ;
195 195
196 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 196 //US QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
197 /*US 197 /*US
198#ifndef DESKTOP_VERSION 198#ifndef DESKTOP_VERSION
199 a.showMainWidget( &m ); 199 a.showMainWidget( &m );
200#else 200#else
201 a.setMainWidget( &m ); 201 a.setMainWidget( &m );
202 m.resize (640, 480 ); 202 m.resize (640, 480 );
203 m.show(); 203 m.show();
204#endif 204#endif
205 */ 205 */
206 qDebug("exec ");
206 a.exec(); 207 a.exec();
207 208
208 } 209 }
209 qDebug("PWMPI: Bye! "); 210 qDebug("PWMPI: Bye! ");
210 211
211#endif 212#endif
212 213
213} 214}
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 26a44b1..c511661 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -493,270 +493,270 @@ void PwM::setVirgin(bool v)
493 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v); 493 toolBar()->setItemEnabled(BUTTON_TOOL_SAVEAS, !v);
494 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v); 494 toolBar()->setItemEnabled(BUTTON_TOOL_PRINT, !v);
495 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v); 495 toolBar()->setItemEnabled(BUTTON_TOOL_EDIT, !v);
496 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v); 496 toolBar()->setItemEnabled(BUTTON_TOOL_DEL, !v);
497 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v); 497 toolBar()->setItemEnabled(BUTTON_TOOL_LOCK, !v);
498 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v); 498 toolBar()->setItemEnabled(BUTTON_TOOL_DEEPLOCK, !v);
499 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v); 499 toolBar()->setItemEnabled(BUTTON_TOOL_UNLOCK, !v);
500 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v); 500 toolBar()->setItemEnabled(BUTTON_TOOL_FIND, !v);
501} 501}
502 502
503void PwM::new_slot() 503void PwM::new_slot()
504{ 504{
505 init->createMainWnd(); 505 init->createMainWnd();
506} 506}
507 507
508//US ENH 508//US ENH
509void PwM::open_slot() 509void PwM::open_slot()
510{ 510{
511 open_slot(""); 511 open_slot("");
512} 512}
513 513
514void PwM::open_slot(QString fn) 514void PwM::open_slot(QString fn)
515{ 515{
516 openDoc(fn); 516 openDoc(fn);
517} 517}
518 518
519PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked) 519PwMDoc * PwM::openDoc(QString filename, bool openDeepLocked)
520{ 520{
521 if (!isVirgin()) { 521 if (!isVirgin()) {
522 // open the document in a new window. 522 // open the document in a new window.
523 PwM *newInstance = init->createMainWnd(); 523 PwM *newInstance = init->createMainWnd();
524 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked); 524 PwMDoc *newDoc = newInstance->openDoc(filename, openDeepLocked);
525 if (!newDoc) { 525 if (!newDoc) {
526 newInstance->setForceQuit(true); 526 newInstance->setForceQuit(true);
527 delete_and_null(newInstance); 527 delete_and_null(newInstance);
528 } 528 }
529 return newDoc; 529 return newDoc;
530 } 530 }
531 531
532 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked)) 532 if (!curDoc()->openDocUi(curDoc(), filename, openDeepLocked))
533 return 0; 533 return 0;
534 showStatMsg(i18n("Successfully opened file.")); 534 showStatMsg(i18n("Successfully opened file."));
535 updateCaption(); 535 updateCaption();
536 setVirgin(false); 536 setVirgin(false);
537 return curDoc(); 537 return curDoc();
538} 538}
539 539
540PwMView * PwM::makeNewListView(PwMDoc *doc) 540PwMView * PwM::makeNewListView(PwMDoc *doc)
541{ 541{
542 PwMView *ret = new PwMView(this, this, doc); 542 PwMView *ret = new PwMView(this, this, doc);
543 ret->setFont(conf()->confGlobEntryFont()); 543 ret->setFont(conf()->confGlobEntryFont());
544 ret->show(); 544 ret->show();
545 return ret; 545 return ret;
546} 546}
547 547
548void PwM::close_slot() 548void PwM::close_slot()
549{ 549{
550 close(); 550 close();
551} 551}
552 552
553void PwM::quitButton_slot() 553void PwM::quitButton_slot()
554{ 554{
555 init->shutdownApp(0); 555 init->shutdownApp(0);
556} 556}
557 557
558void PwM::save_slot() 558void PwM::save_slot()
559{ 559{
560 save(); 560 save();
561} 561}
562 562
563bool PwM::save() 563bool PwM::save()
564{ 564{
565 if (!curDoc()->saveDocUi(curDoc())) 565 if (!curDoc()->saveDocUi(curDoc()))
566 return false; 566 return false;
567 showStatMsg(i18n("Successfully saved data.")); 567 showStatMsg(i18n("Successfully saved data."));
568 updateCaption(); 568 updateCaption();
569 return true; 569 return true;
570} 570}
571 571
572void PwM::saveAs_slot() 572void PwM::saveAs_slot()
573{ 573{
574 saveAs(); 574 saveAs();
575} 575}
576 576
577bool PwM::saveAs() 577bool PwM::saveAs()
578{ 578{
579 if (!curDoc()->saveAsDocUi(curDoc())) 579 if (!curDoc()->saveAsDocUi(curDoc()))
580 return false; 580 return false;
581 showStatMsg(i18n("Successfully saved data.")); 581 showStatMsg(i18n("Successfully saved data."));
582 updateCaption(); 582 updateCaption();
583 return true; 583 return true;
584} 584}
585 585
586//US ENH : changed code to run with older MOC 586//US ENH : changed code to run with older MOC
587void PwM::addPwd_slot() 587void PwM::addPwd_slot()
588{ 588{
589 addPwd_slot(0, 0); 589 addPwd_slot1(0, 0);
590} 590}
591 591
592void PwM::addPwd_slot(QString *pw, PwMDoc *_doc) 592void PwM::addPwd_slot1(QString *pw, PwMDoc *_doc)
593{ 593{
594 PwMDoc *doc; 594 PwMDoc *doc;
595 if (_doc) { 595 if (_doc) {
596 doc = _doc; 596 doc = _doc;
597 } else { 597 } else {
598 doc = curDoc(); 598 doc = curDoc();
599 } 599 }
600 PWM_ASSERT(doc); 600 PWM_ASSERT(doc);
601 doc->timer()->getLock(DocTimer::id_autoLockTimer); 601 doc->timer()->getLock(DocTimer::id_autoLockTimer);
602#ifndef PWM_EMBEDDED 602#ifndef PWM_EMBEDDED
603 AddEntryWndImpl w; 603 AddEntryWndImpl w;
604#else 604#else
605 AddEntryWndImpl w(this, "addentrywndimpl"); 605 AddEntryWndImpl w(this, "addentrywndimpl");
606#endif 606#endif
607 607
608 vector<string> catList; 608 vector<string> catList;
609 doc->getCategoryList(&catList); 609 doc->getCategoryList(&catList);
610 unsigned i, size = catList.size(); 610 unsigned i, size = catList.size();
611 for (i = 0; i < size; ++i) { 611 for (i = 0; i < size; ++i) {
612 w.addCategory(catList[i].c_str()); 612 w.addCategory(catList[i].c_str());
613 } 613 }
614 w.setCurrCategory(view->getCurrentCategory()); 614 w.setCurrCategory(view->getCurrentCategory());
615 if (pw) 615 if (pw)
616 w.pwLineEdit->setText(*pw); 616 w.pwLineEdit->setText(*pw);
617 617
618 tryAgain: 618 tryAgain:
619 if (w.exec() == 1) 619 if (w.exec() == 1)
620 { 620 {
621 PwMDataItem d; 621 PwMDataItem d;
622 622
623 //US BUG: to initialize all values of curEntr with meaningfulldata, 623 //US BUG: to initialize all values of curEntr with meaningfulldata,
624 // we call clear on it. Reason: Metadata will be uninitialized otherwise. 624 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
625 // another option would be to create a constructor for PwMDataItem 625 // another option would be to create a constructor for PwMDataItem
626 d.clear(true); 626 d.clear(true);
627 627
628 d.desc = w.getDescription().latin1(); 628 d.desc = w.getDescription().latin1();
629 d.name = w.getUsername().latin1(); 629 d.name = w.getUsername().latin1();
630 d.pw = w.getPassword().latin1(); 630 d.pw = w.getPassword().latin1();
631 d.comment = w.getComment().latin1(); 631 d.comment = w.getComment().latin1();
632 d.url = w.getUrl().latin1(); 632 d.url = w.getUrl().latin1();
633 d.launcher = w.getLauncher().latin1(); 633 d.launcher = w.getLauncher().latin1();
634 PwMerror ret = doc->addEntry(w.getCategory(), &d); 634 PwMerror ret = doc->addEntry(w.getCategory(), &d);
635 if (ret == e_entryExists) { 635 if (ret == e_entryExists) {
636 KMessageBox::error(this, 636 KMessageBox::error(this,
637 i18n 637 i18n
638 ("An entry with this \"Description\",\n" 638 ("An entry with this \"Description\",\n"
639 "does already exist.\n" 639 "does already exist.\n"
640 "Please select another description."), 640 "Please select another description."),
641 i18n("entry already exists.")); 641 i18n("entry already exists."));
642 goto tryAgain; 642 goto tryAgain;
643 } else if (ret == e_maxAllowedEntr) { 643 } else if (ret == e_maxAllowedEntr) {
644 KMessageBox::error(this, i18n("The maximum possible number of\nentries" 644 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
645 "has been reached.\nYou can't add more entries."), 645 "has been reached.\nYou can't add more entries."),
646 i18n("maximum number of entries")); 646 i18n("maximum number of entries"));
647 doc->timer()->putLock(DocTimer::id_autoLockTimer); 647 doc->timer()->putLock(DocTimer::id_autoLockTimer);
648 return; 648 return;
649 } 649 }
650 } 650 }
651 setVirgin(false); 651 setVirgin(false);
652 doc->timer()->putLock(DocTimer::id_autoLockTimer); 652 doc->timer()->putLock(DocTimer::id_autoLockTimer);
653} 653}
654 654
655//US ENH : changed code to run with older MOC 655//US ENH : changed code to run with older MOC
656void PwM::editPwd_slot() 656void PwM::editPwd_slot()
657{ 657{
658 editPwd_slot(0,0,0); 658 editPwd_slot3(0,0,0);
659} 659}
660 660
661void PwM::editPwd_slot(const QString *category) 661void PwM::editPwd_slot1(const QString *category)
662{ 662{
663 editPwd_slot(category, 0, 0); 663 editPwd_slot3(category, 0, 0);
664} 664}
665 665
666void PwM::editPwd_slot(const QString *category, const int *index, 666void PwM::editPwd_slot3(const QString *category, const int *index,
667 PwMDoc *_doc) 667 PwMDoc *_doc)
668{ 668{
669 PwMDoc *doc; 669 PwMDoc *doc;
670 if (_doc) { 670 if (_doc) {
671 doc = _doc; 671 doc = _doc;
672 } else { 672 } else {
673 doc = curDoc(); 673 doc = curDoc();
674 } 674 }
675 PWM_ASSERT(doc); 675 PWM_ASSERT(doc);
676 if (doc->isDocEmpty()) 676 if (doc->isDocEmpty())
677 return; 677 return;
678 if (doc->isDeepLocked()) 678 if (doc->isDeepLocked())
679 return; 679 return;
680 doc->timer()->getLock(DocTimer::id_autoLockTimer); 680 doc->timer()->getLock(DocTimer::id_autoLockTimer);
681 unsigned int curEntryIndex; 681 unsigned int curEntryIndex;
682 if (index) { 682 if (index) {
683 curEntryIndex = *index; 683 curEntryIndex = *index;
684 } else { 684 } else {
685 if (!(view->getCurEntryIndex(&curEntryIndex))) { 685 if (!(view->getCurEntryIndex(&curEntryIndex))) {
686 printDebug("couldn't get index. Maybe we have a binary entry here."); 686 printDebug("couldn't get index. Maybe we have a binary entry here.");
687 doc->timer()->putLock(DocTimer::id_autoLockTimer); 687 doc->timer()->putLock(DocTimer::id_autoLockTimer);
688 return; 688 return;
689 } 689 }
690 } 690 }
691 QString curCategory; 691 QString curCategory;
692 if (category) { 692 if (category) {
693 curCategory = *category; 693 curCategory = *category;
694 } else { 694 } else {
695 curCategory = view->getCurrentCategory(); 695 curCategory = view->getCurrentCategory();
696 } 696 }
697 PwMDataItem currItem; 697 PwMDataItem currItem;
698 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) { 698 if (!doc->getEntry(curCategory, curEntryIndex, &currItem, true)) {
699 doc->timer()->putLock(DocTimer::id_autoLockTimer); 699 doc->timer()->putLock(DocTimer::id_autoLockTimer);
700 return; 700 return;
701 } 701 }
702 BUG_ON(currItem.binary); 702 BUG_ON(currItem.binary);
703 703
704 AddEntryWndImpl w; 704 AddEntryWndImpl w;
705 vector<string> catList; 705 vector<string> catList;
706 doc->getCategoryList(&catList); 706 doc->getCategoryList(&catList);
707 unsigned i, size = catList.size(); 707 unsigned i, size = catList.size();
708 for (i = 0; i < size; ++i) { 708 for (i = 0; i < size; ++i) {
709 w.addCategory(catList[i].c_str()); 709 w.addCategory(catList[i].c_str());
710 } 710 }
711 w.setCurrCategory(curCategory); 711 w.setCurrCategory(curCategory);
712 w.setDescription(currItem.desc.c_str()); 712 w.setDescription(currItem.desc.c_str());
713 w.setUsername(currItem.name.c_str()); 713 w.setUsername(currItem.name.c_str());
714 w.setPassword(currItem.pw.c_str()); 714 w.setPassword(currItem.pw.c_str());
715 w.setUrl(currItem.url.c_str()); 715 w.setUrl(currItem.url.c_str());
716 w.setLauncher(currItem.launcher.c_str()); 716 w.setLauncher(currItem.launcher.c_str());
717 w.setComment(currItem.comment.c_str()); 717 w.setComment(currItem.comment.c_str());
718 if (w.exec() == 1) { 718 if (w.exec() == 1) {
719 currItem.desc = w.getDescription().latin1(); 719 currItem.desc = w.getDescription().latin1();
720 currItem.name = w.getUsername().latin1(); 720 currItem.name = w.getUsername().latin1();
721 currItem.pw = w.getPassword().latin1(); 721 currItem.pw = w.getPassword().latin1();
722 currItem.comment = w.getComment().latin1(); 722 currItem.comment = w.getComment().latin1();
723 currItem.url = w.getUrl().latin1(); 723 currItem.url = w.getUrl().latin1();
724 currItem.launcher = w.getLauncher().latin1(); 724 currItem.launcher = w.getLauncher().latin1();
725 if (!doc->editEntry(curCategory, w.getCategory(), 725 if (!doc->editEntry(curCategory, w.getCategory(),
726 curEntryIndex, &currItem)) { 726 curEntryIndex, &currItem)) {
727 KMessageBox::error(this, 727 KMessageBox::error(this,
728 i18n("Couldn't edit the entry.\n" 728 i18n("Couldn't edit the entry.\n"
729 "Maybe you changed the category and " 729 "Maybe you changed the category and "
730 "this entry is already present in the new " 730 "this entry is already present in the new "
731 "category?"), 731 "category?"),
732 i18n("couldn't edit entry.")); 732 i18n("couldn't edit entry."));
733 doc->timer()->putLock(DocTimer::id_autoLockTimer); 733 doc->timer()->putLock(DocTimer::id_autoLockTimer);
734 return; 734 return;
735 } 735 }
736 } 736 }
737 doc->timer()->putLock(DocTimer::id_autoLockTimer); 737 doc->timer()->putLock(DocTimer::id_autoLockTimer);
738} 738}
739 739
740void PwM::deletePwd_slot() 740void PwM::deletePwd_slot()
741{ 741{
742 PWM_ASSERT(curDoc()); 742 PWM_ASSERT(curDoc());
743 if (curDoc()->isDocEmpty()) 743 if (curDoc()->isDocEmpty())
744 return; 744 return;
745 if (curDoc()->isDeepLocked()) 745 if (curDoc()->isDeepLocked())
746 return; 746 return;
747 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer); 747 curDoc()->timer()->getLock(DocTimer::id_autoLockTimer);
748 unsigned int curEntryIndex = 0; 748 unsigned int curEntryIndex = 0;
749 if (!(view->getCurEntryIndex(&curEntryIndex))) { 749 if (!(view->getCurEntryIndex(&curEntryIndex))) {
750 printDebug("couldn't get index"); 750 printDebug("couldn't get index");
751 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 751 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
752 return; 752 return;
753 } 753 }
754 754
755 PwMDataItem currItem; 755 PwMDataItem currItem;
756 QString curCategory = view->getCurrentCategory(); 756 QString curCategory = view->getCurrentCategory();
757 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) { 757 if (!curDoc()->getEntry(curCategory, curEntryIndex, &currItem)) {
758 printDebug("couldn't get entry"); 758 printDebug("couldn't get entry");
759 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer); 759 curDoc()->timer()->putLock(DocTimer::id_autoLockTimer);
760 return; 760 return;
761 } 761 }
762 if (KMessageBox:: 762 if (KMessageBox::
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index fe1f7a1..116bc66 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -41,200 +41,202 @@
41#include "pwmexception.h" 41#include "pwmexception.h"
42 42
43 43
44/** timeout for displaying a message on the status-bar (in seconds) */ 44/** timeout for displaying a message on the status-bar (in seconds) */
45 #define STATUSBAR_MSG_TIMEOUT5 45 #define STATUSBAR_MSG_TIMEOUT5
46 46
47 47
48class PwMInit; 48class PwMInit;
49class KSyncManager; 49class KSyncManager;
50 50
51/** PwM is the base class of the project */ 51/** PwM is the base class of the project */
52#ifndef PWM_EMBEDDED 52#ifndef PWM_EMBEDDED
53//MOC_SKIP_BEGIN 53//MOC_SKIP_BEGIN
54class PwM : public KMainWindow 54class PwM : public KMainWindow
55//MOC_SKIP_END 55//MOC_SKIP_END
56#else 56#else
57class PwM : public KMainWindow, public KSyncInterface 57class PwM : public KMainWindow, public KSyncInterface
58#endif 58#endif
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61public: 61public:
62 friend class PwMView; 62 friend class PwMView;
63 /** construtor */ 63 /** construtor */
64 PwM(PwMInit *_init, PwMDoc *doc, 64 PwM(PwMInit *_init, PwMDoc *doc,
65 bool virginity = true, 65 bool virginity = true,
66 QWidget* parent = 0, const char *name = 0); 66 QWidget* parent = 0, const char *name = 0);
67 /** destructor */ 67 /** destructor */
68 ~PwM(); 68 ~PwM();
69 69
70 /** copy some text to the global clipboard */ 70 /** copy some text to the global clipboard */
71 static void copyToClipboard(const QString &s); 71 static void copyToClipboard(const QString &s);
72 72
73 /** returns pointer to the view */ 73 /** returns pointer to the view */
74 PwMView * curView() 74 PwMView * curView()
75 { return view; } 75 { return view; }
76 /** returns pointer to the currently using document. */ 76 /** returns pointer to the currently using document. */
77 PwMDoc * curDoc() 77 PwMDoc * curDoc()
78 { return curView()->document(); } 78 { return curView()->document(); }
79 /** open a new doc with the given filename */ 79 /** open a new doc with the given filename */
80 PwMDoc * openDoc(QString filename, bool openDeepLocked = false); 80 PwMDoc * openDoc(QString filename, bool openDeepLocked = false);
81 /** show a message on the global status bar. 81 /** show a message on the global status bar.
82 * The message times out after some seconds. 82 * The message times out after some seconds.
83 */ 83 */
84 void showStatMsg(const QString &msg); 84 void showStatMsg(const QString &msg);
85 /** ask the user where to save the doc (if it has not been saved, yet) 85 /** ask the user where to save the doc (if it has not been saved, yet)
86 * and write the data to disk. 86 * and write the data to disk.
87 */ 87 */
88 bool save(); 88 bool save();
89 /** ask the user where to save the doc 89 /** ask the user where to save the doc
90 * and write the data to disk. 90 * and write the data to disk.
91 */ 91 */
92 bool saveAs(); 92 bool saveAs();
93 /** force quit. Quit this window, always! Don't minimize it */ 93 /** force quit. Quit this window, always! Don't minimize it */
94 bool isForceQuit() 94 bool isForceQuit()
95 { return forceQuit; } 95 { return forceQuit; }
96 /** set forceQuit */ 96 /** set forceQuit */
97 void setForceQuit(bool force) 97 void setForceQuit(bool force)
98 { forceQuit = force; } 98 { forceQuit = force; }
99 /** force minimize this window */ 99 /** force minimize this window */
100 bool isForceMinimizeToTray() 100 bool isForceMinimizeToTray()
101 { return forceMinimizeToTray; } 101 { return forceMinimizeToTray; }
102 /** set forceMinimizeToTray */ 102 /** set forceMinimizeToTray */
103 void setForceMinimizeToTray(bool force) 103 void setForceMinimizeToTray(bool force)
104 { forceMinimizeToTray = force; } 104 { forceMinimizeToTray = force; }
105 105
106public slots: 106public slots:
107 /** file/new triggered */ 107 /** file/new triggered */
108 void new_slot(); 108 void new_slot();
109 /** file/open triggered */ 109 /** file/open triggered */
110//US ENH 110//US ENH
111 void open_slot(); 111 void open_slot();
112 void open_slot(QString fn); 112 void open_slot(QString fn);
113 /** file/close triggered */ 113 /** file/close triggered */
114 void close_slot(); 114 void close_slot();
115 /** file/quit triggered */ 115 /** file/quit triggered */
116 void quitButton_slot(); 116 void quitButton_slot();
117 /** file/save triggered */ 117 /** file/save triggered */
118 void save_slot(); 118 void save_slot();
119 /** file/saveAs triggered */ 119 /** file/saveAs triggered */
120 void saveAs_slot(); 120 void saveAs_slot();
121 /** file/export/text triggered */ 121 /** file/export/text triggered */
122 void exportToText(); 122 void exportToText();
123 /** file/export/gpasman triggered */ 123 /** file/export/gpasman triggered */
124 void exportToGpasman(); 124 void exportToGpasman();
125 /** file/export/kwallet triggered */ 125 /** file/export/kwallet triggered */
126 void exportToKWallet(); 126 void exportToKWallet();
127 /** file/import/text triggered */ 127 /** file/import/text triggered */
128 bool importFromText(); 128 bool importFromText();
129 /** file/import/gpasman triggered */ 129 /** file/import/gpasman triggered */
130 bool importFromGpasman(); 130 bool importFromGpasman();
131 /** file/import/kwallet triggered */ 131 /** file/import/kwallet triggered */
132 bool importKWallet(); 132 bool importKWallet();
133 /** file/print triggered */ 133 /** file/print triggered */
134 void print_slot(); 134 void print_slot();
135 /** manage/add triggered */ 135 /** manage/add triggered */
136 //US ENH : changed code to run with older MOC 136 //US ENH : changed code to run with older MOC
137
137 void addPwd_slot(); 138 void addPwd_slot();
138 void addPwd_slot(QString *pw, PwMDoc *_doc); 139 void addPwd_slot1(QString *pw, PwMDoc *_doc);
139 /** manage/edit triggered */ 140 /** manage/edit triggered */
140 //US ENH : changed code to run with older MOC 141 //US ENH : changed code to run with older MOC
141 void editPwd_slot(); 142 void editPwd_slot();
142 void editPwd_slot(const QString *category); 143 void editPwd_slot1(const QString *category);
143 void editPwd_slot(const QString *category = 0, const int *index = 0, 144 void editPwd_slot3(const QString *category = 0, const int *index = 0,
144 PwMDoc *_doc = 0); 145 PwMDoc *_doc = 0);
146
145 /** manage/delete triggered */ 147 /** manage/delete triggered */
146 void deletePwd_slot(); 148 void deletePwd_slot();
147 /** execute the "Launcher" entry */ 149 /** execute the "Launcher" entry */
148 void execLauncher_slot(); 150 void execLauncher_slot();
149 /** open browser with URL entry */ 151 /** open browser with URL entry */
150 void goToURL_slot(); 152 void goToURL_slot();
151 /** manage/changeMasterPwd triggered */ 153 /** manage/changeMasterPwd triggered */
152 void changeMasterPwd_slot(); 154 void changeMasterPwd_slot();
153 /** lock current document */ 155 /** lock current document */
154 void lockWnd_slot(); 156 void lockWnd_slot();
155 /** deeplock current document */ 157 /** deeplock current document */
156 void deepLockWnd_slot(); 158 void deepLockWnd_slot();
157 /** window/unlock triggered */ 159 /** window/unlock triggered */
158 void unlockWnd_slot(); 160 void unlockWnd_slot();
159 /** find item */ 161 /** find item */
160 void find_slot(); 162 void find_slot();
161 /** configure clicked */ 163 /** configure clicked */
162 void config_slot(); 164 void config_slot();
163 /** (de)activate the "change master pw" button in the menu-bar */ 165 /** (de)activate the "change master pw" button in the menu-bar */
164 void activateMpButton(bool activate = true); 166 void activateMpButton(bool activate = true);
165 /** generate a new chipcard */ 167 /** generate a new chipcard */
166 void genNewCard_slot(); 168 void genNewCard_slot();
167 /** completely erase the current card */ 169 /** completely erase the current card */
168 void eraseCard_slot(); 170 void eraseCard_slot();
169 /** returns the ID number of the current card */ 171 /** returns the ID number of the current card */
170 void readCardId_slot(); 172 void readCardId_slot();
171 /** make backup image of the current card */ 173 /** make backup image of the current card */
172 void makeCardBackup_slot(); 174 void makeCardBackup_slot();
173 /** write backup image to current card */ 175 /** write backup image to current card */
174 void replayCardBackup_slot(); 176 void replayCardBackup_slot();
175 177
176#ifdef PWM_EMBEDDED 178#ifdef PWM_EMBEDDED
177 void whatsnew_slot(); 179 void whatsnew_slot();
178 void showLicense_slot(); 180 void showLicense_slot();
179 void faq_slot(); 181 void faq_slot();
180 void createAboutData_slot(); 182 void createAboutData_slot();
181 void syncHowTo_slot(); 183 void syncHowTo_slot();
182#endif 184#endif
183 185
184protected: 186protected:
185 /** is this window virgin? */ 187 /** is this window virgin? */
186 bool isVirgin() 188 bool isVirgin()
187 { return virgin; } 189 { return virgin; }
188 /** add/remove virginity */ 190 /** add/remove virginity */
189 void setVirgin(bool v); 191 void setVirgin(bool v);
190 /** initialize the menubar */ 192 /** initialize the menubar */
191 void initMenubar(); 193 void initMenubar();
192 /** initialize the toolbar */ 194 /** initialize the toolbar */
193 void initToolbar(); 195 void initToolbar();
194 /** initialize the window-metrics */ 196 /** initialize the window-metrics */
195 void initMetrics(); 197 void initMetrics();
196 /** close-event */ 198 /** close-event */
197 void closeEvent(QCloseEvent *e); 199 void closeEvent(QCloseEvent *e);
198 /** creates a new PwM-ListView and returns it */ 200 /** creates a new PwM-ListView and returns it */
199 PwMView * makeNewListView(PwMDoc *doc); 201 PwMView * makeNewListView(PwMDoc *doc);
200 /** Window hide-event */ 202 /** Window hide-event */
201 void hideEvent(QHideEvent *); 203 void hideEvent(QHideEvent *);
202 /** is this window minimized? */ 204 /** is this window minimized? */
203 bool isMinimized() 205 bool isMinimized()
204 { 206 {
205#ifndef PWM_EMBEDDED 207#ifndef PWM_EMBEDDED
206 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0) 208 #if KDE_VERSION >= KDE_MAKE_VERSION(3, 2, 0)
207 return KWin::windowInfo(winId()).isMinimized(); 209 return KWin::windowInfo(winId()).isMinimized();
208 #else // KDE_VERSION 210 #else // KDE_VERSION
209 return KWin::info(winId()).isIconified(); 211 return KWin::info(winId()).isIconified();
210 #endif // KDE_VERSION 212 #endif // KDE_VERSION
211#else 213#else
212 return false; 214 return false;
213#endif 215#endif
214 } 216 }
215 /** window got the focus */ 217 /** window got the focus */
216 void focusInEvent(QFocusEvent *e); 218 void focusInEvent(QFocusEvent *e);
217 /** update the caption string */ 219 /** update the caption string */
218 void updateCaption(); 220 void updateCaption();
219#ifdef CONFIG_KWALLETIF 221#ifdef CONFIG_KWALLETIF
220 /** check if kwalletemu is enabled and ask the user what to do */ 222 /** check if kwalletemu is enabled and ask the user what to do */
221 bool checkAndAskForKWalletEmu(); 223 bool checkAndAskForKWalletEmu();
222#endif // CONFIG_KWALLETIF 224#endif // CONFIG_KWALLETIF
223 225
224protected slots: 226protected slots:
225 /** doc got closed */ 227 /** doc got closed */
226 void docClosed(PwMDoc *doc); 228 void docClosed(PwMDoc *doc);
227 229
228signals: 230signals:
229 /** window got closed (by user or someone else) */ 231 /** window got closed (by user or someone else) */
230 void closed(PwM *wnd); 232 void closed(PwM *wnd);
231 /** window got the focus (was brought to foreground) */ 233 /** window got the focus (was brought to foreground) */
232 void gotFocus(PwM *wnd); 234 void gotFocus(PwM *wnd);
233 /** window lost the focus */ 235 /** window lost the focus */
234 void lostFocus(PwM *wnd); 236 void lostFocus(PwM *wnd);
235 237
236protected: 238protected:
237 /** pointer to the view active in this KMainWindow */ 239 /** pointer to the view active in this KMainWindow */
238 PwMView *view; 240 PwMView *view;
239 /** pointer to the init class */ 241 /** pointer to the init class */
240 PwMInit *init; 242 PwMInit *init;
diff --git a/pwmanager/pwmanager/pwmanager.pro b/pwmanager/pwmanager/pwmanager.pro
index 34f7403..7f39c76 100644
--- a/pwmanager/pwmanager/pwmanager.pro
+++ b/pwmanager/pwmanager/pwmanager.pro
@@ -1,126 +1,131 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 3DESTDIR= ../../bin
4
5 TARGET = pwmpi 4 TARGET = pwmpi
6OBJECTS_DIR = obj/$(PLATFORM) 5include( ../../variables.pri )
7MOC_DIR = moc/$(PLATFORM)
8DESTDIR=$(QPEDIR)/bin
9 6
10INCLUDEPATH += . ../../ ../../qtcompat ../../qtcompat/xml ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils $(QPEDIR)/include 7INCLUDEPATH += . ../../ ../../libkdepim ../../microkde ../../microkde/kdecore ../../microkde/kdeui ../../microkde/kutils
11DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION 8DEFINES += PWM_EMBEDDED CONFIG_PWMANAGER_GCRY DESKTOP_VERSION
12 9
13#enable this setting if you want debugoutput for pwmanager 10#enable this setting if you want debugoutput for pwmanager
14#DEFINES += CONFIG_DEBUG 11#DEFINES += CONFIG_DEBUG
15LIBS += -L../libcrypt/$(PLATFORM) 12LIBS += -L../libcrypt/
13LIBS += -L../../bin/
16LIBS += -lmicrokde 14LIBS += -lmicrokde
17LIBS += -lmicroqtcompat
18LIBS += -lmicrokdepim 15LIBS += -lmicrokdepim
19LIBS += -L$(QPEDIR)/lib
20LIBS += -lqpe
21LIBS += -lzlib 16LIBS += -lzlib
22#LIBS += -lbz2
23#LIBS += -lkpmicrogcrypt
24LIBS += -ljpeg
25LIBS += $(QTOPIALIB)
26LIBS += -lkpmicrocipher 17LIBS += -lkpmicrocipher
27LIBS += -lkpmicroerror 18LIBS += -lkpmicroerror
28LIBS += -lkpmicrompi 19LIBS += -lkpmicrompi
29LIBS += -lstdc++ 20LIBS += -lstdc++
30 21
22unix:{
23OBJECTS_DIR = obj/unix
24MOC_DIR = moc/unix
25
26}
27win32:{
28
29DEFINES += _WIN32_
30OBJECTS_DIR = obj/win
31MOC_DIR = moc/win
32QMAKE_LINK += /NODEFAULTLIB:LIBC
33
34}
35
31#INTERFACES = \ 36#INTERFACES = \
32#addentrywnd.ui \ 37#addentrywnd.ui \
33#configwnd.ui \ 38#configwnd.ui \
34#findwnd.ui \ 39#findwnd.ui \
35#getmasterpwwnd.ui \ 40#getmasterpwwnd.ui \
36#pwgenwnd.ui \ 41#pwgenwnd.ui \
37#setmasterpwwnd.ui \ 42#setmasterpwwnd.ui \
38#subtbledit.ui 43#subtbledit.ui
39 44
40#INTERFACES = \ 45#INTERFACES = \
41#subtbledit.ui \ 46#subtbledit.ui \
42 47
43 48
44 49
45#HEADERS = \ 50#HEADERS = \
46#configuration_31compat.h \ 51#configuration_31compat.h \
47#configuration.h \ 52#configuration.h \
48#configwnd.h \ 53#configwnd.h \
49#configwndimpl.h \ 54#configwndimpl.h \
50#selftest.h 55#selftest.h
51#subtbledit.h \ 56#subtbledit.h \
52#subtbleditimpl.h \ 57#subtbleditimpl.h \
53#compressbzip2.h \ 58#compressbzip2.h \
54 59
55HEADERS = \ 60HEADERS = \
56addentrywnd_emb.h \ 61addentrywnd_emb.h \
57addentrywndimpl.h \ 62addentrywndimpl.h \
58base64.h \ 63base64.h \
59binentrygen.h \ 64binentrygen.h \
60blowfish.h \ 65blowfish.h \
61commentbox.h \ 66commentbox.h \
62compiler.h \ 67compiler.h \
63compressgzip.h \ 68compressgzip.h \
64findwnd_emb.h \ 69findwnd_emb.h \
65findwndimpl.h \ 70findwndimpl.h \
66genpasswd.h \ 71genpasswd.h \
67getkeycardwnd.h \ 72getkeycardwnd.h \
68getmasterpwwnd_emb.h \ 73getmasterpwwnd_emb.h \
69getmasterpwwndimpl.h \ 74getmasterpwwndimpl.h \
70globalstuff.h \ 75globalstuff.h \
71gpasmanfile.h \ 76gpasmanfile.h \
72htmlgen.h \ 77htmlgen.h \
73htmlparse.h \ 78htmlparse.h \
74ipc.h \ 79ipc.h \
75libgcryptif.h \ 80libgcryptif.h \
76listobjselectwnd.h \ 81listobjselectwnd.h \
77listviewpwm.h \ 82listviewpwm.h \
78printtext.h \ 83printtext.h \
79pwgenwnd_emb.h \ 84pwgenwnd_emb.h \
80pwgenwndimpl.h \ 85pwgenwndimpl.h \
81pwmdoc.h \ 86pwmdoc.h \
82pwmdocui.h \ 87pwmdocui.h \
83pwmexception.h \ 88pwmexception.h \
84pwm.h \ 89pwm.h \
85pwminit.h \ 90pwminit.h \
86pwmprefs.h \ 91pwmprefs.h \
87pwmprint.h \ 92pwmprint.h \
88pwmtray.h \ 93pwmtray.h \
89pwmview.h \ 94pwmview.h \
90pwmviewstyle_0.h \ 95pwmviewstyle_0.h \
91pwmviewstyle_1.h \ 96pwmviewstyle_1.h \
92pwmviewstyle.h \ 97pwmviewstyle.h \
93randomizer.h \ 98randomizer.h \
94rc2.h \ 99rc2.h \
95rencatwnd.h \ 100rencatwnd.h \
96serializer.h \ 101serializer.h \
97setmasterpwwnd_emb.h \ 102setmasterpwwnd_emb.h \
98setmasterpwwndimpl.h \ 103setmasterpwwndimpl.h \
99sha1.h \ 104sha1.h \
100waitwnd.h \ 105waitwnd.h \
101kcmconfigs/kcmpwmconfig.h \ 106kcmconfigs/kcmpwmconfig.h \
102kcmconfigs/pwmconfigwidget.h 107kcmconfigs/pwmconfigwidget.h
103 108
104#sources that need not be build 109#sources that need not be build
105#SOURCES = \ 110#SOURCES = \
106#advcommeditimpl.cpp \ 111#advcommeditimpl.cpp \
107#configuration.cpp \ 112#configuration.cpp \
108#configwnd.cpp \ 113#configwnd.cpp \
109#configwndimpl.cpp \ 114#configwndimpl.cpp \
110#configuration_31compat.cpp \ 115#configuration_31compat.cpp \
111#htmlparse.cpp \ 116#htmlparse.cpp \
112#printtext.cpp \ 117#printtext.cpp \
113#selftest.cpp \ 118#selftest.cpp \
114#pwmprint.cpp \ 119#pwmprint.cpp \
115#spinforsignal.cpp 120#spinforsignal.cpp
116#subtbledit.cpp \ 121#subtbledit.cpp \
117#subtbleditimpl.cpp \ 122#subtbleditimpl.cpp \
118#compressbzip2.cpp 123#compressbzip2.cpp
119 124
120 125
121SOURCES = \ 126SOURCES = \
122addentrywnd_emb.cpp \ 127addentrywnd_emb.cpp \
123addentrywndimpl.cpp \ 128addentrywndimpl.cpp \
124base64.cpp \ 129base64.cpp \
125binentrygen.cpp \ 130binentrygen.cpp \
126blowfish.cpp \ 131blowfish.cpp \
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index e29e3d1..8869f3a 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -2236,194 +2236,194 @@ bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex)
2236#else 2236#else
2237 command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); 2237 command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str());
2238 command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); 2238 command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str());
2239 command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); 2239 command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str());
2240 command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); 2240 command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str());
2241 command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); 2241 command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str());
2242#endif 2242#endif
2243 command.append(" &"); 2243 command.append(" &");
2244 2244
2245 QString customXterm(conf()->confGlobXtermCommand()); 2245 QString customXterm(conf()->confGlobXtermCommand());
2246 if (!customXterm.isEmpty()) 2246 if (!customXterm.isEmpty())
2247 command = customXterm + " " + command; 2247 command = customXterm + " " + command;
2248 2248
2249 system(command.latin1()); 2249 system(command.latin1());
2250 2250
2251 lockAt(category, entryIndex, wasLocked); 2251 lockAt(category, entryIndex, wasLocked);
2252 return true; 2252 return true;
2253} 2253}
2254 2254
2255bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) 2255bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex)
2256{ 2256{
2257 unsigned int cat = 0; 2257 unsigned int cat = 0;
2258 2258
2259 if (!findCategory(category, &cat)) 2259 if (!findCategory(category, &cat))
2260 return false; 2260 return false;
2261 2261
2262 return goToURL(cat, entryIndex); 2262 return goToURL(cat, entryIndex);
2263} 2263}
2264 2264
2265bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) 2265bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex)
2266{ 2266{
2267 if (geteuid() == 0) { 2267 if (geteuid() == 0) {
2268 rootAlertMsgBox(); 2268 rootAlertMsgBox();
2269 return false; 2269 return false;
2270 } 2270 }
2271 QString url(dti.dta[category].d[entryIndex].url.c_str()); 2271 QString url(dti.dta[category].d[entryIndex].url.c_str());
2272 if (url.isEmpty()) 2272 if (url.isEmpty())
2273 return false; 2273 return false;
2274 2274
2275 QString customBrowser(conf()->confGlobBrowserCommand()); 2275 QString customBrowser(conf()->confGlobBrowserCommand());
2276 if (!customBrowser.isEmpty()) { 2276 if (!customBrowser.isEmpty()) {
2277 browserProc.clearArguments(); 2277 browserProc.clearArguments();
2278 browserProc << customBrowser << url; 2278 browserProc << customBrowser << url;
2279 if (browserProc.start(KProcess::DontCare)) 2279 if (browserProc.start(KProcess::DontCare))
2280 return true; 2280 return true;
2281 } 2281 }
2282 2282
2283 browserProc.clearArguments(); 2283 browserProc.clearArguments();
2284 browserProc << "konqueror" << url; 2284 browserProc << "konqueror" << url;
2285 if (browserProc.start(KProcess::DontCare)) 2285 if (browserProc.start(KProcess::DontCare))
2286 return true; 2286 return true;
2287 2287
2288 browserProc.clearArguments(); 2288 browserProc.clearArguments();
2289 browserProc << "mozilla" << url; 2289 browserProc << "mozilla" << url;
2290 if (browserProc.start(KProcess::DontCare)) 2290 if (browserProc.start(KProcess::DontCare))
2291 return true; 2291 return true;
2292 2292
2293 browserProc.clearArguments(); 2293 browserProc.clearArguments();
2294 browserProc << "opera" << url; 2294 browserProc << "opera" << url;
2295 if (browserProc.start(KProcess::DontCare)) 2295 if (browserProc.start(KProcess::DontCare))
2296 return true; 2296 return true;
2297 return false; 2297 return false;
2298} 2298}
2299 2299
2300PwMerror PwMDoc::exportToText(const QString *file) 2300PwMerror PwMDoc::exportToText(const QString *file)
2301{ 2301{
2302 PWM_ASSERT(file); 2302 PWM_ASSERT(file);
2303 if (QFile::exists(*file)) { 2303 if (QFile::exists(*file)) {
2304 if (!QFile::remove(*file)) 2304 if (!QFile::remove(*file))
2305 return e_accessFile; 2305 return e_accessFile;
2306 } 2306 }
2307 QFile f(*file); 2307 QFile f(*file);
2308 if (!f.open(IO_ReadWrite)) 2308 if (!f.open(IO_ReadWrite))
2309 return e_openFile; 2309 return e_openFile;
2310 2310
2311 if (!unlockAll_tempoary()) { 2311 if (!unlockAll_tempoary()) {
2312 f.close(); 2312 f.close();
2313 return e_lock; 2313 return e_lock;
2314 } 2314 }
2315 2315
2316 // write header 2316 // write header
2317 string header = i18n("Password table generated by\nPwM v").latin1(); 2317 string header = i18n("Password table generated by\nPwM v").latin1();
2318 header += PACKAGE_VER; 2318 header += PACKAGE_VER;
2319 header += i18n("\non ").latin1(); 2319 header += i18n("\non ").latin1();
2320 QDate currDate = QDate::currentDate(); 2320 QDate currDate = QDate::currentDate();
2321 QTime currTime = QTime::currentTime(); 2321 QTime currTime = QTime::currentTime();
2322 2322
2323#ifndef PWM_EMBEDDED 2323#ifndef PWM_EMBEDDED
2324 header += currDate.toString("ddd MMMM d ").latin1(); 2324 header += currDate.toString("ddd MMMM d ").latin1();
2325 header += currTime.toString("hh:mm:ss ").latin1(); 2325 header += currTime.toString("hh:mm:ss ").latin1();
2326#else 2326#else
2327 QString dfs = KGlobal::locale()->dateFormatShort(); 2327 QString dfs = KGlobal::locale()->dateFormatShort();
2328 bool ampm = KGlobal::locale()->use12Clock(); 2328 bool ampm = KGlobal::locale()->use12Clock();
2329 KGlobal::locale()->setDateFormatShort("%A %B %d"); 2329 KGlobal::locale()->setDateFormatShort("%A %B %d");
2330 KGlobal::locale()->setHore24Format(true); 2330 KGlobal::locale()->setHore24Format(true);
2331 2331
2332 header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined); 2332 header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1();
2333 header += KGlobal::locale()->formatTime(currTime, true); 2333 header += KGlobal::locale()->formatTime(currTime, true).latin1();
2334 KGlobal::locale()->setDateFormatShort(dfs); 2334 KGlobal::locale()->setDateFormatShort(dfs);
2335 KGlobal::locale()->setHore24Format(!ampm); 2335 KGlobal::locale()->setHore24Format(!ampm);
2336 2336
2337#endif 2337#endif
2338 header += tostr(currDate.year()); 2338 header += tostr(currDate.year());
2339 header += "\n==============================\n\n"; 2339 header += "\n==============================\n\n";
2340 2340
2341 2341
2342#ifndef PWM_EMBEDDED 2342#ifndef PWM_EMBEDDED
2343 if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { 2343 if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) {
2344 unlockAll_tempoary(true); 2344 unlockAll_tempoary(true);
2345 f.close(); 2345 f.close();
2346 return e_writeFile; 2346 return e_writeFile;
2347 } 2347 }
2348#else 2348#else
2349 if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { 2349 if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) {
2350 unlockAll_tempoary(true); 2350 unlockAll_tempoary(true);
2351 f.close(); 2351 f.close();
2352 return e_writeFile; 2352 return e_writeFile;
2353 } 2353 }
2354#endif 2354#endif
2355 unsigned int i, numCat = numCategories(); 2355 unsigned int i, numCat = numCategories();
2356 unsigned int j, numEnt; 2356 unsigned int j, numEnt;
2357 string exp; 2357 string exp;
2358 for (i = 0; i < numCat; ++i) { 2358 for (i = 0; i < numCat; ++i) {
2359 numEnt = numEntries(i); 2359 numEnt = numEntries(i);
2360 2360
2361 exp = "\n== Category: "; 2361 exp = "\n== Category: ";
2362 exp += dti.dta[i].name; 2362 exp += dti.dta[i].name;
2363 exp += " ==\n"; 2363 exp += " ==\n";
2364#ifndef PWM_EMBEDDED 2364#ifndef PWM_EMBEDDED
2365 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { 2365 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) {
2366 unlockAll_tempoary(true); 2366 unlockAll_tempoary(true);
2367 f.close(); 2367 f.close();
2368 return e_writeFile; 2368 return e_writeFile;
2369 } 2369 }
2370#else 2370#else
2371 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { 2371 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) {
2372 unlockAll_tempoary(true); 2372 unlockAll_tempoary(true);
2373 f.close(); 2373 f.close();
2374 return e_writeFile; 2374 return e_writeFile;
2375 } 2375 }
2376#endif 2376#endif
2377 for (j = 0; j < numEnt; ++j) { 2377 for (j = 0; j < numEnt; ++j) {
2378 exp = "\n-- "; 2378 exp = "\n-- ";
2379 exp += dti.dta[i].d[j].desc; 2379 exp += dti.dta[i].d[j].desc;
2380 exp += " --\n"; 2380 exp += " --\n";
2381 2381
2382 exp += i18n("Username: ").latin1(); 2382 exp += i18n("Username: ").latin1();
2383 exp += dti.dta[i].d[j].name; 2383 exp += dti.dta[i].d[j].name;
2384 exp += "\n"; 2384 exp += "\n";
2385 2385
2386 exp += i18n("Password: ").latin1(); 2386 exp += i18n("Password: ").latin1();
2387 exp += dti.dta[i].d[j].pw; 2387 exp += dti.dta[i].d[j].pw;
2388 exp += "\n"; 2388 exp += "\n";
2389 2389
2390 exp += i18n("Comment: ").latin1(); 2390 exp += i18n("Comment: ").latin1();
2391 exp += dti.dta[i].d[j].comment; 2391 exp += dti.dta[i].d[j].comment;
2392 exp += "\n"; 2392 exp += "\n";
2393 2393
2394 exp += i18n("URL: ").latin1(); 2394 exp += i18n("URL: ").latin1();
2395 exp += dti.dta[i].d[j].url; 2395 exp += dti.dta[i].d[j].url;
2396 exp += "\n"; 2396 exp += "\n";
2397 2397
2398 exp += i18n("Launcher: ").latin1(); 2398 exp += i18n("Launcher: ").latin1();
2399 exp += dti.dta[i].d[j].launcher; 2399 exp += dti.dta[i].d[j].launcher;
2400 exp += "\n"; 2400 exp += "\n";
2401 2401
2402#ifndef PWM_EMBEDDED 2402#ifndef PWM_EMBEDDED
2403 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { 2403 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) {
2404 unlockAll_tempoary(true); 2404 unlockAll_tempoary(true);
2405 f.close(); 2405 f.close();
2406 return e_writeFile; 2406 return e_writeFile;
2407 } 2407 }
2408#else 2408#else
2409 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { 2409 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) {
2410 unlockAll_tempoary(true); 2410 unlockAll_tempoary(true);
2411 f.close(); 2411 f.close();
2412 return e_writeFile; 2412 return e_writeFile;
2413 } 2413 }
2414#endif 2414#endif
2415 } 2415 }
2416 } 2416 }
2417 unlockAll_tempoary(true); 2417 unlockAll_tempoary(true);
2418 f.close(); 2418 f.close();
2419 2419
2420 return e_success; 2420 return e_success;
2421} 2421}
2422 2422
2423PwMerror PwMDoc::importFromText(const QString *file, int format) 2423PwMerror PwMDoc::importFromText(const QString *file, int format)
2424{ 2424{
2425 PWM_ASSERT(file); 2425 PWM_ASSERT(file);
2426 if (format == 0) 2426 if (format == 0)
2427 return importText_PwM(file); 2427 return importText_PwM(file);
2428 else if (format == -1) { 2428 else if (format == -1) {
2429 // probe for all formats 2429 // probe for all formats
@@ -2925,213 +2925,213 @@ void PwMDoc::ensureLvp()
2925 2925
2926 while (entrI != entrEnd) { 2926 while (entrI != entrEnd) {
2927 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); 2927 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos);
2928 ++entrI; 2928 ++entrI;
2929 } 2929 }
2930 */ 2930 */
2931 2931
2932 ++catI; 2932 ++catI;
2933 } 2933 }
2934} 2934}
2935 2935
2936QString PwMDoc::getTitle() 2936QString PwMDoc::getTitle()
2937{ 2937{
2938 /* NOTE: We have to ensure, that the returned title 2938 /* NOTE: We have to ensure, that the returned title
2939 * is unique and not reused somewhere else while 2939 * is unique and not reused somewhere else while
2940 * this document is valid (open). 2940 * this document is valid (open).
2941 */ 2941 */
2942 QString title(getFilename()); 2942 QString title(getFilename());
2943 2943
2944 //US ENH: The whole filename on PDAs is too long. So use only the last characters 2944 //US ENH: The whole filename on PDAs is too long. So use only the last characters
2945 if (QApplication::desktop()->width() < 640) 2945 if (QApplication::desktop()->width() < 640)
2946 { 2946 {
2947 if (title.length() > 30) 2947 if (title.length() > 30)
2948 title = "..." + title.right(30); 2948 title = "..." + title.right(30);
2949 2949
2950 } 2950 }
2951 2951
2952 2952
2953 if (title.isEmpty()) { 2953 if (title.isEmpty()) {
2954 if (unnamedNum == 0) { 2954 if (unnamedNum == 0) {
2955 unnamedNum = PwMDocList::getNewUnnamedNumber(); 2955 unnamedNum = PwMDocList::getNewUnnamedNumber();
2956 PWM_ASSERT(unnamedNum != 0); 2956 PWM_ASSERT(unnamedNum != 0);
2957 } 2957 }
2958 title = DEFAULT_TITLE; 2958 title = DEFAULT_TITLE;
2959 title += " "; 2959 title += " ";
2960 title += tostr(unnamedNum).c_str(); 2960 title += tostr(unnamedNum).c_str();
2961 } 2961 }
2962 return title; 2962 return title;
2963} 2963}
2964 2964
2965bool PwMDoc::tryDelete() 2965bool PwMDoc::tryDelete()
2966{ 2966{
2967 if (deleted) 2967 if (deleted)
2968 return true; 2968 return true;
2969 int ret; 2969 int ret;
2970 if (isDirty()) { 2970 if (isDirty()) {
2971 ret = dirtyAskSave(getTitle()); 2971 ret = dirtyAskSave(getTitle());
2972 if (ret == 0) { // save to disk 2972 if (ret == 0) { // save to disk
2973 if (!saveDocUi(this)) 2973 if (!saveDocUi(this))
2974 goto out_ignore; 2974 goto out_ignore;
2975 } else if (ret == 1) { // don't save and delete 2975 } else if (ret == 1) { // don't save and delete
2976 goto out_accept; 2976 goto out_accept;
2977 } else { // cancel operation 2977 } else { // cancel operation
2978 goto out_ignore; 2978 goto out_ignore;
2979 } 2979 }
2980 } 2980 }
2981out_accept: 2981out_accept:
2982 deleted = true; 2982 deleted = true;
2983 delete this; 2983 delete this;
2984 return true; 2984 return true;
2985out_ignore: 2985out_ignore:
2986 return false; 2986 return false;
2987} 2987}
2988 2988
2989 2989
2990 2990
2991#ifdef PWM_EMBEDDED 2991#ifdef PWM_EMBEDDED
2992//US ENH: this is the magic function that syncronizes the this doc with the remote doc 2992//US ENH: this is the magic function that syncronizes the this doc with the remote doc
2993//US it could have been defined as static, but I did not want to. 2993//US it could have been defined as static, but I did not want to.
2994PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) 2994PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode )
2995{ 2995{
2996 int addedPasswordsLocal = 0; 2996 int addedPasswordsLocal = 0;
2997 int addedPasswordsRemote = 0; 2997 int addedPasswordsRemote = 0;
2998 int deletedPasswordsRemote = 0; 2998 int deletedPasswordsRemote = 0;
2999 int deletedPasswordsLocal = 0; 2999 int deletedPasswordsLocal = 0;
3000 int changedLocal = 0; 3000 int changedLocal = 0;
3001 int changedRemote = 0; 3001 int changedRemote = 0;
3002 3002
3003 PwMSyncItem* syncItemLocal; 3003 PwMSyncItem* syncItemLocal;
3004 PwMSyncItem* syncItemRemote; 3004 PwMSyncItem* syncItemRemote;
3005 3005
3006 QString mCurrentSyncName = manager->getCurrentSyncName(); 3006 QString mCurrentSyncName = manager->getCurrentSyncName();
3007 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3007 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3008 3008
3009 bool fullDateRange = false; 3009 bool fullDateRange = false;
3010 int take; 3010 int take;
3011 // local->resetTempSyncStat(); 3011 // local->resetTempSyncStat();
3012 QDateTime mLastSync = QDateTime::currentDateTime(); 3012 QDateTime mLastSync = QDateTime::currentDateTime();
3013 QDateTime modifiedSync = mLastSync; 3013 QDateTime modifiedSync = mLastSync;
3014 3014
3015 unsigned int index; 3015 unsigned int index;
3016 //Step 1. Find syncinfo in Local file and create if not existent. 3016 //Step 1. Find syncinfo in Local file and create if not existent.
3017 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 3017 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
3018 if (found == false) 3018 if (found == false)
3019 { 3019 {
3020 PwMSyncItem newSyncItemLocal; 3020 PwMSyncItem newSyncItemLocal;
3021 newSyncItemLocal.syncName = mCurrentSyncDevice; 3021 newSyncItemLocal.syncName = mCurrentSyncDevice.latin1();
3022 newSyncItemLocal.lastSyncDate = mLastSync; 3022 newSyncItemLocal.lastSyncDate = mLastSync;
3023 syncLocal->addSyncDataEntry(&newSyncItemLocal, true); 3023 syncLocal->addSyncDataEntry(&newSyncItemLocal, true);
3024 found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 3024 found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
3025 if (found == false) { 3025 if (found == false) {
3026 qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); 3026 qDebug("PwMDoc::syncronize : newly created local sync data could not be found");
3027 return e_syncError; 3027 return e_syncError;
3028 } 3028 }
3029 } 3029 }
3030 3030
3031 syncItemLocal = syncLocal->getSyncDataEntry(index); 3031 syncItemLocal = syncLocal->getSyncDataEntry(index);
3032 qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); 3032 qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1());
3033 3033
3034 //Step 2. Find syncinfo in remote file and create if not existent. 3034 //Step 2. Find syncinfo in remote file and create if not existent.
3035 found = syncRemote->findSyncData(mCurrentSyncName, &index); 3035 found = syncRemote->findSyncData(mCurrentSyncName, &index);
3036 if (found == false) 3036 if (found == false)
3037 { 3037 {
3038 qDebug("FULLDATE 1"); 3038 qDebug("FULLDATE 1");
3039 fullDateRange = true; 3039 fullDateRange = true;
3040 PwMSyncItem newSyncItemRemote; 3040 PwMSyncItem newSyncItemRemote;
3041 newSyncItemRemote.syncName = mCurrentSyncName; 3041 newSyncItemRemote.syncName = mCurrentSyncName.latin1();
3042 newSyncItemRemote.lastSyncDate = mLastSync; 3042 newSyncItemRemote.lastSyncDate = mLastSync;
3043 syncRemote->addSyncDataEntry(&newSyncItemRemote, true); 3043 syncRemote->addSyncDataEntry(&newSyncItemRemote, true);
3044 found = syncRemote->findSyncData(mCurrentSyncName, &index); 3044 found = syncRemote->findSyncData(mCurrentSyncName, &index);
3045 if (found == false) { 3045 if (found == false) {
3046 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); 3046 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found");
3047 return e_syncError; 3047 return e_syncError;
3048 } 3048 }
3049 } 3049 }
3050 3050
3051 syncItemRemote = syncRemote->getSyncDataEntry(index); 3051 syncItemRemote = syncRemote->getSyncDataEntry(index);
3052 qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); 3052 qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1());
3053 //and remove the found entry here. We will reenter it later again. 3053 //and remove the found entry here. We will reenter it later again.
3054 //US syncRemote->delSyncDataEntry(index, true); 3054 //US syncRemote->delSyncDataEntry(index, true);
3055 3055
3056 3056
3057 if ( syncItemLocal->lastSyncDate == mLastSync ) { 3057 if ( syncItemLocal->lastSyncDate == mLastSync ) {
3058 qDebug("FULLDATE 2"); 3058 qDebug("FULLDATE 2");
3059 fullDateRange = true; 3059 fullDateRange = true;
3060 } 3060 }
3061 3061
3062 if ( ! fullDateRange ) { 3062 if ( ! fullDateRange ) {
3063 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { 3063 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) {
3064 3064
3065 fullDateRange = true; 3065 fullDateRange = true;
3066 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); 3066 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() );
3067 } 3067 }
3068 } 3068 }
3069 // fullDateRange = true; // debug only! 3069 // fullDateRange = true; // debug only!
3070 if ( fullDateRange ) 3070 if ( fullDateRange )
3071 mLastSync = QDateTime::currentDateTime().addDays( -100*365); 3071 mLastSync = QDateTime::currentDateTime().addDays( -100*365);
3072 else 3072 else
3073 mLastSync = syncItemLocal->lastSyncDate; 3073 mLastSync = syncItemLocal->lastSyncDate;
3074 3074
3075 3075
3076 qDebug("*************************** "); 3076 qDebug("*************************** ");
3077 qDebug("mLastSync %s ",mLastSync.toString().latin1() ); 3077 qDebug("mLastSync %s ",mLastSync.toString().latin1() );
3078 QStringList er = syncRemote->getIDEntryList(); 3078 QStringList er = syncRemote->getIDEntryList();
3079 PwMDataItem* inRemote ;//= er.first(); 3079 PwMDataItem* inRemote ;//= er.first();
3080 PwMDataItem* inLocal; 3080 PwMDataItem* inLocal;
3081 unsigned int catLocal, indexLocal; 3081 unsigned int catLocal, indexLocal;
3082 unsigned int catRemote, indexRemote; 3082 unsigned int catRemote, indexRemote;
3083 3083
3084 QString uid; 3084 QString uid;
3085 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3085 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3086 3086
3087 int modulo = (er.count()/10)+1; 3087 int modulo = (er.count()/10)+1;
3088 unsigned int incCounter = 0; 3088 unsigned int incCounter = 0;
3089 while ( incCounter < er.count()) { 3089 while ( incCounter < er.count()) {
3090 if (manager->isProgressBarCanceled()) 3090 if (manager->isProgressBarCanceled())
3091 return e_syncError; 3091 return e_syncError;
3092 if ( incCounter % modulo == 0 ) 3092 if ( incCounter % modulo == 0 )
3093 manager->showProgressBar(incCounter); 3093 manager->showProgressBar(incCounter);
3094 3094
3095 uid = er[ incCounter ]; 3095 uid = er[ incCounter ];
3096 qDebug("sync uid %s from remote file", uid.latin1()); 3096 qDebug("sync uid %s from remote file", uid.latin1());
3097 3097
3098 qApp->processEvents(); 3098 qApp->processEvents();
3099 3099
3100 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 3100 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
3101 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 3101 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
3102 PWM_ASSERT(inRemote); 3102 PWM_ASSERT(inRemote);
3103 if ( inLocal != 0 ) { // maybe conflict - same uid in both files 3103 if ( inLocal != 0 ) { // maybe conflict - same uid in both files
3104 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { 3104 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) {
3105 qDebug("take %d %s ", take, inLocal->desc.c_str()); 3105 qDebug("take %d %s ", take, inLocal->desc.c_str());
3106 if ( take == 3 ) 3106 if ( take == 3 )
3107 return e_syncError; 3107 return e_syncError;
3108 if ( take == 1 ) {// take local 3108 if ( take == 1 ) {// take local
3109 int oldlistpos = inRemote->listViewPos; 3109 int oldlistpos = inRemote->listViewPos;
3110 (*inRemote) = (*inLocal); 3110 (*inRemote) = (*inLocal);
3111 inRemote->listViewPos = oldlistpos; 3111 inRemote->listViewPos = oldlistpos;
3112 ++changedRemote; 3112 ++changedRemote;
3113 } else { // take == 2 take remote 3113 } else { // take == 2 take remote
3114 int oldlistpos = inLocal->listViewPos; 3114 int oldlistpos = inLocal->listViewPos;
3115 (*inLocal) = (*inRemote); 3115 (*inLocal) = (*inRemote);
3116 inLocal->listViewPos = oldlistpos; 3116 inLocal->listViewPos = oldlistpos;
3117 ++changedLocal; 3117 ++changedLocal;
3118 } 3118 }
3119 } 3119 }
3120 } else { // no conflict 3120 } else { // no conflict
3121 if ( inRemote->meta.update > mLastSync || mode == 5 ) { 3121 if ( inRemote->meta.update > mLastSync || mode == 5 ) {
3122 inRemote->meta.update = modifiedSync; 3122 inRemote->meta.update = modifiedSync;
3123 3123
3124 //first check if we have a matching category in the local file 3124 //first check if we have a matching category in the local file
3125 const string* remotecat = syncRemote->getCategory(catRemote); 3125 const string* remotecat = syncRemote->getCategory(catRemote);
3126 //US syncRemote->insertAddressee( inRemote, false ); 3126 //US syncRemote->insertAddressee( inRemote, false );
3127 //US syncLocal->insertAddressee( inRemote, false ); 3127 //US syncLocal->insertAddressee( inRemote, false );
3128 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); 3128 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false);
3129 3129
3130 ++addedPasswordsLocal; 3130 ++addedPasswordsLocal;
3131 } else { 3131 } else {
3132 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3132 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3133 syncRemote->delEntry(catRemote, indexRemote, true); 3133 syncRemote->delEntry(catRemote, indexRemote, true);
3134 //USsyncRemote->removeAddressee( inRemote ); 3134 //USsyncRemote->removeAddressee( inRemote );
3135 ++deletedPasswordsRemote; 3135 ++deletedPasswordsRemote;
3136 } 3136 }
3137 } 3137 }
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp
index 8946443..ea9e330 100644
--- a/pwmanager/pwmanager/pwminit.cpp
+++ b/pwmanager/pwmanager/pwminit.cpp
@@ -1,415 +1,423 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 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 "pwminit.h" 20#include "pwminit.h"
21#include "randomizer.h" 21#include "randomizer.h"
22#include <qdir.h>
22 23
23#ifndef PWM_EMBEDDED 24#ifndef PWM_EMBEDDED
24#include "selftest.h" 25#include "selftest.h"
25#include "configuration.h" 26#include "configuration.h"
26#else 27#else
27#include "pwmprefs.h" 28#include "pwmprefs.h"
28#endif 29#endif
29 30
30#include "pwm.h" 31#include "pwm.h"
31#include "pwmexception.h" 32#include "pwmexception.h"
32#include "pwmtray.h" 33#include "pwmtray.h"
33#include "pwmdoc.h" 34#include "pwmdoc.h"
34 35
35#ifdef CONFIG_KWALLETIF 36#ifdef CONFIG_KWALLETIF
36# include "kwalletemu.h" 37# include "kwalletemu.h"
37#endif // CONFIG_KWALLETIF 38#endif // CONFIG_KWALLETIF
38#ifdef CONFIG_KEYCARD 39#ifdef CONFIG_KEYCARD
39# include "pwmkeycard.h" 40# include "pwmkeycard.h"
40#endif // CONFIG_KEYCARD 41#endif // CONFIG_KEYCARD
41 42
42#include <qmessagebox.h> 43#include <qmessagebox.h>
43 44
44#include <kmessagebox.h> 45#include <kmessagebox.h>
45#ifndef PWM_EMBEDDED 46#ifndef PWM_EMBEDDED
46#include <kcmdlineargs.h> 47#include <kcmdlineargs.h>
47#include <kwin.h> 48#include <kwin.h>
48#include <dcopclient.h> 49#include <dcopclient.h>
49#endif 50#endif
50 51
51#include <kapplication.h> 52#include <kapplication.h>
52#include <kiconloader.h> 53#include <kiconloader.h>
53 54
54#include <signal.h> 55#include <signal.h>
55 56
56static PwMInit *sig_init_pointer; 57static PwMInit *sig_init_pointer;
57static NOREGPARM void sig_handler(int signum) 58static NOREGPARM void sig_handler(int signum)
58{ 59{
59 switch (signum) { 60 switch (signum) {
60 case SIGINT: 61 case SIGINT:
61 case SIGTERM: 62 case SIGTERM:
62 sig_init_pointer->shutdownApp(20 + signum); 63 sig_init_pointer->shutdownApp(20 + signum);
63 break; 64 break;
64 default: 65 default:
65 printDebug(string("unhandled signal ") 66 printDebug(string("unhandled signal ")
66 + tostr(signum)); 67 + tostr(signum));
67 } 68 }
68} 69}
69 70
70 71
71 72
72 73
73PwMInit::PwMInit(PwMApplication *_app) 74PwMInit::PwMInit(PwMApplication *_app)
74 : runStatus (unknown) 75 : runStatus (unknown)
75 , _curWidget (0) 76 , _curWidget (0)
76 , _dcopClient (0) 77 , _dcopClient (0)
77 , _kwalletEmu (0) 78 , _kwalletEmu (0)
78 , _keycard (0) 79 , _keycard (0)
79 , _tray (0) 80 , _tray (0)
80{ 81{
81 sig_init_pointer = this; 82 sig_init_pointer = this;
82 app = _app; 83 app = _app;
83} 84}
84 85
85PwMInit::~PwMInit() 86PwMInit::~PwMInit()
86{ 87{
87#ifndef PWM_EMBEDDED 88#ifndef PWM_EMBEDDED
88 SelfTest::cancel(); 89 SelfTest::cancel();
89 // close all open mainwnds 90 // close all open mainwnds
90 QValueList<PwM *>::iterator i = _mainWndList.begin(), 91 QValueList<PwM *>::iterator i = _mainWndList.begin(),
91 end = _mainWndList.end(); 92 end = _mainWndList.end();
92 93
93#else 94#else
94 // close all open mainwnds 95 // close all open mainwnds
95 QValueList<PwM *>::Iterator i = _mainWndList.begin(), 96 QValueList<PwM *>::Iterator i = _mainWndList.begin(),
96 end = _mainWndList.end(); 97 end = _mainWndList.end();
97#endif 98#endif
98 while (i != end) { 99 while (i != end) {
99 disconnect(*i, SIGNAL(closed(PwM *)), 100 disconnect(*i, SIGNAL(closed(PwM *)),
100 this, SLOT(mainWndClosed(PwM *))); 101 this, SLOT(mainWndClosed(PwM *)));
101 delete *i; 102 delete *i;
102 ++i; 103 ++i;
103 } 104 }
104 _mainWndList.clear(); 105 _mainWndList.clear();
105 // close all remaining open documents 106 // close all remaining open documents
106 PwMDocList *_dl = PwMDoc::getOpenDocList(); 107 PwMDocList *_dl = PwMDoc::getOpenDocList();
107 vector<PwMDocList::listItem> dl = *(_dl->getList()); 108 vector<PwMDocList::listItem> dl = *(_dl->getList());
108 vector<PwMDocList::listItem>::iterator i2 = dl.begin(), 109 vector<PwMDocList::listItem>::iterator i2 = dl.begin(),
109 end2 = dl.end(); 110 end2 = dl.end();
110 while (i2 != end2) { 111 while (i2 != end2) {
111 delete (*i2).doc; 112 delete (*i2).doc;
112 ++i2; 113 ++i2;
113 } 114 }
114 115
115#ifdef CONFIG_KWALLETIF 116#ifdef CONFIG_KWALLETIF
116 delete_ifnot_null(_kwalletEmu); 117 delete_ifnot_null(_kwalletEmu);
117#endif // CONFIG_KWALLETIF 118#endif // CONFIG_KWALLETIF
118#ifdef CONFIG_KEYCARD 119#ifdef CONFIG_KEYCARD
119 delete_ifnot_null(_keycard); 120 delete_ifnot_null(_keycard);
120#endif // CONFIG_KEYCARD 121#endif // CONFIG_KEYCARD
121 delete_ifnot_null(_tray); 122 delete_ifnot_null(_tray);
122 123
123 Randomizer::cleanup(); 124 Randomizer::cleanup();
124#ifndef PWM_EMBEDDED 125#ifndef PWM_EMBEDDED
125 Configuration::cleanup(); 126 Configuration::cleanup();
126#endif 127#endif
127} 128}
128 129
129void PwMInit::initializeApp() 130void PwMInit::initializeApp()
130{ 131{
132 qDebug("PwMInit::initializeApp() ");
131 PWM_ASSERT(runStatus == unknown); 133 PWM_ASSERT(runStatus == unknown);
132 runStatus = init; 134 runStatus = init;
133 initPosixSignalHandler(); 135 initPosixSignalHandler();
134 Randomizer::init(); 136 Randomizer::init();
135#ifndef PWM_EMBEDDED 137#ifndef PWM_EMBEDDED
136 Configuration::init(); 138 Configuration::init();
137#endif 139#endif
138 initDCOP(); 140 initDCOP();
139 initKWalletEmu(); 141 initKWalletEmu();
140 initKeycard(); 142 initKeycard();
141 initTray(); 143 initTray();
142 handleCmdLineArgs(); 144 handleCmdLineArgs();
143 145 qDebug("handle ");
144 bool openDeeplocked = false; 146 bool openDeeplocked = false;
145 if (conf()->confGlobAutostartDeepLocked() || 147 if (conf()->confGlobAutostartDeepLocked() ||
146 savedCmd.open_deeplocked) 148 savedCmd.open_deeplocked)
147 openDeeplocked = true; 149 openDeeplocked = true;
148 if (conf()->confWndAutoMinimizeOnStart() || 150 if ( false ){
149 savedCmd.minToTray) { 151 // LR is not working
152 //if (conf()->confWndAutoMinimizeOnStart() ||
153 // savedCmd.minToTray) {
150 PwMDoc *newDoc = createDoc(); 154 PwMDoc *newDoc = createDoc();
155 qDebug(" createDoc()");
151 if (!newDoc->openDocUi(newDoc, 156 if (!newDoc->openDocUi(newDoc,
152 conf()->confGlobAutoStart(), 157 conf()->confGlobAutoStart(),
153 openDeeplocked)) { 158 openDeeplocked)) {
154 delete newDoc; 159 delete newDoc;
160 }
155 161
156 //US ENH for embedded devices: in the case of failure, open a document the default way 162 //US ENH for embedded devices: in the case of failure, open a document the default way
157 createMainWnd(conf()->confGlobAutoStart(), 163 createMainWnd(conf()->confGlobAutoStart(),
158 openDeeplocked, 164 openDeeplocked,
159 true, 165 true,
160 0, 166 0,
161 savedCmd.minimized); 167 savedCmd.minimized);
162 168
163 169
164 170
165 171
166 } 172 //}
167 } else { 173 } else {
168 createMainWnd(conf()->confGlobAutoStart(), 174 createMainWnd(conf()->confGlobAutoStart(),
169 openDeeplocked, 175 openDeeplocked,
170 true, 176 true,
171 0, 177 0,
172 savedCmd.minimized); 178 savedCmd.minimized);
173 } 179 }
174 180
175 runStatus = running; 181 runStatus = running;
176} 182}
177 183
178void PwMInit::shutdownApp(int exitStatus) 184void PwMInit::shutdownApp(int exitStatus)
179{ 185{
180 printDebug(string("PwMInit::shutdownApp(") 186 printDebug(string("PwMInit::shutdownApp(")
181 + tostr(exitStatus) + ") called."); 187 + tostr(exitStatus) + ") called.");
182 PWM_ASSERT((runStatus == running) || (runStatus == init)); 188 PWM_ASSERT((runStatus == running) || (runStatus == init));
183 runStatus = shutdown; 189 runStatus = shutdown;
184 QApplication::exit(exitStatus); 190 QApplication::exit(exitStatus);
185 /* The destructor of PwMInit is called when control 191 /* The destructor of PwMInit is called when control
186 * leaves main() 192 * leaves main()
187 */ 193 */
188} 194}
189 195
190void PwMInit::initPosixSignalHandler() 196void PwMInit::initPosixSignalHandler()
191{ 197{
192 signal(SIGINT, sig_handler); 198 signal(SIGINT, sig_handler);
193 signal(SIGTERM, sig_handler); 199 signal(SIGTERM, sig_handler);
194} 200}
195 201
196void PwMInit::initDCOP() 202void PwMInit::initDCOP()
197{ 203{
198#ifndef PWM_EMBEDDED 204#ifndef PWM_EMBEDDED
199 _dcopClient = app->dcopClient(); 205 _dcopClient = app->dcopClient();
200 _dcopClient->setNotifications(true); 206 _dcopClient->setNotifications(true);
201#endif 207#endif
202 208
203} 209}
204 210
205void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) 211void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload)
206{ 212{
207#ifdef CONFIG_KWALLETIF 213#ifdef CONFIG_KWALLETIF
208 if (!conf()->confGlobKwalletEmu() || 214 if (!conf()->confGlobKwalletEmu() ||
209 forceDisable) { 215 forceDisable) {
210 delete_ifnot_null(_kwalletEmu); 216 delete_ifnot_null(_kwalletEmu);
211 return; 217 return;
212 } 218 }
213 try { 219 try {
214 if (_kwalletEmu && forceReload) 220 if (_kwalletEmu && forceReload)
215 delete_and_null(_kwalletEmu); 221 delete_and_null(_kwalletEmu);
216 if (!_kwalletEmu) 222 if (!_kwalletEmu)
217 _kwalletEmu = new KWalletEmu(this); 223 _kwalletEmu = new KWalletEmu(this);
218 } catch (PwMException e) { 224 } catch (PwMException e) {
219 string errMsg("initializing KWallet emulation failed. ID: "); 225 string errMsg("initializing KWallet emulation failed. ID: ");
220 errMsg += tostr(static_cast<int>(e.getId())); 226 errMsg += tostr(static_cast<int>(e.getId()));
221 errMsg += " err-message: "; 227 errMsg += " err-message: ";
222 errMsg += e.getMessage(); 228 errMsg += e.getMessage();
223 printWarn(errMsg); 229 printWarn(errMsg);
224 return; 230 return;
225 } 231 }
226#else // CONFIG_KWALLETIF 232#else // CONFIG_KWALLETIF
227 PARAM_UNUSED(forceDisable); 233 PARAM_UNUSED(forceDisable);
228 PARAM_UNUSED(forceReload); 234 PARAM_UNUSED(forceReload);
229#endif // CONFIG_KWALLETIF 235#endif // CONFIG_KWALLETIF
230} 236}
231 237
232void PwMInit::initKeycard() 238void PwMInit::initKeycard()
233{ 239{
234#ifdef CONFIG_KEYCARD 240#ifdef CONFIG_KEYCARD
235 PWM_ASSERT(!_keycard); 241 PWM_ASSERT(!_keycard);
236 _keycard = new PwMKeyCard(this); 242 _keycard = new PwMKeyCard(this);
237#endif // CONFIG_KEYCARD 243#endif // CONFIG_KEYCARD
238} 244}
239 245
240void PwMInit::initTray() 246void PwMInit::initTray()
241{ 247{
242#ifdef PWM_EMBEDDED 248#ifdef PWM_EMBEDDED
243 //US ENH : embedded version does not support a tray 249 //US ENH : embedded version does not support a tray
244 return; 250 return;
245#endif 251#endif
246 252
247 if (!conf()->confGlobTray()) { 253 if (!conf()->confGlobTray()) {
248 if (!_tray) 254 if (!_tray)
249 return; 255 return;
250 _tray->hide(); 256 _tray->hide();
251 delete_and_null(_tray); 257 delete_and_null(_tray);
252 return; 258 return;
253 } 259 }
254 if (_tray) 260 if (_tray)
255 return; 261 return;
256 _tray = new PwMTray(this); 262 _tray = new PwMTray(this);
257 connect(_tray, SIGNAL(quitSelected()), 263 connect(_tray, SIGNAL(quitSelected()),
258 this, SLOT(removeTrayAndQuit())); 264 this, SLOT(removeTrayAndQuit()));
259 connect(_tray, SIGNAL(closed(PwMTray *)), 265 connect(_tray, SIGNAL(closed(PwMTray *)),
260 this, SLOT(trayIconClosed(PwMTray *))); 266 this, SLOT(trayIconClosed(PwMTray *)));
261 KIconLoader icons; 267 KIconLoader icons;
262#ifndef PWM_EMBEDDED 268#ifndef PWM_EMBEDDED
263 _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); 269 _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small));
264#endif 270#endif
265 _tray->show(); 271 _tray->show();
266 // connect the signals of all open documents. 272 // connect the signals of all open documents.
267 const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); 273 const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList();
268 vector<PwMDocList::listItem>::const_iterator i = dl->begin(), 274 vector<PwMDocList::listItem>::const_iterator i = dl->begin(),
269 end = dl->end(); 275 end = dl->end();
270 while (i != end) { 276 while (i != end) {
271 _tray->connectDocToTray((*i).doc); 277 _tray->connectDocToTray((*i).doc);
272 ++i; 278 ++i;
273 } 279 }
274} 280}
275 281
276void PwMInit::removeTrayAndQuit() 282void PwMInit::removeTrayAndQuit()
277{ 283{
278 PWM_ASSERT(_tray); 284 PWM_ASSERT(_tray);
279 // _tray is deleted in ~PwMInit 285 // _tray is deleted in ~PwMInit
280 shutdownApp(0); 286 shutdownApp(0);
281} 287}
282 288
283PwM * PwMInit::createMainWnd(const QString &loadFile, 289PwM * PwMInit::createMainWnd(const QString &loadFile,
284 bool loadFileDeepLocked, 290 bool loadFileDeepLocked,
285 bool virginity, 291 bool virginity,
286 PwMDoc *doc, 292 PwMDoc *doc,
287 bool minimized) 293 bool minimized)
288{ 294{
295 qDebug("PwMInit::createMainWnd ");
289 PwM *newWnd; 296 PwM *newWnd;
290 if (!doc) 297 if (!doc)
291 doc = createDoc(); 298 doc = createDoc();
292 newWnd = new PwM(this, doc, virginity); 299 newWnd = new PwM(this, doc, virginity);
293#ifndef PWM_EMBEDDED 300#ifndef PWM_EMBEDDED
294 _mainWndList.push_back(newWnd); 301 _mainWndList.push_back(newWnd);
295#else 302#else
296 _mainWndList.append(newWnd); 303 _mainWndList.append(newWnd);
297#endif 304#endif
298 connect(newWnd, SIGNAL(closed(PwM *)), 305 connect(newWnd, SIGNAL(closed(PwM *)),
299 this, SLOT(mainWndClosed(PwM *))); 306 this, SLOT(mainWndClosed(PwM *)));
300 connect(newWnd, SIGNAL(gotFocus(PwM *)), 307 connect(newWnd, SIGNAL(gotFocus(PwM *)),
301 this, SLOT(setCurWidget(PwM *))); 308 this, SLOT(setCurWidget(PwM *)));
302 connect(newWnd, SIGNAL(lostFocus(PwM *)), 309 connect(newWnd, SIGNAL(lostFocus(PwM *)),
303 this, SLOT(resetCurWidget())); 310 this, SLOT(resetCurWidget()));
304 311
305 //US ENH 312 //US ENH
306#ifndef PWM_EMBEDDED 313#ifndef PWM_EMBEDDED
307 if (minimized) 314 if (minimized)
308 newWnd->showMinimized(); 315 newWnd->showMinimized();
309 else 316 else
310 newWnd->show(); 317 newWnd->show();
311 318
312#else //PWM_EMBEDDED 319#else //PWM_EMBEDDED
313 320
314#ifndef DESKTOP_VERSION 321#ifndef DESKTOP_VERSION
315 app->showMainWidget( newWnd ); 322 app->showMainWidget( newWnd );
316#else //DESKTOP_VERSION 323#else //DESKTOP_VERSION
317 app->setMainWidget( newWnd ); 324 app->setMainWidget( newWnd );
318 newWnd->resize (640, 480 ); 325 newWnd->resize (640, 480 );
319 newWnd->show(); 326 newWnd->show();
327 qDebug("show ");
320#endif //DESKTOP_VERSION 328#endif //DESKTOP_VERSION
321 329
322#endif //PWM_EMBEDDED 330#endif //PWM_EMBEDDED
323 331
324 if (loadFile != QString::null && 332 if (loadFile != QString::null &&
325 loadFile != "") { 333 loadFile != "") {
326 newWnd->openDoc(loadFile, loadFileDeepLocked); 334 newWnd->openDoc(loadFile, loadFileDeepLocked);
327 } 335 }
328 return newWnd; 336 return newWnd;
329} 337}
330 338
331PwMDoc * PwMInit::createDoc() 339PwMDoc * PwMInit::createDoc()
332{ 340{
333 PwMDoc *doc = new PwMDoc(this); 341 PwMDoc *doc = new PwMDoc(this);
334#ifdef CONFIG_KEYCARD 342#ifdef CONFIG_KEYCARD
335 doc->setPwMKeyCard(keycard()); 343 doc->setPwMKeyCard(keycard());
336#endif 344#endif
337#ifdef CONFIG_KWALLETIF 345#ifdef CONFIG_KWALLETIF
338 if (kwalletEmu()) 346 if (kwalletEmu())
339 kwalletEmu()->connectDocSignals(doc); 347 kwalletEmu()->connectDocSignals(doc);
340#endif 348#endif
341 349
342 if (_tray) 350 if (_tray)
343 _tray->connectDocToTray(doc); 351 _tray->connectDocToTray(doc);
344 352
345 return doc; 353 return doc;
346 354
347} 355}
348 356
349void PwMInit::mainWndClosed(PwM *wnd) 357void PwMInit::mainWndClosed(PwM *wnd)
350{ 358{
351 bool doMinimizeToTray = false; 359 bool doMinimizeToTray = false;
352 bool doDeleteDoc = false; 360 bool doDeleteDoc = false;
353#ifndef PWM_EMBEDDED 361#ifndef PWM_EMBEDDED
354 dcopClient()->suspend(); 362 dcopClient()->suspend();
355 dcopClient()->setAcceptCalls(false); 363 dcopClient()->setAcceptCalls(false);
356#endif 364#endif
357again: 365again:
358 366
359 if (wnd->isForceMinimizeToTray()) { 367 if (wnd->isForceMinimizeToTray()) {
360 if (unlikely(!_tray)) { 368 if (unlikely(!_tray)) {
361 /* This should not happen! If we set forceMinimizeToTray , 369 /* This should not happen! If we set forceMinimizeToTray ,
362 * we must be sure that _tray exists. 370 * we must be sure that _tray exists.
363 */ 371 */
364 BUG(); 372 BUG();
365 wnd->setForceMinimizeToTray(false); 373 wnd->setForceMinimizeToTray(false);
366 goto again; 374 goto again;
367 } 375 }
368 doMinimizeToTray = true; 376 doMinimizeToTray = true;
369 } else { 377 } else {
370 // Ask to minimize to tray. If not, delete doc. 378 // Ask to minimize to tray. If not, delete doc.
371 if (_tray && 379 if (_tray &&
372 runStatus != shutdown && 380 runStatus != shutdown &&
373 !wnd->isForceQuit() && 381 !wnd->isForceQuit() &&
374 !wnd->curDoc()->isDeleted()) { 382 !wnd->curDoc()->isDeleted()) {
375 if (conf()->confWndClose()) 383 if (conf()->confWndClose())
376 doDeleteDoc = true; 384 doDeleteDoc = true;
377 else 385 else
378 doMinimizeToTray = true; 386 doMinimizeToTray = true;
379 } else { 387 } else {
380 doDeleteDoc = true; 388 doDeleteDoc = true;
381 } 389 }
382 } 390 }
383 391
384 if (doMinimizeToTray) { 392 if (doMinimizeToTray) {
385 393
386 PWM_ASSERT(_tray); 394 PWM_ASSERT(_tray);
387 int mmlock = conf()->confGlobMinimizeLock(); 395 int mmlock = conf()->confGlobMinimizeLock();
388 switch (mmlock) { 396 switch (mmlock) {
389 case 0: // don't lock anything 397 case 0: // don't lock anything
390 break; 398 break;
391 case 1: // normal lock 399 case 1: // normal lock
392 wnd->curDoc()->lockAll(true); 400 wnd->curDoc()->lockAll(true);
393 break; 401 break;
394 case 2: // deep-lock 402 case 2: // deep-lock
395 wnd->curDoc()->deepLock(); 403 wnd->curDoc()->deepLock();
396 break; 404 break;
397 default: 405 default:
398 WARN(); 406 WARN();
399 } 407 }
400 } else if (doDeleteDoc) { 408 } else if (doDeleteDoc) {
401 if (!wnd->curDoc()->tryDelete()) { 409 if (!wnd->curDoc()->tryDelete()) {
402 /* We failed deleting the doc, 410 /* We failed deleting the doc,
403 * so open a new window with it, again. 411 * so open a new window with it, again.
404 */ 412 */
405 createMainWnd(QString::null, false, 413 createMainWnd(QString::null, false,
406 false, wnd->curDoc()); 414 false, wnd->curDoc());
407 } 415 }
408 } 416 }
409#ifndef PWM_EMBEDDED 417#ifndef PWM_EMBEDDED
410 // find the closed window in the "mainWndList" and delete it. 418 // find the closed window in the "mainWndList" and delete it.
411 QValueList<PwM *>::iterator i = _mainWndList.begin(), 419 QValueList<PwM *>::iterator i = _mainWndList.begin(),
412 end = _mainWndList.end(); 420 end = _mainWndList.end();
413#else 421#else
414 // find the closed window in the "mainWndList" and delete it. 422 // find the closed window in the "mainWndList" and delete it.
415 QValueList<PwM *>::Iterator i = _mainWndList.begin(), 423 QValueList<PwM *>::Iterator i = _mainWndList.begin(),
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
@@ -77,193 +77,197 @@
77 #define ENTRY_DESC_NEW "d" 77 #define ENTRY_DESC_NEW "d"
78 #define ENTRY_NAME_NEW "n" 78 #define ENTRY_NAME_NEW "n"
79 #define ENTRY_PW_NEW "p" 79 #define ENTRY_PW_NEW "p"
80 #define ENTRY_COMMENT_NEW"c" 80 #define ENTRY_COMMENT_NEW"c"
81 #define ENTRY_URL_NEW "u" 81 #define ENTRY_URL_NEW "u"
82 #define ENTRY_LAUNCHER_NEW"l" 82 #define ENTRY_LAUNCHER_NEW"l"
83 #define ENTRY_LVP_NEW "v" 83 #define ENTRY_LVP_NEW "v"
84 #define ENTRY_BIN_NEW ENTRY_BIN_OLD 84 #define ENTRY_BIN_NEW ENTRY_BIN_OLD
85 #define ENTRY_META_NEW ENTRY_META_OLD 85 #define ENTRY_META_NEW ENTRY_META_OLD
86 86
87#if USE_OLD_TAGS != 0 87#if USE_OLD_TAGS != 0
88 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD 88 # define ROOT_MAGIC_WR ROOT_MAGIC_OLD
89 # define VER_STR_WR VER_STR_OLD 89 # define VER_STR_WR VER_STR_OLD
90 # define COMPAT_VER_WR COMPAT_VER_OLD 90 # define COMPAT_VER_WR COMPAT_VER_OLD
91 # define CAT_ROOT_WR CAT_ROOT_OLD 91 # define CAT_ROOT_WR CAT_ROOT_OLD
92 # define CAT_PREFIX_WR CAT_PREFIX_OLD 92 # define CAT_PREFIX_WR CAT_PREFIX_OLD
93 # define CAT_NAME_WR CAT_NAME_OLD 93 # define CAT_NAME_WR CAT_NAME_OLD
94 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD 94 # define ENTRY_PREFIX_WRENTRY_PREFIX_OLD
95 # define ENTRY_DESC_WR ENTRY_DESC_OLD 95 # define ENTRY_DESC_WR ENTRY_DESC_OLD
96 # define ENTRY_NAME_WR ENTRY_NAME_OLD 96 # define ENTRY_NAME_WR ENTRY_NAME_OLD
97 # define ENTRY_PW_WR ENTRY_PW_OLD 97 # define ENTRY_PW_WR ENTRY_PW_OLD
98 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD 98 # define ENTRY_COMMENT_WRENTRY_COMMENT_OLD
99 # define ENTRY_URL_WR ENTRY_URL_OLD 99 # define ENTRY_URL_WR ENTRY_URL_OLD
100 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD 100 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_OLD
101 # define ENTRY_LVP_WR ENTRY_LVP_OLD 101 # define ENTRY_LVP_WR ENTRY_LVP_OLD
102 # define ENTRY_BIN_WR ENTRY_BIN_OLD 102 # define ENTRY_BIN_WR ENTRY_BIN_OLD
103 # define ENTRY_META_WR ENTRY_META_OLD 103 # define ENTRY_META_WR ENTRY_META_OLD
104#else 104#else
105 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW 105 # define ROOT_MAGIC_WR ROOT_MAGIC_NEW
106 # define VER_STR_WR VER_STR_NEW 106 # define VER_STR_WR VER_STR_NEW
107 # define COMPAT_VER_WR COMPAT_VER_NEW 107 # define COMPAT_VER_WR COMPAT_VER_NEW
108 # define CAT_ROOT_WR CAT_ROOT_NEW 108 # define CAT_ROOT_WR CAT_ROOT_NEW
109 # define CAT_PREFIX_WR CAT_PREFIX_NEW 109 # define CAT_PREFIX_WR CAT_PREFIX_NEW
110 # define CAT_NAME_WR CAT_NAME_NEW 110 # define CAT_NAME_WR CAT_NAME_NEW
111 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW 111 # define ENTRY_PREFIX_WRENTRY_PREFIX_NEW
112 # define ENTRY_DESC_WR ENTRY_DESC_NEW 112 # define ENTRY_DESC_WR ENTRY_DESC_NEW
113 # define ENTRY_NAME_WR ENTRY_NAME_NEW 113 # define ENTRY_NAME_WR ENTRY_NAME_NEW
114 # define ENTRY_PW_WR ENTRY_PW_NEW 114 # define ENTRY_PW_WR ENTRY_PW_NEW
115 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW 115 # define ENTRY_COMMENT_WRENTRY_COMMENT_NEW
116 # define ENTRY_URL_WR ENTRY_URL_NEW 116 # define ENTRY_URL_WR ENTRY_URL_NEW
117 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW 117 # define ENTRY_LAUNCHER_WRENTRY_LAUNCHER_NEW
118 # define ENTRY_LVP_WR ENTRY_LVP_NEW 118 # define ENTRY_LVP_WR ENTRY_LVP_NEW
119 # define ENTRY_BIN_WR ENTRY_BIN_NEW 119 # define ENTRY_BIN_WR ENTRY_BIN_NEW
120 # define ENTRY_META_WR ENTRY_META_NEW 120 # define ENTRY_META_WR ENTRY_META_NEW
121#endif 121#endif
122 122
123 123
124Serializer::Serializer() 124Serializer::Serializer()
125{ 125{
126 defaultLockStat = true; 126 defaultLockStat = true;
127//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing 127//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
128#ifndef PWM_EMBEDDED 128#ifndef PWM_EMBEDDED
129 domDoc = new QDomDocument; 129 domDoc = new QDomDocument;
130#else 130#else
131 domDoc = new QDomDocument("mydoc"); 131 domDoc = new QDomDocument("mydoc");
132#endif 132#endif
133} 133}
134 134
135Serializer::Serializer(const QCString &buffer) 135Serializer::Serializer(const QCString &buffer)
136{ 136{
137 defaultLockStat = true; 137 defaultLockStat = true;
138//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing 138//US BUG: I needed to specify a document name. Otherwise impl will not be created for serializing
139#ifndef PWM_EMBEDDED 139#ifndef PWM_EMBEDDED
140 domDoc = new QDomDocument; 140 domDoc = new QDomDocument;
141#else 141#else
142 domDoc = new QDomDocument("mydoc"); 142 domDoc = new QDomDocument("mydoc");
143#endif 143#endif
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 PWM_ASSERT(domDoc); 168 PWM_ASSERT(domDoc);
169#ifndef PWM_EMBEDDED 169#ifndef PWM_EMBEDDED
170 if (!domDoc->setContent(buffer, true)) 170 if (!domDoc->setContent(buffer, true))
171 return false; 171 return false;
172#else 172#else
173#ifdef DESKTOP_VERSION
174 if (!domDoc->setContent(buffer, true))
175#else
173 if (!domDoc->setContent(buffer)) 176 if (!domDoc->setContent(buffer))
177#endif
174 return false; 178 return false;
175#endif 179#endif
176 if (!checkValid()) 180 if (!checkValid())
177 return false; 181 return false;
178 return true; 182 return true;
179} 183}
180 184
181QCString Serializer::getXml() 185QCString Serializer::getXml()
182{ 186{
183 PWM_ASSERT(domDoc); 187 PWM_ASSERT(domDoc);
184 188
185#ifndef PWM_EMBEDDED 189#ifndef PWM_EMBEDDED
186#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 190#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
187 QCString tmp(domDoc->toCString(8)); 191 QCString tmp(domDoc->toCString(8));
188 printDebug("<BEGIN Serializer::getXml() dump>\n"); 192 printDebug("<BEGIN Serializer::getXml() dump>\n");
189 cout << tmp << endl; 193 cout << tmp << endl;
190 printDebug("<END Serializer::getXml() dump>"); 194 printDebug("<END Serializer::getXml() dump>");
191#endif // DEBUG 195#endif // DEBUG
192 196
193 QCString ret(domDoc->toCString(0)); 197 QCString ret(domDoc->toCString(0));
194 ret.replace('\n', ""); 198 ret.replace('\n', "");
195 return ret; 199 return ret;
196#else 200#else
197 201
198#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0 202#if defined(PWM_DEBUG) && SERIALIZER_DEBUG != 0
199 QCString tmp(" " + domDoc->toCString()); 203 QCString tmp(" " + domDoc->toCString());
200 printDebug("<BEGIN Serializer::getXml() dump>\n"); 204 printDebug("<BEGIN Serializer::getXml() dump>\n");
201 qDebug(tmp); 205 qDebug(tmp);
202 cout << tmp << endl; 206 cout << tmp << endl;
203 printDebug("<END Serializer::getXml() dump>"); 207 printDebug("<END Serializer::getXml() dump>");
204#endif // DEBUG 208#endif // DEBUG
205 209
206 QCString ret(domDoc->toCString()); 210 QCString ret(domDoc->toCString());
207 ret.replace(QRegExp("\n"), ""); 211 ret.replace(QRegExp("\n"), "");
208 return ret; 212 return ret;
209 213
210#endif 214#endif
211} 215}
212 216
213bool Serializer::serialize(PwMItem &dta) 217bool Serializer::serialize(PwMItem &dta)
214{ 218{
215 PWM_ASSERT(domDoc); 219 PWM_ASSERT(domDoc);
216 QDomElement root(genNewRoot()); 220 QDomElement root(genNewRoot());
217 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR)); 221 QDomElement catNode(domDoc->createElement(CAT_ROOT_WR));
218 QDomElement syncNode(domDoc->createElement(SYNC_ROOT)); 222 QDomElement syncNode(domDoc->createElement(SYNC_ROOT));
219 if (!addSyncData(&syncNode, dta.syncDta)) 223 if (!addSyncData(&syncNode, dta.syncDta))
220 return false; 224 return false;
221 root.appendChild(syncNode); 225 root.appendChild(syncNode);
222 if (!addCategories(&catNode, dta.dta)) 226 if (!addCategories(&catNode, dta.dta))
223 return false; 227 return false;
224 root.appendChild(catNode); 228 root.appendChild(catNode);
225 return true; 229 return true;
226} 230}
227 231
228bool Serializer::deSerialize(PwMItem *dta) 232bool Serializer::deSerialize(PwMItem *dta)
229{ 233{
230 PWM_ASSERT(domDoc); 234 PWM_ASSERT(domDoc);
231 PWM_ASSERT(dta); 235 PWM_ASSERT(dta);
232 QDomElement root(domDoc->documentElement()); 236 QDomElement root(domDoc->documentElement());
233 QDomNode n; 237 QDomNode n;
234 238
235 dta->clear(); 239 dta->clear();
236 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) { 240 for (n = root.firstChild(); !n.isNull(); n = n.nextSibling()) {
237 // find <categories> ... </categories> 241 // find <categories> ... </categories>
238 // <c> ... </c> 242 // <c> ... </c>
239 if (n.nodeName() == CAT_ROOT_NEW || 243 if (n.nodeName() == CAT_ROOT_NEW ||
240 n.nodeName() == CAT_ROOT_OLD) { 244 n.nodeName() == CAT_ROOT_OLD) {
241 if (!readCategories(n, &(dta->dta))) { 245 if (!readCategories(n, &(dta->dta))) {
242 return false; 246 return false;
243 } 247 }
244 continue; 248 continue;
245 } 249 }
246 else if (n.nodeName() == SYNC_ROOT) { 250 else if (n.nodeName() == SYNC_ROOT) {
247 if (!readSyncData(n, &(dta->syncDta))) { 251 if (!readSyncData(n, &(dta->syncDta))) {
248 return false; 252 return false;
249 } 253 }
250 continue; 254 continue;
251 } 255 }
252 256
253 /* NOTE: We can stop processing here, as we 257 /* NOTE: We can stop processing here, as we
254 * don't have more nodes in root, yet. 258 * don't have more nodes in root, yet.
255 */ 259 */
256 return false; 260 return false;
257 261
258 } 262 }
259 return true; 263 return true;
260} 264}
261 265
262bool Serializer::readCategories(const QDomNode &n, 266bool Serializer::readCategories(const QDomNode &n,
263 vector<PwMCategoryItem> *dta) 267 vector<PwMCategoryItem> *dta)
264{ 268{
265 QDomNodeList nl(n.childNodes()); 269 QDomNodeList nl(n.childNodes());
266 QDomNode cur; 270 QDomNode cur;
267 QString name; 271 QString name;
268 unsigned int numCat = nl.count(), i; 272 unsigned int numCat = nl.count(), i;
269 PwMCategoryItem curCat; 273 PwMCategoryItem curCat;
@@ -639,142 +643,142 @@ bool Serializer::writeMeta(QDomElement *e,
639 643
640 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. 644 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
641 //So do not transform an empty value at all. 645 //So do not transform an empty value at all.
642 if (dta.expire.isValid()) 646 if (dta.expire.isValid())
643 { 647 {
644 tag = domDoc->createElement(META_EXPIRE_DATE); 648 tag = domDoc->createElement(META_EXPIRE_DATE);
645#ifndef PWM_EMBEDDED 649#ifndef PWM_EMBEDDED
646 text = domDoc->createTextNode(dta.expire.toString(Qt::ISODate)); 650 text = domDoc->createTextNode(dta.expire.toString(Qt::ISODate));
647#else 651#else
648 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.expire, KLocale::ISODate)); 652 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.expire, KLocale::ISODate));
649#endif 653#endif
650 tag.appendChild(text); 654 tag.appendChild(text);
651 e->appendChild(tag); 655 e->appendChild(tag);
652 } 656 }
653 657
654 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers. 658 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
655 //So do not transform an empty value at all. 659 //So do not transform an empty value at all.
656 if (dta.update.isValid()) 660 if (dta.update.isValid())
657 { 661 {
658 tag = domDoc->createElement(META_UPDATE_DATE); 662 tag = domDoc->createElement(META_UPDATE_DATE);
659#ifndef PWM_EMBEDDED 663#ifndef PWM_EMBEDDED
660 text = domDoc->createTextNode(dta.update.toString(Qt::ISODate)); 664 text = domDoc->createTextNode(dta.update.toString(Qt::ISODate));
661#else 665#else
662 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.update, KLocale::ISODate)); 666 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.update, KLocale::ISODate));
663#endif 667#endif
664 tag.appendChild(text); 668 tag.appendChild(text);
665 e->appendChild(tag); 669 e->appendChild(tag);
666 } 670 }
667 671
668 tag = domDoc->createElement(META_UPDATE_INT); 672 tag = domDoc->createElement(META_UPDATE_INT);
669 text = domDoc->createTextNode(tostr(dta.updateInt).c_str()); 673 text = domDoc->createTextNode(tostr(dta.updateInt).c_str());
670 tag.appendChild(text); 674 tag.appendChild(text);
671 e->appendChild(tag); 675 e->appendChild(tag);
672 676
673 tag = domDoc->createElement(META_UNIQUEID); 677 tag = domDoc->createElement(META_UNIQUEID);
674 text = domDoc->createTextNode(escapeEntryData(dta.uniqueid.c_str())); 678 text = domDoc->createTextNode(escapeEntryData(dta.uniqueid.c_str()));
675 tag.appendChild(text); 679 tag.appendChild(text);
676 e->appendChild(tag); 680 e->appendChild(tag);
677 681
678#undef new_text 682#undef new_text
679 return true; 683 return true;
680} 684}
681 685
682QString Serializer::escapeEntryData(QString dta) 686QString Serializer::escapeEntryData(QString dta)
683{ 687{
684#ifndef PWM_EMBEDDED 688#ifndef PWM_EMBEDDED
685 dta.replace('\n', "$>--endl--<$"); 689 dta.replace('\n', "$>--endl--<$");
686 dta.replace("]]>", "||>"); 690 dta.replace("]]>", "||>");
687#else 691#else
688 dta.replace(QRegExp("\n"), "$>--endl--<$"); 692 dta.replace(QRegExp("\n"), "$>--endl--<$");
689 dta.replace(QRegExp("]]>"), "||>"); 693 dta.replace(QRegExp("]]>"), "||>");
690#endif 694#endif
691 return dta; 695 return dta;
692} 696}
693 697
694QString Serializer::unescapeEntryData(QString dta) 698QString Serializer::unescapeEntryData(QString dta)
695{ 699{
696#ifndef PWM_EMBEDDED 700#ifndef PWM_EMBEDDED
697 dta.replace("$>--endl--<$", "\n"); 701 dta.replace("$>--endl--<$", "\n");
698 dta.replace("||>", "]]>"); 702 dta.replace("||>", "]]>");
699#else 703#else
700 dta.replace(QRegExp("\\$>--endl--<\\$"), "\n"); 704 dta.replace(QRegExp("\\$>--endl--<\\$"), "\n");
701 dta.replace(QRegExp("||>"), "]]>"); 705 dta.replace(QRegExp("||>"), "]]>");
702#endif 706#endif
703 return dta; 707 return dta;
704} 708}
705 709
706 710
707//US ENH: the following methods are getting used to write/read sync entries 711//US ENH: the following methods are getting used to write/read sync entries
708/** read the syncentries in the node "n" */ 712/** read the syncentries in the node "n" */
709bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta) 713bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta)
710{ 714{
711 QDomNodeList nl(n.childNodes()); 715 QDomNodeList nl(n.childNodes());
712 QDomNode cur; 716 QDomNode cur;
713 717
714 QString devicename, val; 718 QString devicename, val;
715 unsigned int numSync = nl.count(), i; 719 unsigned int numSync = nl.count(), i;
716 PwMSyncItem curSync; 720 PwMSyncItem curSync;
717 bool ok = true; 721 bool ok = true;
718 722
719 if (!numSync) { 723 if (!numSync) {
720 //no sync entries is a possible result 724 //no sync entries is a possible result
721 printDebug("Serializer::readSyncData(): empty"); 725 printDebug("Serializer::readSyncData(): empty");
722 return true; 726 return true;
723 } 727 }
724 for (i = 0; i < numSync; ++i) { 728 for (i = 0; i < numSync; ++i) {
725 cur = nl.item(i); 729 cur = nl.item(i);
726 if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) { 730 if (cur.nodeName().left(1) == SYNC_TARGET_PREFIX) {
727 devicename = cur.toElement().attribute(SYNC_TARGET_NAME); 731 devicename = cur.toElement().attribute(SYNC_TARGET_NAME);
728 val = cur.toElement().text(); 732 val = cur.toElement().text();
729 733
730 if ((val == "") || (devicename == QString::null)) { 734 if ((val == "") || (devicename == QString::null)) {
731 printDebug("Serializer::readSyncData(): empty synctarget name or syncdate"); 735 printDebug("Serializer::readSyncData(): empty synctarget name or syncdate");
732 continue; 736 continue;
733 } 737 }
734 738
735 curSync.syncName = devicename; 739 curSync.syncName = devicename.latin1();
736#ifndef PWM_EMBEDDED 740#ifndef PWM_EMBEDDED
737 curSync.lastSyncDate = QDateTime::fromString(val, Qt::ISODate); 741 curSync.lastSyncDate = QDateTime::fromString(val, Qt::ISODate);
738#else 742#else
739 curSync.lastSyncDate = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); 743 curSync.lastSyncDate = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
740 if (ok == false) 744 if (ok == false)
741 qDebug("Serializer::readSyncData(): could not parse syncdate:%s",val.latin1()); 745 qDebug("Serializer::readSyncData(): could not parse syncdate:%s",val.latin1());
742 746
743#endif 747#endif
744 dta->push_back(curSync); 748 dta->push_back(curSync);
745 } 749 }
746 } 750 }
747 return true; 751 return true;
748 752
749} 753}
750 754
751 755
752 756
753bool Serializer::addSyncData(QDomElement *e, 757bool Serializer::addSyncData(QDomElement *e,
754 const vector<PwMSyncItem> &dta) 758 const vector<PwMSyncItem> &dta)
755{ 759{
756 unsigned int numSync = dta.size(), i; 760 unsigned int numSync = dta.size(), i;
757 QString curId, curDeviceName; 761 QString curId, curDeviceName;
758 QDomElement curSync; 762 QDomElement curSync;
759 QDomText text; 763 QDomText text;
760 764
761 for (i = 0; i < numSync; ++i) { 765 for (i = 0; i < numSync; ++i) {
762 curId = SYNC_TARGET_PREFIX; 766 curId = SYNC_TARGET_PREFIX;
763 curId += tostr(i).c_str(); 767 curId += tostr(i).c_str();
764 curDeviceName = dta[i].syncName.c_str(); 768 curDeviceName = dta[i].syncName.c_str();
765 curSync = domDoc->createElement(curId); 769 curSync = domDoc->createElement(curId);
766 curSync.setAttribute(SYNC_TARGET_NAME, curDeviceName); 770 curSync.setAttribute(SYNC_TARGET_NAME, curDeviceName);
767 771
768#ifndef PWM_EMBEDDED 772#ifndef PWM_EMBEDDED
769 text = domDoc->createTextNode(dta[i].lastSyncDate.toString(Qt::ISODate)); 773 text = domDoc->createTextNode(dta[i].lastSyncDate.toString(Qt::ISODate));
770#else 774#else
771 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate)); 775 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate));
772#endif 776#endif
773 curSync.appendChild(text); 777 curSync.appendChild(text);
774 778
775 e->appendChild(curSync); 779 e->appendChild(curSync);
776 780
777 } 781 }
778 return true; 782 return true;
779} 783}
780 784