summaryrefslogtreecommitdiffabout
path: root/pwmanager
authorulf69 <ulf69>2004-10-18 02:55:13 (UTC)
committer ulf69 <ulf69>2004-10-18 02:55:13 (UTC)
commit2fd3f09238a624b1a91793d43b5f3653e2b34763 (patch) (unidiff)
tree07cff893e261ad594ff44d7ab2e8e457a88d6390 /pwmanager
parent4e7fac5fdb4c0dace10cada64f036c56bb29fe58 (diff)
downloadkdepimpi-2fd3f09238a624b1a91793d43b5f3653e2b34763.zip
kdepimpi-2fd3f09238a624b1a91793d43b5f3653e2b34763.tar.gz
kdepimpi-2fd3f09238a624b1a91793d43b5f3653e2b34763.tar.bz2
*** empty log message ***
Diffstat (limited to 'pwmanager') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwm.cpp57
-rw-r--r--pwmanager/pwmanager/pwm.h8
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp85
-rw-r--r--pwmanager/pwmanager/pwmdoc.h39
-rw-r--r--pwmanager/pwmanager/pwmview.cpp92
-rw-r--r--pwmanager/pwmanager/pwmview.h25
-rw-r--r--pwmanager/pwmanager/serializer.cpp126
7 files changed, 287 insertions, 145 deletions
diff --git a/pwmanager/pwmanager/pwm.cpp b/pwmanager/pwmanager/pwm.cpp
index 014e809..57b4432 100644
--- a/pwmanager/pwmanager/pwm.cpp
+++ b/pwmanager/pwmanager/pwm.cpp
@@ -129,13 +129,14 @@ enum {
129 129
130#ifdef PWM_EMBEDDED 130#ifdef PWM_EMBEDDED
131// Button IDs for "help" popup menu 131// Button IDs for "help" popup menu
132enum { 132enum {
133 BUTTON_POPUP_HELP_LICENSE = 0, 133 BUTTON_POPUP_HELP_LICENSE = 0,
134 BUTTON_POPUP_HELP_FAQ, 134 BUTTON_POPUP_HELP_FAQ,
135 BUTTON_POPUP_HELP_ABOUT 135 BUTTON_POPUP_HELP_ABOUT,
136 BUTTON_POPUP_HELP_SYNC
136}; 137};
137#endif 138#endif
138 139
139// Button IDs for toolbar 140// Button IDs for toolbar
140enum { 141enum {
141 BUTTON_TOOL_NEW = 0, 142 BUTTON_TOOL_NEW = 0,
@@ -153,13 +154,13 @@ enum {
153}; 154};
154 155
155 156
156PwM::PwM(PwMInit *_init, PwMDoc *doc, 157PwM::PwM(PwMInit *_init, PwMDoc *doc,
157 bool virginity, 158 bool virginity,
158 QWidget *parent, const char *name) 159 QWidget *parent, const char *name)
159 : KMainWindow(parent, name) 160 : KMainWindow(parent, "HALLO")
160 , forceQuit (false) 161 , forceQuit (false)
161 , forceMinimizeToTray (false) 162 , forceMinimizeToTray (false)
162{ 163{
163 init = _init; 164 init = _init;
164 connect(doc, SIGNAL(docClosed(PwMDoc *)), 165 connect(doc, SIGNAL(docClosed(PwMDoc *)),
165 this, SLOT(docClosed(PwMDoc *))); 166 this, SLOT(docClosed(PwMDoc *)));
@@ -355,12 +356,16 @@ void PwM::initMenubar()
355 BUTTON_POPUP_HELP_FAQ); 356 BUTTON_POPUP_HELP_FAQ);
356 357
357 helpPopup->insertItem(i18n("&About PwManager"), this, 358 helpPopup->insertItem(i18n("&About PwManager"), this,
358 SLOT(createAboutData_slot()), 0, 359 SLOT(createAboutData_slot()), 0,
359 BUTTON_POPUP_HELP_ABOUT); 360 BUTTON_POPUP_HELP_ABOUT);
360 361
362 helpPopup->insertItem(i18n("&Sync HowTo"), this,
363 SLOT(syncHowTo_slot()), 0,
364 BUTTON_POPUP_HELP_SYNC);
365
361#endif 366#endif
362 menuBar()->insertItem(i18n("&Help"), helpPopup); 367 menuBar()->insertItem(i18n("&Help"), helpPopup);
363 368
364} 369}
365 370
366void PwM::initToolbar() 371void PwM::initToolbar()
@@ -606,30 +611,36 @@ void PwM::addPwd_slot(QString *pw, PwMDoc *_doc)
606 w.pwLineEdit->setText(*pw); 611 w.pwLineEdit->setText(*pw);
607 612
608 tryAgain: 613 tryAgain:
609 if (w.exec() == 1) 614 if (w.exec() == 1)
610 { 615 {
611 PwMDataItem d; 616 PwMDataItem d;
617
618 //US BUG: to initialize all values of curEntr with meaningfulldata,
619 // we call clear on it. Reason: Metadata will be uninitialized otherwise.
620 // another option would be to create a constructor for PwMDataItem
621 d.clear(true);
622
612 d.desc = w.getDescription().latin1(); 623 d.desc = w.getDescription().latin1();
613 d.name = w.getUsername().latin1(); 624 d.name = w.getUsername().latin1();
614 d.pw = w.getPassword().latin1(); 625 d.pw = w.getPassword().latin1();
615 d.comment = w.getComment().latin1(); 626 d.comment = w.getComment().latin1();
616 d.url = w.getUrl().latin1(); 627 d.url = w.getUrl().latin1();
617 d.launcher = w.getLauncher().latin1(); 628 d.launcher = w.getLauncher().latin1();
618 PwMerror ret = doc->addEntry(w.getCategory(), &d); 629 PwMerror ret = doc->addEntry(w.getCategory(), &d);
619 if (ret == e_entryExists) { 630 if (ret == e_entryExists) {
620 KMessageBox::error(this, 631 KMessageBox::error(this,
621 i18n 632 i18n
622 ("An entry with this \"Description\", " 633 ("An entry with this \"Description\",\n"
623 "does already exist.\n" 634 "does already exist.\n"
624 "Please select another description."), 635 "Please select another description."),
625 i18n("entry already exists.")); 636 i18n("entry already exists."));
626 goto tryAgain; 637 goto tryAgain;
627 } else if (ret == e_maxAllowedEntr) { 638 } else if (ret == e_maxAllowedEntr) {
628 KMessageBox::error(this, i18n("The maximum possible number of entries " 639 KMessageBox::error(this, i18n("The maximum possible number of\nentries"
629 "has been reached. You can't add more entries."), 640 "has been reached.\nYou can't add more entries."),
630 i18n("maximum number of entries")); 641 i18n("maximum number of entries"));
631 doc->timer()->putLock(DocTimer::id_autoLockTimer); 642 doc->timer()->putLock(DocTimer::id_autoLockTimer);
632 return; 643 return;
633 } 644 }
634 } 645 }
635 setVirgin(false); 646 setVirgin(false);
@@ -1284,12 +1295,19 @@ void PwM::showLicense_slot()
1284 1295
1285void PwM::faq_slot() 1296void PwM::faq_slot()
1286{ 1297{
1287 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" ); 1298 KApplication::showFile( "PWM/Pi FAQ", "kdepim/pwmanager/pwmanagerFAQ.txt" );
1288} 1299}
1289 1300
1301void PwM::syncHowTo_slot()
1302{
1303 qDebug("PwM::syncHowTo_slot");
1304 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1305}
1306
1307
1290void PwM::createAboutData_slot() 1308void PwM::createAboutData_slot()
1291{ 1309{
1292 QString version; 1310 QString version;
1293#include <../version> 1311#include <../version>
1294 QMessageBox::about( this, "About PwManager/Pi", 1312 QMessageBox::about( this, "About PwManager/Pi",
1295 "PwManager/Platform-independent\n" 1313 "PwManager/Platform-independent\n"
@@ -1323,43 +1341,24 @@ void PwM::createAboutData_slot()
1323bool PwM::sync(KSyncManager* manager, QString filename, int mode) 1341bool PwM::sync(KSyncManager* manager, QString filename, int mode)
1324{ 1342{
1325 PWM_ASSERT(curDoc()); 1343 PWM_ASSERT(curDoc());
1326 1344
1327 bool ret = curDoc()->sync(manager, filename, mode); 1345 bool ret = curDoc()->sync(manager, filename, mode);
1328 1346
1347 qDebug("PwM::sync save now: ret=%i", ret);
1348
1329 if (ret == true) { 1349 if (ret == true) {
1330 //US BUG: what can we call here to update the view of the current doc? 1350 //US BUG: what can we call here to update the view of the current doc?
1331 //mViewManager->refreshView(); 1351 //mViewManager->refreshView();
1352
1353 //US curDoc()->sync sets the dirtyFlag in case the sync was successfull.
1354 save();
1332 } 1355 }
1333 1356
1334 return ret; 1357 return ret;
1335} 1358}
1336
1337//called by the syncmanager to indicate that the work has to be marked as dirty.
1338void PwM::sync_setModified()
1339{
1340 PWM_ASSERT(curDoc());
1341 curDoc()->sync_setModified();
1342}
1343
1344//called by the syncmanager to ask if the dirty flag is set.
1345bool PwM::sync_isModified()
1346{
1347 PWM_ASSERT(curDoc());
1348 return curDoc()->sync_isModified();
1349}
1350
1351//called by the syncmanager to indicate that the work has to be saved.
1352void PwM::sync_save()
1353{
1354 PWM_ASSERT(curDoc());
1355 return curDoc()->sync_save();
1356}
1357
1358
1359
1360#endif 1359#endif
1361 1360
1362 1361
1363#ifndef PWM_EMBEDDED 1362#ifndef PWM_EMBEDDED
1364#include "pwm.moc" 1363#include "pwm.moc"
1365#endif 1364#endif
diff --git a/pwmanager/pwmanager/pwm.h b/pwmanager/pwmanager/pwm.h
index 7c6bf0d..6ed9d34 100644
--- a/pwmanager/pwmanager/pwm.h
+++ b/pwmanager/pwmanager/pwm.h
@@ -174,12 +174,13 @@ public slots:
174 void replayCardBackup_slot(); 174 void replayCardBackup_slot();
175 175
176#ifdef PWM_EMBEDDED 176#ifdef PWM_EMBEDDED
177 void showLicense_slot(); 177 void showLicense_slot();
178 void faq_slot(); 178 void faq_slot();
179 void createAboutData_slot(); 179 void createAboutData_slot();
180 void syncHowTo_slot();
180#endif 181#endif
181 182
182protected: 183protected:
183 /** is this window virgin? */ 184 /** is this window virgin? */
184 bool isVirgin() 185 bool isVirgin()
185 { return virgin; } 186 { return virgin; }
@@ -269,19 +270,12 @@ protected:
269 270
270 private: 271 private:
271#ifdef PWM_EMBEDDED 272#ifdef PWM_EMBEDDED
272 //this are the overwritten callbackmethods from the syncinterface 273 //this are the overwritten callbackmethods from the syncinterface
273 virtual bool sync(KSyncManager* manager, QString filename, int mode); 274 virtual bool sync(KSyncManager* manager, QString filename, int mode);
274 275
275 //called by the syncmanager to indicate that the work has to marked as dirty.
276 virtual void sync_setModified();
277 //called by the syncmanager to ask if the dirty flag is set.
278 virtual bool sync_isModified();
279 //called by the syncmanager to indicate that the work has to be saved.
280 virtual void sync_save();
281
282 // LR ******************************* 276 // LR *******************************
283 // sync stuff! 277 // sync stuff!
284 QPopupMenu *syncPopup; 278 QPopupMenu *syncPopup;
285 KSyncManager* syncManager; 279 KSyncManager* syncManager;
286#endif 280#endif
287 281
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 0ac5517..2a7b11d 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -484,13 +484,14 @@ PwMerror PwMDoc::saveDoc(char compress, const QString *file)
484 printWarn(string("removing file ") 484 printWarn(string("removing file ")
485 + tmpFileMoved.latin1() 485 + tmpFileMoved.latin1()
486 + " failed!"); 486 + " failed!");
487 } 487 }
488 } 488 }
489 ret = e_success; 489 ret = e_success;
490 printDebug(string("writing file { compress: ") 490 printDebug(string("writing file { name: ")
491 + filename.latin1() + " compress: "
491 + tostr(static_cast<int>(compress)) + " cryptAlgo: " 492 + tostr(static_cast<int>(compress)) + " cryptAlgo: "
492 + tostr(static_cast<int>(cryptAlgo)) + " hashAlgo: " 493 + tostr(static_cast<int>(cryptAlgo)) + " hashAlgo: "
493 + tostr(static_cast<int>(hashAlgo)) 494 + tostr(static_cast<int>(hashAlgo))
494 + " }"); 495 + " }");
495 goto out; 496 goto out;
496out_moveback: 497out_moveback:
@@ -602,13 +603,15 @@ out_success:
602 603
603PwMerror PwMDoc::writeFileHeader(char keyHash, char dataHash, char crypt, char compress, 604PwMerror PwMDoc::writeFileHeader(char keyHash, char dataHash, char crypt, char compress,
604 QString *pw, QFile *f) 605 QString *pw, QFile *f)
605{ 606{
606 PWM_ASSERT(pw); 607 PWM_ASSERT(pw);
607 PWM_ASSERT(f); 608 PWM_ASSERT(f);
608 PWM_ASSERT(listView); 609 //US ENH: or maybe a bug: checking here for listView does not make sense because we do not check anywhere else
610 //Wenn I sync, I open a doc without a view => listView is 0 => Assertion
611 //USPWM_ASSERT(listView);
609 if (f->writeBlock(FILE_ID_HEADER, strlen(FILE_ID_HEADER)) != 612 if (f->writeBlock(FILE_ID_HEADER, strlen(FILE_ID_HEADER)) !=
610 static_cast<Q_LONG>(strlen(FILE_ID_HEADER))) { 613 static_cast<Q_LONG>(strlen(FILE_ID_HEADER))) {
611 return e_writeFile; 614 return e_writeFile;
612 } 615 }
613 if (f->putch(PWM_FILE_VER) == -1 || 616 if (f->putch(PWM_FILE_VER) == -1 ||
614 f->putch(keyHash) == -1 || 617 f->putch(keyHash) == -1 ||
@@ -2801,16 +2804,25 @@ PwMerror PwMDoc::importFromGpasman(const QString *file)
2801 2804
2802void PwMDoc::ensureLvp() 2805void PwMDoc::ensureLvp()
2803{ 2806{
2804 if (isDocEmpty()) 2807 if (isDocEmpty())
2805 return; 2808 return;
2806 2809
2810 //US ENH BUG: when using syncronizing, this way of sorting
2811 //is not sufficient, because there might be empty spaces
2812 // at the beginning. But this algorythm only can add elements
2813 //to the end.The result are crashes because of listoverflows
2814 //we need something to fill all gaps.
2807 vector< vector<PwMDataItem>::iterator > undefined; 2815 vector< vector<PwMDataItem>::iterator > undefined;
2816 vector< vector<PwMDataItem>::iterator > sorted;
2808 vector< vector<PwMDataItem>::iterator >::iterator undefBegin, 2817 vector< vector<PwMDataItem>::iterator >::iterator undefBegin,
2809 undefEnd, 2818 undefEnd,
2810 undefI; 2819 undefI;
2820 vector< vector<PwMDataItem>::iterator >::iterator sortedBegin,
2821 sortedEnd,
2822 sortedI;
2811 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), 2823 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
2812 catEnd = dti.dta.end(), 2824 catEnd = dti.dta.end(),
2813 catI = catBegin; 2825 catI = catBegin;
2814 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 2826 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
2815 int lvpTop, tmpLvp; 2827 int lvpTop, tmpLvp;
2816 2828
@@ -2823,16 +2835,30 @@ void PwMDoc::ensureLvp()
2823 entrI = entrBegin; 2835 entrI = entrBegin;
2824 2836
2825 while (entrI != entrEnd) { 2837 while (entrI != entrEnd) {
2826 tmpLvp = entrI->listViewPos; 2838 tmpLvp = entrI->listViewPos;
2827 if (tmpLvp == -1) 2839 if (tmpLvp == -1)
2828 undefined.push_back(entrI); 2840 undefined.push_back(entrI);
2829 else if (tmpLvp > lvpTop) 2841 else
2830 lvpTop = tmpLvp; 2842 sorted[tmpLvp] = entrI;
2843 //US else if (tmpLvp > lvpTop)
2844 //US lvpTop = tmpLvp;
2831 ++entrI; 2845 ++entrI;
2832 } 2846 }
2847
2848 //now we have all undefied in the collection. Now insert the existing
2849 sortedBegin = sorted.begin();
2850 sortedEnd = sorted.end();
2851 sortedI = sortedBegin;
2852
2853 while (sortedI != sortedEnd) {
2854 tmpLvp = (*sortedI)->listViewPos;
2855 undefined[tmpLvp] = *sortedI;
2856 ++sortedI;
2857 }
2858
2833 undefBegin = undefined.begin(); 2859 undefBegin = undefined.begin();
2834 undefEnd = undefined.end(); 2860 undefEnd = undefined.end();
2835 undefI = undefBegin; 2861 undefI = undefBegin;
2836 while (undefI != undefEnd) { 2862 while (undefI != undefEnd) {
2837 (*undefI)->listViewPos = ++lvpTop; 2863 (*undefI)->listViewPos = ++lvpTop;
2838 ++undefI; 2864 ++undefI;
@@ -2845,12 +2871,22 @@ QString PwMDoc::getTitle()
2845{ 2871{
2846 /* NOTE: We have to ensure, that the returned title 2872 /* NOTE: We have to ensure, that the returned title
2847 * is unique and not reused somewhere else while 2873 * is unique and not reused somewhere else while
2848 * this document is valid (open). 2874 * this document is valid (open).
2849 */ 2875 */
2850 QString title(getFilename()); 2876 QString title(getFilename());
2877
2878 //US ENH: The whole filename on PDAs is too long. So use only the last characters
2879 if (QApplication::desktop()->width() < 640)
2880 {
2881 if (title.length() > 30)
2882 title = "..." + title.right(30);
2883
2884 }
2885
2886
2851 if (title.isEmpty()) { 2887 if (title.isEmpty()) {
2852 if (unnamedNum == 0) { 2888 if (unnamedNum == 0) {
2853 unnamedNum = PwMDocList::getNewUnnamedNumber(); 2889 unnamedNum = PwMDocList::getNewUnnamedNumber();
2854 PWM_ASSERT(unnamedNum != 0); 2890 PWM_ASSERT(unnamedNum != 0);
2855 } 2891 }
2856 title = DEFAULT_TITLE; 2892 title = DEFAULT_TITLE;
@@ -2924,13 +2960,13 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
2924 qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); 2960 qDebug("PwMDoc::syncronize : newly created local sync data could not be found");
2925 return e_syncError; 2961 return e_syncError;
2926 } 2962 }
2927 } 2963 }
2928 2964
2929 syncItemLocal = syncLocal->getSyncDataEntry(index); 2965 syncItemLocal = syncLocal->getSyncDataEntry(index);
2930 qDebug("Last Sync %s ", syncItemLocal->lastSyncDate.toString().latin1()); 2966 qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1());
2931 2967
2932 //Step 2. Find syncinfo in remote file and create if not existent. 2968 //Step 2. Find syncinfo in remote file and create if not existent.
2933 found = syncRemote->findSyncData(mCurrentSyncName, &index); 2969 found = syncRemote->findSyncData(mCurrentSyncName, &index);
2934 if (found == false) 2970 if (found == false)
2935 { 2971 {
2936 qDebug("FULLDATE 1"); 2972 qDebug("FULLDATE 1");
@@ -2944,39 +2980,40 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
2944 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); 2980 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found");
2945 return e_syncError; 2981 return e_syncError;
2946 } 2982 }
2947 } 2983 }
2948 2984
2949 syncItemRemote = syncRemote->getSyncDataEntry(index); 2985 syncItemRemote = syncRemote->getSyncDataEntry(index);
2986 qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1());
2950 //and remove the found entry here. We will reenter it later again. 2987 //and remove the found entry here. We will reenter it later again.
2951 //US syncRemote->delSyncDataEntry(index, true); 2988 //US syncRemote->delSyncDataEntry(index, true);
2952 2989
2953 2990
2954 if ( syncItemLocal->lastSyncDate == mLastSync ) { 2991 if ( syncItemLocal->lastSyncDate == mLastSync ) {
2955 qDebug("FULLDATE 2"); 2992 qDebug("FULLDATE 2");
2956 fullDateRange = true; 2993 fullDateRange = true;
2957 } 2994 }
2958 2995
2959 if ( ! fullDateRange ) { 2996 if ( ! fullDateRange ) {
2960 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { 2997 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) {
2961 2998
2962 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2999 // qDebug("set fulldate to true %s %s" ,syncItemLocal->lastSyncDate.toString().latin1(), syncItemRemote->lastSyncDate.toString().latin1() );
2963 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3000 // qDebug("%d %d %d %d ", syncItemLocal->lastSyncDate.time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2964 fullDateRange = true; 3001 fullDateRange = true;
2965 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); 3002 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() );
2966 } 3003 }
2967 } 3004 }
2968 // fullDateRange = true; // debug only! 3005 // fullDateRange = true; // debug only!
2969 if ( fullDateRange ) 3006 if ( fullDateRange )
2970 mLastSync = QDateTime::currentDateTime().addDays( -100*365); 3007 mLastSync = QDateTime::currentDateTime().addDays( -100*365);
2971 else 3008 else
2972 mLastSync = syncItemLocal->lastSyncDate; 3009 mLastSync = syncItemLocal->lastSyncDate;
2973 3010
2974 3011
2975 qDebug("*************************** "); 3012 qDebug("*************************** ");
2976 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3013 qDebug("mLastSync %s ",mLastSync.toString().latin1() );
2977 QStringList er = syncRemote->getIDEntryList(); 3014 QStringList er = syncRemote->getIDEntryList();
2978 PwMDataItem* inRemote ;//= er.first(); 3015 PwMDataItem* inRemote ;//= er.first();
2979 PwMDataItem* inLocal; 3016 PwMDataItem* inLocal;
2980 unsigned int catLocal, indexLocal; 3017 unsigned int catLocal, indexLocal;
2981 unsigned int catRemote, indexRemote; 3018 unsigned int catRemote, indexRemote;
2982 3019
@@ -2998,13 +3035,13 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
2998 3035
2999 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 3036 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
3000 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 3037 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
3001 PWM_ASSERT(inRemote); 3038 PWM_ASSERT(inRemote);
3002 if ( inLocal != 0 ) { // maybe conflict - same uid in both files 3039 if ( inLocal != 0 ) { // maybe conflict - same uid in both files
3003 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { 3040 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) {
3004 //qDebug("take %d %s ", take, inL.summary().latin1()); 3041 qDebug("take %d %s ", take, inLocal->desc.c_str());
3005 if ( take == 3 ) 3042 if ( take == 3 )
3006 return e_syncError; 3043 return e_syncError;
3007 if ( take == 1 ) {// take local 3044 if ( take == 1 ) {// take local
3008 //US syncRemote->removeAddressee( inRemote ); 3045 //US syncRemote->removeAddressee( inRemote );
3009 (*inRemote) = (*inLocal); 3046 (*inRemote) = (*inLocal);
3010 //US syncRemote->insertAddressee( inRemote , false); 3047 //US syncRemote->insertAddressee( inRemote , false);
@@ -3049,12 +3086,13 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s
3049 qApp->processEvents(); 3086 qApp->processEvents();
3050 if (manager->isProgressBarCanceled()) 3087 if (manager->isProgressBarCanceled())
3051 return e_syncError; 3088 return e_syncError;
3052 if ( incCounter % modulo == 0 ) 3089 if ( incCounter % modulo == 0 )
3053 manager->showProgressBar(incCounter); 3090 manager->showProgressBar(incCounter);
3054 uid = el[ incCounter ]; 3091 uid = el[ incCounter ];
3092 qDebug("sync uid %s from local file", uid.latin1());
3055 3093
3056 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 3094 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
3057 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 3095 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
3058 PWM_ASSERT(inLocal); 3096 PWM_ASSERT(inLocal);
3059 3097
3060 if ( inRemote == 0 ) { 3098 if ( inRemote == 0 ) {
@@ -3129,22 +3167,22 @@ int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime
3129 return 0; 3167 return 0;
3130 3168
3131 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); 3169 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() );
3132 3170
3133 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 3171 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
3134 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 3172 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
3135 //full = true; //debug only 3173 full = true; //debug only
3136 if ( full ) { 3174 if ( full ) {
3137 bool equ = true;//US ( (*local) == (*remote) ); 3175 bool equ = ( (*local) == (*remote) );
3138 if ( equ ) { 3176 if ( equ ) {
3139 //qDebug("equal "); 3177 qDebug("equal ");
3140 if ( mode < SYNC_PREF_FORCE_LOCAL ) 3178 if ( mode < SYNC_PREF_FORCE_LOCAL )
3141 return 0; 3179 return 0;
3142 3180
3143 }//else //debug only 3181 }else //debug only
3144 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 3182 qDebug("not equal %s %s ", local->desc.c_str(), remote->desc.c_str());
3145 } 3183 }
3146 3184
3147 int result; 3185 int result;
3148 bool localIsNew; 3186 bool localIsNew;
3149 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 3187 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
3150 3188
@@ -3212,13 +3250,13 @@ bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
3212 if (this->isDeepLocked()) { 3250 if (this->isDeepLocked()) {
3213 PwMerror ret = this->deepLock(false); 3251 PwMerror ret = this->deepLock(false);
3214 if (ret != e_success) 3252 if (ret != e_success)
3215 return false; 3253 return false;
3216 } 3254 }
3217 3255
3218 //2) construct and open a new doc on the stack(automatic cleanup) for remote file. 3256 //2) construct and open a new doc on the stack(automatic cleanup of remote file).
3219 PwMDoc syncTarget(this, "synctarget"); 3257 PwMDoc syncTarget(this, "synctarget");
3220 PwMDoc* pSyncTarget = &syncTarget; 3258 PwMDoc* pSyncTarget = &syncTarget;
3221 3259
3222 3260
3223 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); 3261 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/);
3224 3262
@@ -3264,29 +3302,12 @@ bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
3264 } 3302 }
3265 else { 3303 else {
3266 return false; 3304 return false;
3267 } 3305 }
3268} 3306}
3269 3307
3270//called by the syncmanager to indicate that the work has to marked as dirty.
3271void PwMDoc::sync_setModified()
3272{
3273 flagDirty();
3274}
3275
3276//called by the syncmanager to ask if the dirty flag is set.
3277bool PwMDoc::sync_isModified()
3278{
3279 return isDirty();
3280}
3281
3282//called by the syncmanager to indicate that the work has to be saved.
3283void PwMDoc::sync_save()
3284{
3285 saveDoc(conf()->confGlobCompression());
3286}
3287#endif 3308#endif
3288 3309
3289 3310
3290bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) 3311bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index)
3291{ 3312{
3292 vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), 3313 vector<PwMSyncItem>::iterator i = dti.syncDta.begin(),
diff --git a/pwmanager/pwmanager/pwmdoc.h b/pwmanager/pwmanager/pwmdoc.h
index 2e9547e..6a1dd30 100644
--- a/pwmanager/pwmanager/pwmdoc.h
+++ b/pwmanager/pwmanager/pwmdoc.h
@@ -127,22 +127,12 @@ struct PwMMetaData
127 expire = QDateTime(); 127 expire = QDateTime();
128 update = QDateTime(); 128 update = QDateTime();
129 updateInt = 0; 129 updateInt = 0;
130 uniqueid = KApplication::randomString(8); 130 uniqueid = KApplication::randomString(8);
131 } 131 }
132 132
133 PwMMetaData& operator = (const PwMMetaData& x)
134 {
135 create = x.create;
136 expire = x.expire;
137 update = x.update;
138 updateInt = x.updateInt;
139 uniqueid = x.uniqueid;
140 return *this;
141 }
142
143 inline bool isValid() const 133 inline bool isValid() const
144 { 134 {
145 if (valid.isNull()) 135 if (valid.isNull())
146 return true; 136 return true;
147 return (valid < QDateTime::currentDateTime()); 137 return (valid < QDateTime::currentDateTime());
148 } 138 }
@@ -214,24 +204,40 @@ struct PwMDataItem
214 lockStat = true; 204 lockStat = true;
215 listViewPos = -1; 205 listViewPos = -1;
216 binary = false; 206 binary = false;
217 if (clearMeta) 207 if (clearMeta)
218 meta.clear(); 208 meta.clear();
219 } 209 }
220 210 //US ENH: we need this operator to compare two items if we have no unique ids
211 //available. Generaly this happens before the first sync
212 bool PwMDataItem::operator==( const PwMDataItem &a ) const
213 {
214 qDebug("oper==%s", a.desc.c_str());
215 if ( desc != a.desc ) return false;
216 if ( name != a.name ) return false;
217 if ( pw != a.pw ) return false;
218 if ( comment != a.comment ) return false;
219 if ( url != a.url ) return false;
220 if ( launcher != a.launcher ) return false;
221 //all other field will not be checked.
222 return true;
223 }
224
225 //US ENH:this operator is used to copy an elements data during syncronization
226 //Attention: listViewPos will not be copied. So the position will stay the same.
221 PwMDataItem& operator = (const PwMDataItem& x) 227 PwMDataItem& operator = (const PwMDataItem& x)
222 { 228 {
223 qDebug("oper=%s", x.desc.c_str()); 229 // qDebug("oper=%s", x.desc.c_str());
224 desc = x.desc; 230 desc = x.desc;
225 name = x.name; 231 name = x.name;
226 pw = x.pw; 232 pw = x.pw;
227 comment = x.comment; 233 comment = x.comment;
228 url = x.url; 234 url = x.url;
229 launcher = x.launcher; 235 launcher = x.launcher;
230 lockStat = x.lockStat; 236 lockStat = x.lockStat;
231 listViewPos = x.listViewPos; 237 //Do not copy listViewPos!!! listViewPos = x.listViewPos;
232 binary = x.binary; 238 binary = x.binary;
233 meta = x.meta; 239 meta = x.meta;
234 rev = x.rev; 240 rev = x.rev;
235 return *this; 241 return *this;
236 } 242 }
237 243
@@ -771,19 +777,12 @@ protected:
771 // 3 cancel 777 // 3 cancel
772 int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ); 778 int takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full );
773 779
774 //the following methods are the overwritten callbackmethods from the syncinterface 780 //the following methods are the overwritten callbackmethods from the syncinterface
775 virtual bool sync(KSyncManager* manager, QString filename, int mode); 781 virtual bool sync(KSyncManager* manager, QString filename, int mode);
776 782
777 //called by the syncmanager to indicate that the work has to be marked as dirty.
778 virtual void sync_setModified();
779 //called by the syncmanager to ask if the dirty flag is set.
780 virtual bool sync_isModified();
781 //called by the syncmanager to indicate that the work has to be saved.
782 virtual void sync_save();
783
784#endif 783#endif
785 private: 784 private:
786 //US ENH: helpermethods to access the sync data for a certain syncname. 785 //US ENH: helpermethods to access the sync data for a certain syncname.
787 // It returns the syncdatas index 786 // It returns the syncdatas index
788 bool findSyncData(const QString &syncname, unsigned int *index); 787 bool findSyncData(const QString &syncname, unsigned int *index);
789 788
diff --git a/pwmanager/pwmanager/pwmview.cpp b/pwmanager/pwmanager/pwmview.cpp
index e23ce25..e53124f 100644
--- a/pwmanager/pwmanager/pwmview.cpp
+++ b/pwmanager/pwmanager/pwmview.cpp
@@ -453,17 +453,97 @@ void PwMView::copyCommentToClip()
453 return; 453 return;
454 PwMDataItem d; 454 PwMDataItem d;
455 document()->getEntry(getCurrentCategory(), curIndex, &d); 455 document()->getEntry(getCurrentCategory(), curIndex, &d);
456 PwM::copyToClipboard(d.comment.c_str()); 456 PwM::copyToClipboard(d.comment.c_str());
457} 457}
458 458
459/************************************************************************
460 *
461 *
462 *
463 ************************************************************************/
464
465
466PwMDataItemView::PwMDataItemView( QWidget *parent, const char *name )
467 : QTextBrowser( parent, name )
468
469
470{
471//US setWrapPolicy( QTextEdit::AtWordBoundary );
472 setLinkUnderline( false );
473 // setVScrollBarMode( QScrollView::AlwaysOff );
474 //setHScrollBarMode( QScrollView::AlwaysOff );
475
476//US QStyleSheet *sheet = styleSheet();
477//US QStyleSheetItem *link = sheet->item( "a" );
478//US link->setColor( KGlobalSettings::linkColor() );
479
480}
481
482void PwMDataItemView::setPwMDataItem( const PwMDataItem& a )
483
484{
485 mItem = a;
486 // clear view
487 setText( QString::null );
488
489
490 QString dynamicPart;
491 QString format = "<tr><td align=\"right\"><b>%1</b></td>"
492 "<td align=\"left\">%2</td></tr>";
493
494 dynamicPart += format
495 .arg( i18n("Description") )
496 .arg( mItem.desc.c_str() );
459 497
498 dynamicPart += format
499 .arg( i18n("Name") )
500 .arg( mItem.name.c_str() );
501
502 dynamicPart += format
503 .arg( i18n("Password") )
504 .arg( mItem.pw.c_str() );
505
506 QString comment(mItem.pw.c_str());
507 dynamicPart += format
508 .arg( i18n("Comment") )
509 .arg( comment.replace( QRegExp("\n"), "<br>" ) );
510
511 dynamicPart += format
512 .arg( i18n("URL") )
513 .arg( mItem.url.c_str() );
514
515 dynamicPart += format
516 .arg( i18n("Launcher") )
517 .arg( mItem.launcher.c_str() );
518
519 QString mText = "<table><td colspan=\"2\">&nbsp;</td>";
520
521 mText += dynamicPart;
522 mText += "</table>";
523
524 // at last display it...
525 setText( mText );
526
527}
528
529PwMDataItem PwMDataItemView::pwmdataitem() const
530{
531 return mItem;
532}
533
534/************************************************************************
535 *
536 *
537 *
538 ************************************************************************/
460 539
461 540
462PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, 541PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool takeloc, QWidget *parent, const char *name )
463 true ,i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false) 542 : KDialogBase(parent, name, true ,
543 i18n("Conflict! Please choose Entry!"),Ok|User1|Close,Close, false)
464{ 544{
465 findButton( Close )->setText( i18n("Cancel Sync")); 545 findButton( Close )->setText( i18n("Cancel Sync"));
466 findButton( Ok )->setText( i18n("Remote")); 546 findButton( Ok )->setText( i18n("Remote"));
467 findButton( User1 )->setText( i18n("Local")); 547 findButton( User1 )->setText( i18n("Local"));
468 QWidget* topframe = new QWidget( this ); 548 QWidget* topframe = new QWidget( this );
469 setMainWidget( topframe ); 549 setMainWidget( topframe );
@@ -475,21 +555,21 @@ PwMDataItemChooser::PwMDataItemChooser( PwMDataItem loc, PwMDataItem rem, bool t
475 } 555 }
476 QVBox* subframe = new QVBox( topframe ); 556 QVBox* subframe = new QVBox( topframe );
477 bl->addWidget(subframe ); 557 bl->addWidget(subframe );
478 QLabel* lab = new QLabel( i18n("Local Entry"), subframe ); 558 QLabel* lab = new QLabel( i18n("Local Entry"), subframe );
479 if ( takeloc ) 559 if ( takeloc )
480 lab->setBackgroundColor(Qt::green.light() ); 560 lab->setBackgroundColor(Qt::green.light() );
481 // AddresseeView * av = new AddresseeView( subframe ); 561 PwMDataItemView * av = new PwMDataItemView( subframe );
482 // av->setAddressee( loc ); 562 av->setPwMDataItem( loc );
483 subframe = new QVBox( topframe ); 563 subframe = new QVBox( topframe );
484 bl->addWidget(subframe ); 564 bl->addWidget(subframe );
485 lab = new QLabel( i18n("Remote Entry"), subframe ); 565 lab = new QLabel( i18n("Remote Entry"), subframe );
486 if ( !takeloc ) 566 if ( !takeloc )
487 lab->setBackgroundColor(Qt::green.light() ); 567 lab->setBackgroundColor(Qt::green.light() );
488 // av = new AddresseeView( subframe ); 568 av = new PwMDataItemView( subframe );
489 // av->setAddressee( rem ); 569 av->setPwMDataItem( rem );
490 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); 570 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
491 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); 571 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
492#ifndef DESKTOP_VERSION 572#ifndef DESKTOP_VERSION
493 showMaximized(); 573 showMaximized();
494#else 574#else
495 resize ( 640, 400 ); 575 resize ( 640, 400 );
diff --git a/pwmanager/pwmanager/pwmview.h b/pwmanager/pwmanager/pwmview.h
index 75cce51..e42b17a 100644
--- a/pwmanager/pwmanager/pwmview.h
+++ b/pwmanager/pwmanager/pwmview.h
@@ -38,12 +38,13 @@
38#include <klocale.h> 38#include <klocale.h>
39#include <kdialogbase.h> 39#include <kdialogbase.h>
40 40
41#include <qevent.h> 41#include <qevent.h>
42#include <qfont.h> 42#include <qfont.h>
43#include <qobject.h> 43#include <qobject.h>
44#include <qtextbrowser.h>
44 45
45#include <vector> 46#include <vector>
46#include <string> 47#include <string>
47 48
48using std::string; 49using std::string;
49using std::vector; 50using std::vector;
@@ -146,12 +147,36 @@ private:
146 PwMDoc *doc; 147 PwMDoc *doc;
147 /** pointer to the main class "PwM" */ 148 /** pointer to the main class "PwM" */
148 PwM *mainClass; 149 PwM *mainClass;
149}; 150};
150 151
151 152
153//US ENH basic widget to view an password entry. We need it for the sync stuff.
154//But might be oif interest for other functionalities as well.
155class PwMDataItemView : public QTextBrowser
156{
157 public:
158 PwMDataItemView( QWidget *parent = 0, const char *name = 0 );
159
160 /**
161 Sets the PwMDataItem object. It is displayed immediately.
162
163 @param a The PwMDataItem object.
164 */
165 void setPwMDataItem( const PwMDataItem& a );
166
167 /**
168 Returns the current PwMDataItem object.
169 */
170 PwMDataItem pwmdataitem() const;
171
172 private:
173 PwMDataItem mItem;
174};
175
176
152//US ENH we need this chooser when syncing results in a conflict 177//US ENH we need this chooser when syncing results in a conflict
153class PwMDataItemChooser : public KDialogBase 178class PwMDataItemChooser : public KDialogBase
154{ 179{
155 Q_OBJECT 180 Q_OBJECT
156 181
157 public: 182 public:
diff --git a/pwmanager/pwmanager/serializer.cpp b/pwmanager/pwmanager/serializer.cpp
index 203f82c..5c6568f 100644
--- a/pwmanager/pwmanager/serializer.cpp
+++ b/pwmanager/pwmanager/serializer.cpp
@@ -24,13 +24,13 @@
24#ifdef PWM_EMBEDDED 24#ifdef PWM_EMBEDDED
25#include <kglobal.h> 25#include <kglobal.h>
26#include <klocale.h> 26#include <klocale.h>
27#endif 27#endif
28 28
29/* enable/disable serializer debugging (0/1) */ 29/* enable/disable serializer debugging (0/1) */
30 #define SERIALIZER_DEBUG0 30 #define SERIALIZER_DEBUG1
31/* use the old xml tags for writing (0/1) */ 31/* use the old xml tags for writing (0/1) */
32 #define USE_OLD_TAGS 0 32 #define USE_OLD_TAGS 0
33/* write a CDATA section (0/1) */ 33/* write a CDATA section (0/1) */
34 #define WRITE_CDATA_SEC 0 34 #define WRITE_CDATA_SEC 0
35 35
36 36
@@ -301,12 +301,16 @@ bool Serializer::readEntries(const QDomNode &n,
301 vector<PwMDataItem> *dta) 301 vector<PwMDataItem> *dta)
302{ 302{
303 QDomNodeList nl(n.childNodes()); 303 QDomNodeList nl(n.childNodes());
304 QDomNode cur; 304 QDomNode cur;
305 unsigned int numEntr = nl.count(), i; 305 unsigned int numEntr = nl.count(), i;
306 PwMDataItem curEntr; 306 PwMDataItem curEntr;
307 //US BUG: to initialize all values of curEntr with meaningfulldata,
308 // we call clear on it. Reason: Information in the file we will read might be incomplete.
309 // e.g. the metadata is missing.
310 curEntr.clear(true);
307 311
308 dta->clear(); 312 dta->clear();
309 for (i = 0; i < numEntr; ++i) { 313 for (i = 0; i < numEntr; ++i) {
310 cur = nl.item(i); 314 cur = nl.item(i);
311 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW || 315 if (cur.nodeName().left(1) == ENTRY_PREFIX_NEW ||
312 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) { 316 cur.nodeName().left(6) == ENTRY_PREFIX_OLD) {
@@ -398,56 +402,57 @@ bool Serializer::extractMeta(const QDomNode &n,
398 name = cur.nodeName(); 402 name = cur.nodeName();
399 val = cur.toElement().text(); 403 val = cur.toElement().text();
400 if (val == "") { 404 if (val == "") {
401 cur = cur.nextSibling(); 405 cur = cur.nextSibling();
402 continue; 406 continue;
403 } 407 }
408
409 //US BUG: The transformation of an empty date into an ISO date and back is different on different systems/compilers.
410 //because of that it is possible that here some values are not set, which means they are null.
411 //US ENH: at the same moment we need backwardcompatibility. So older versions might have stored invalid dates.
412
413 QDateTime dtval; //dtval should be invalid by definition.
414
415 if ((name == META_CREATE_DATE) ||
416 (name == META_VALID_DATE) ||
417 (name == META_EXPIRE_DATE) ||
418 (name == META_UPDATE_DATE))
419 {
420 //qDebug("Serializer::extractMeta:: val:%s, empty:%i, length:%i",val.utf8(), val.isEmpty(), val.length());
421
404#ifndef PWM_EMBEDDED 422#ifndef PWM_EMBEDDED
405 if (name == META_CREATE_DATE) { 423 dtval = QDateTime::fromString(val, Qt::ISODate);
406 dta->create = QDateTime::fromString(val, Qt::ISODate);
407 } else if (name == META_VALID_DATE) {
408 dta->valid = QDateTime::fromString(val, Qt::ISODate);
409 } else if (name == META_EXPIRE_DATE) {
410 dta->expire = QDateTime::fromString(val, Qt::ISODate);
411 } else if (name == META_UPDATE_DATE) {
412 dta->update = QDateTime::fromString(val, Qt::ISODate);
413 } else if (name == META_UPDATE_INT) {
414 dta->updateInt = strtoul(val.latin1(), 0, 10);
415 } else if (name == META_UNIQUEID) {
416 dta->uniqueid = unescapeEntryData(val).latin1();
417 } else {
418 printDebug(string("extractMeta(): invalid: ")
419 + name.latin1());
420 }
421#else 424#else
425 bool ok;
426 dtval = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok);
427
428 if (ok == false)
429 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
430#endif
422 431
432 //if the parsed data is wrong, dtval should be invalid at this time.
423 433
424 bool ok = true; 434 }
425 435
426 if (name == META_CREATE_DATE) { 436 if (name == META_CREATE_DATE) {
427 dta->create = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); 437 dta->create = dtval;
428 } else if (name == META_VALID_DATE) { 438 } else if (name == META_VALID_DATE) {
429 dta->valid = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); 439 dta->valid = dtval;
430 } else if (name == META_EXPIRE_DATE) { 440 } else if (name == META_EXPIRE_DATE) {
431 dta->expire = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); 441 dta->expire = dtval;
432 } else if (name == META_UPDATE_DATE) { 442 } else if (name == META_UPDATE_DATE) {
433 dta->update = KGlobal::locale()->readDateTime(val, KLocale::ISODate, &ok); 443 dta->update = dtval;
434 } else if (name == META_UPDATE_INT) { 444 } else if (name == META_UPDATE_INT) {
435 dta->updateInt = strtoul(val.latin1(), 0, 10); 445 dta->updateInt = strtoul(val.latin1(), 0, 10);
436 } else if (name == META_UNIQUEID) { 446 } else if (name == META_UNIQUEID) {
437 dta->uniqueid = unescapeEntryData(val).latin1(); 447 dta->uniqueid = unescapeEntryData(val).latin1();
438 } else { 448 } else {
439 printDebug(string("extractMeta(): invalid: ") 449 printDebug(string("extractMeta(): invalid: ")
440 + name.latin1()); 450 + name.latin1());
441 } 451 }
442 452
443 if (ok == false)
444 qDebug("Serializer::extractMeta invalid date or time !!!!!!!!!!!!!");
445
446
447#endif
448 cur = cur.nextSibling(); 453 cur = cur.nextSibling();
449 } 454 }
450 return true; 455 return true;
451} 456}
452 457
453bool Serializer::checkValid() 458bool Serializer::checkValid()
@@ -601,47 +606,67 @@ bool Serializer::writeEntry(QDomElement *e,
601bool Serializer::writeMeta(QDomElement *e, 606bool Serializer::writeMeta(QDomElement *e,
602 const PwMMetaData &dta) 607 const PwMMetaData &dta)
603{ 608{
604 QDomText text; 609 QDomText text;
605 QDomElement tag; 610 QDomElement tag;
606 611
607 tag = domDoc->createElement(META_CREATE_DATE); 612 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
613 //So do not transform an empty value at all.
614 if (dta.create.isValid())
615 {
616 tag = domDoc->createElement(META_CREATE_DATE);
608#ifndef PWM_EMBEDDED 617#ifndef PWM_EMBEDDED
609 text = domDoc->createTextNode(dta.create.toString(Qt::ISODate)); 618 text = domDoc->createTextNode(dta.create.toString(Qt::ISODate));
610#else 619#else
611 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.create, KLocale::ISODate)); 620 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.create, KLocale::ISODate));
612#endif 621#endif
613 tag.appendChild(text); 622 tag.appendChild(text);
614 e->appendChild(tag); 623 e->appendChild(tag);
624 }
615 625
616 tag = domDoc->createElement(META_VALID_DATE); 626 //US BUG!!!: The transformation of an empty date into an ISO date is different on different systems/compilers.
627 //So do not transform an empty value at all.
628 if (dta.valid.isValid())
629 {
630 tag = domDoc->createElement(META_VALID_DATE);
617#ifndef PWM_EMBEDDED 631#ifndef PWM_EMBEDDED
618 text = domDoc->createTextNode(dta.valid.toString(Qt::ISODate)); 632 text = domDoc->createTextNode(dta.valid.toString(Qt::ISODate));
619#else 633#else
620 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.valid, KLocale::ISODate)); 634 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.valid, KLocale::ISODate));
621#endif 635#endif
622 tag.appendChild(text); 636 tag.appendChild(text);
623 e->appendChild(tag); 637 e->appendChild(tag);
638 }
624 639
625 tag = domDoc->createElement(META_EXPIRE_DATE); 640 //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.
642 if (dta.expire.isValid())
643 {
644 tag = domDoc->createElement(META_EXPIRE_DATE);
626#ifndef PWM_EMBEDDED 645#ifndef PWM_EMBEDDED
627 text = domDoc->createTextNode(dta.expire.toString(Qt::ISODate)); 646 text = domDoc->createTextNode(dta.expire.toString(Qt::ISODate));
628#else 647#else
629 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.expire, KLocale::ISODate)); 648 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.expire, KLocale::ISODate));
630#endif 649#endif
631 tag.appendChild(text); 650 tag.appendChild(text);
632 e->appendChild(tag); 651 e->appendChild(tag);
652 }
633 653
634 tag = domDoc->createElement(META_UPDATE_DATE); 654 //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.
656 if (dta.update.isValid())
657 {
658 tag = domDoc->createElement(META_UPDATE_DATE);
635#ifndef PWM_EMBEDDED 659#ifndef PWM_EMBEDDED
636 text = domDoc->createTextNode(dta.update.toString(Qt::ISODate)); 660 text = domDoc->createTextNode(dta.update.toString(Qt::ISODate));
637#else 661#else
638 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.update, KLocale::ISODate)); 662 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta.update, KLocale::ISODate));
639#endif 663#endif
640 tag.appendChild(text); 664 tag.appendChild(text);
641 e->appendChild(tag); 665 e->appendChild(tag);
666 }
642 667
643 tag = domDoc->createElement(META_UPDATE_INT); 668 tag = domDoc->createElement(META_UPDATE_INT);
644 text = domDoc->createTextNode(tostr(dta.updateInt).c_str()); 669 text = domDoc->createTextNode(tostr(dta.updateInt).c_str());
645 tag.appendChild(text); 670 tag.appendChild(text);
646 e->appendChild(tag); 671 e->appendChild(tag);
647 672
@@ -669,13 +694,13 @@ QString Serializer::escapeEntryData(QString dta)
669QString Serializer::unescapeEntryData(QString dta) 694QString Serializer::unescapeEntryData(QString dta)
670{ 695{
671#ifndef PWM_EMBEDDED 696#ifndef PWM_EMBEDDED
672 dta.replace("$>--endl--<$", "\n"); 697 dta.replace("$>--endl--<$", "\n");
673 dta.replace("||>", "]]>"); 698 dta.replace("||>", "]]>");
674#else 699#else
675 dta.replace(QRegExp("$>--endl--<$"), "\n"); 700 dta.replace(QRegExp("\\$>--endl--<\\$"), "\n");
676 dta.replace(QRegExp("||>"), "]]>"); 701 dta.replace(QRegExp("||>"), "]]>");
677#endif 702#endif
678 return dta; 703 return dta;
679} 704}
680 705
681 706
@@ -727,13 +752,13 @@ bool Serializer::readSyncData(const QDomNode &n, vector<PwMSyncItem> *dta)
727 752
728bool Serializer::addSyncData(QDomElement *e, 753bool Serializer::addSyncData(QDomElement *e,
729 const vector<PwMSyncItem> &dta) 754 const vector<PwMSyncItem> &dta)
730{ 755{
731 unsigned int numSync = dta.size(), i; 756 unsigned int numSync = dta.size(), i;
732 QString curId, curDeviceName; 757 QString curId, curDeviceName;
733 QDomElement curSync, curSyncDate; 758 QDomElement curSync;
734 QDomText text; 759 QDomText text;
735 760
736 for (i = 0; i < numSync; ++i) { 761 for (i = 0; i < numSync; ++i) {
737 curId = SYNC_TARGET_PREFIX; 762 curId = SYNC_TARGET_PREFIX;
738 curId += tostr(i).c_str(); 763 curId += tostr(i).c_str();
739 curDeviceName = dta[i].syncName.c_str(); 764 curDeviceName = dta[i].syncName.c_str();
@@ -742,14 +767,13 @@ bool Serializer::addSyncData(QDomElement *e,
742 767
743#ifndef PWM_EMBEDDED 768#ifndef PWM_EMBEDDED
744 text = domDoc->createTextNode(dta[i].lastSyncDate.toString(Qt::ISODate)); 769 text = domDoc->createTextNode(dta[i].lastSyncDate.toString(Qt::ISODate));
745#else 770#else
746 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate)); 771 text = domDoc->createTextNode(KGlobal::locale()->formatDateTime(dta[i].lastSyncDate, KLocale::ISODate));
747#endif 772#endif
748 curSyncDate.appendChild(text); 773 curSync.appendChild(text);
749 curSync.appendChild(curSyncDate);
750 774
751 e->appendChild(curSync); 775 e->appendChild(curSync);
752 776
753 } 777 }
754 return true; 778 return true;
755} 779}