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
@@ -158,56 +158,57 @@ int main(int argc, char *argv[])
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
@@ -541,174 +541,174 @@ PwMView * 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());
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
@@ -89,104 +89,106 @@ public:
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 */
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,78 +1,83 @@
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 \
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
@@ -2284,98 +2284,98 @@ bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex)
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
@@ -2973,117 +2973,117 @@ bool PwMDoc::tryDelete()
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()) {
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,69 +1,70 @@
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
@@ -83,132 +84,137 @@ PwMInit::PwMInit(PwMApplication *_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)
@@ -241,127 +247,129 @@ void 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 }
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
@@ -125,97 +125,101 @@ Serializer::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);
@@ -687,94 +691,94 @@ QString Serializer::escapeEntryData(QString dta)
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