Diffstat (limited to 'pwmanager/pwmanager/pwmdoc.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | pwmanager/pwmanager/pwmdoc.cpp | 85 |
1 files changed, 53 insertions, 32 deletions
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 | |||
@@ -488,5 +488,6 @@ PwMerror PwMDoc::saveDoc(char compress, const QString *file) | |||
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: " |
@@ -606,5 +607,7 @@ PwMerror PwMDoc::writeFileHeader(char keyHash, char dataHash, char crypt, char c | |||
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))) { |
@@ -2805,8 +2808,17 @@ void PwMDoc::ensureLvp() | |||
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(), |
@@ -2827,8 +2839,22 @@ void PwMDoc::ensureLvp() | |||
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(); |
@@ -2849,4 +2875,14 @@ QString PwMDoc::getTitle() | |||
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) { |
@@ -2928,5 +2964,5 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
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. |
@@ -2948,4 +2984,5 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
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); |
@@ -2960,6 +2997,6 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
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() ); |
@@ -2974,5 +3011,5 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
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(); |
@@ -3002,5 +3039,5 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
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; |
@@ -3053,4 +3090,5 @@ PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* s | |||
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 ); |
@@ -3133,14 +3171,14 @@ int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime | |||
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 | ||
@@ -3216,5 +3254,5 @@ bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) | |||
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; |
@@ -3268,21 +3306,4 @@ bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) | |||
3268 | } | 3306 | } |
3269 | 3307 | ||
3270 | //called by the syncmanager to indicate that the work has to marked as dirty. | ||
3271 | void PwMDoc::sync_setModified() | ||
3272 | { | ||
3273 | flagDirty(); | ||
3274 | } | ||
3275 | |||
3276 | //called by the syncmanager to ask if the dirty flag is set. | ||
3277 | bool PwMDoc::sync_isModified() | ||
3278 | { | ||
3279 | return isDirty(); | ||
3280 | } | ||
3281 | |||
3282 | //called by the syncmanager to indicate that the work has to be saved. | ||
3283 | void PwMDoc::sync_save() | ||
3284 | { | ||
3285 | saveDoc(conf()->confGlobCompression()); | ||
3286 | } | ||
3287 | #endif | 3308 | #endif |
3288 | 3309 | ||