summaryrefslogtreecommitdiffabout
path: root/pwmanager/pwmanager/pwmdoc.cpp
Unidiff
Diffstat (limited to 'pwmanager/pwmanager/pwmdoc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index e29e3d1..8869f3a 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -2236,194 +2236,194 @@ bool PwMDoc::execLauncher(unsigned int category, unsigned int entryIndex)
2236#else 2236#else
2237 command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str()); 2237 command.replace(QRegExp("$d"), dti.dta[category].d[entryIndex].desc.c_str());
2238 command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str()); 2238 command.replace(QRegExp("$n"), dti.dta[category].d[entryIndex].name.c_str());
2239 command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str()); 2239 command.replace(QRegExp("$p"), dti.dta[category].d[entryIndex].pw.c_str());
2240 command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str()); 2240 command.replace(QRegExp("$u"), dti.dta[category].d[entryIndex].url.c_str());
2241 command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str()); 2241 command.replace(QRegExp("$c"), dti.dta[category].d[entryIndex].comment.c_str());
2242#endif 2242#endif
2243 command.append(" &"); 2243 command.append(" &");
2244 2244
2245 QString customXterm(conf()->confGlobXtermCommand()); 2245 QString customXterm(conf()->confGlobXtermCommand());
2246 if (!customXterm.isEmpty()) 2246 if (!customXterm.isEmpty())
2247 command = customXterm + " " + command; 2247 command = customXterm + " " + command;
2248 2248
2249 system(command.latin1()); 2249 system(command.latin1());
2250 2250
2251 lockAt(category, entryIndex, wasLocked); 2251 lockAt(category, entryIndex, wasLocked);
2252 return true; 2252 return true;
2253} 2253}
2254 2254
2255bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex) 2255bool PwMDoc::goToURL(const QString &category, unsigned int entryIndex)
2256{ 2256{
2257 unsigned int cat = 0; 2257 unsigned int cat = 0;
2258 2258
2259 if (!findCategory(category, &cat)) 2259 if (!findCategory(category, &cat))
2260 return false; 2260 return false;
2261 2261
2262 return goToURL(cat, entryIndex); 2262 return goToURL(cat, entryIndex);
2263} 2263}
2264 2264
2265bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex) 2265bool PwMDoc::goToURL(unsigned int category, unsigned int entryIndex)
2266{ 2266{
2267 if (geteuid() == 0) { 2267 if (geteuid() == 0) {
2268 rootAlertMsgBox(); 2268 rootAlertMsgBox();
2269 return false; 2269 return false;
2270 } 2270 }
2271 QString url(dti.dta[category].d[entryIndex].url.c_str()); 2271 QString url(dti.dta[category].d[entryIndex].url.c_str());
2272 if (url.isEmpty()) 2272 if (url.isEmpty())
2273 return false; 2273 return false;
2274 2274
2275 QString customBrowser(conf()->confGlobBrowserCommand()); 2275 QString customBrowser(conf()->confGlobBrowserCommand());
2276 if (!customBrowser.isEmpty()) { 2276 if (!customBrowser.isEmpty()) {
2277 browserProc.clearArguments(); 2277 browserProc.clearArguments();
2278 browserProc << customBrowser << url; 2278 browserProc << customBrowser << url;
2279 if (browserProc.start(KProcess::DontCare)) 2279 if (browserProc.start(KProcess::DontCare))
2280 return true; 2280 return true;
2281 } 2281 }
2282 2282
2283 browserProc.clearArguments(); 2283 browserProc.clearArguments();
2284 browserProc << "konqueror" << url; 2284 browserProc << "konqueror" << url;
2285 if (browserProc.start(KProcess::DontCare)) 2285 if (browserProc.start(KProcess::DontCare))
2286 return true; 2286 return true;
2287 2287
2288 browserProc.clearArguments(); 2288 browserProc.clearArguments();
2289 browserProc << "mozilla" << url; 2289 browserProc << "mozilla" << url;
2290 if (browserProc.start(KProcess::DontCare)) 2290 if (browserProc.start(KProcess::DontCare))
2291 return true; 2291 return true;
2292 2292
2293 browserProc.clearArguments(); 2293 browserProc.clearArguments();
2294 browserProc << "opera" << url; 2294 browserProc << "opera" << url;
2295 if (browserProc.start(KProcess::DontCare)) 2295 if (browserProc.start(KProcess::DontCare))
2296 return true; 2296 return true;
2297 return false; 2297 return false;
2298} 2298}
2299 2299
2300PwMerror PwMDoc::exportToText(const QString *file) 2300PwMerror PwMDoc::exportToText(const QString *file)
2301{ 2301{
2302 PWM_ASSERT(file); 2302 PWM_ASSERT(file);
2303 if (QFile::exists(*file)) { 2303 if (QFile::exists(*file)) {
2304 if (!QFile::remove(*file)) 2304 if (!QFile::remove(*file))
2305 return e_accessFile; 2305 return e_accessFile;
2306 } 2306 }
2307 QFile f(*file); 2307 QFile f(*file);
2308 if (!f.open(IO_ReadWrite)) 2308 if (!f.open(IO_ReadWrite))
2309 return e_openFile; 2309 return e_openFile;
2310 2310
2311 if (!unlockAll_tempoary()) { 2311 if (!unlockAll_tempoary()) {
2312 f.close(); 2312 f.close();
2313 return e_lock; 2313 return e_lock;
2314 } 2314 }
2315 2315
2316 // write header 2316 // write header
2317 string header = i18n("Password table generated by\nPwM v").latin1(); 2317 string header = i18n("Password table generated by\nPwM v").latin1();
2318 header += PACKAGE_VER; 2318 header += PACKAGE_VER;
2319 header += i18n("\non ").latin1(); 2319 header += i18n("\non ").latin1();
2320 QDate currDate = QDate::currentDate(); 2320 QDate currDate = QDate::currentDate();
2321 QTime currTime = QTime::currentTime(); 2321 QTime currTime = QTime::currentTime();
2322 2322
2323#ifndef PWM_EMBEDDED 2323#ifndef PWM_EMBEDDED
2324 header += currDate.toString("ddd MMMM d ").latin1(); 2324 header += currDate.toString("ddd MMMM d ").latin1();
2325 header += currTime.toString("hh:mm:ss ").latin1(); 2325 header += currTime.toString("hh:mm:ss ").latin1();
2326#else 2326#else
2327 QString dfs = KGlobal::locale()->dateFormatShort(); 2327 QString dfs = KGlobal::locale()->dateFormatShort();
2328 bool ampm = KGlobal::locale()->use12Clock(); 2328 bool ampm = KGlobal::locale()->use12Clock();
2329 KGlobal::locale()->setDateFormatShort("%A %B %d"); 2329 KGlobal::locale()->setDateFormatShort("%A %B %d");
2330 KGlobal::locale()->setHore24Format(true); 2330 KGlobal::locale()->setHore24Format(true);
2331 2331
2332 header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined); 2332 header += KGlobal::locale()->formatDate(currDate, true, KLocale::Userdefined).latin1();
2333 header += KGlobal::locale()->formatTime(currTime, true); 2333 header += KGlobal::locale()->formatTime(currTime, true).latin1();
2334 KGlobal::locale()->setDateFormatShort(dfs); 2334 KGlobal::locale()->setDateFormatShort(dfs);
2335 KGlobal::locale()->setHore24Format(!ampm); 2335 KGlobal::locale()->setHore24Format(!ampm);
2336 2336
2337#endif 2337#endif
2338 header += tostr(currDate.year()); 2338 header += tostr(currDate.year());
2339 header += "\n==============================\n\n"; 2339 header += "\n==============================\n\n";
2340 2340
2341 2341
2342#ifndef PWM_EMBEDDED 2342#ifndef PWM_EMBEDDED
2343 if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) { 2343 if (f.writeBlock(header.c_str(), header.length()) != (Q_LONG)header.length()) {
2344 unlockAll_tempoary(true); 2344 unlockAll_tempoary(true);
2345 f.close(); 2345 f.close();
2346 return e_writeFile; 2346 return e_writeFile;
2347 } 2347 }
2348#else 2348#else
2349 if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) { 2349 if (f.writeBlock(header.c_str(), header.length()) != (long)header.length()) {
2350 unlockAll_tempoary(true); 2350 unlockAll_tempoary(true);
2351 f.close(); 2351 f.close();
2352 return e_writeFile; 2352 return e_writeFile;
2353 } 2353 }
2354#endif 2354#endif
2355 unsigned int i, numCat = numCategories(); 2355 unsigned int i, numCat = numCategories();
2356 unsigned int j, numEnt; 2356 unsigned int j, numEnt;
2357 string exp; 2357 string exp;
2358 for (i = 0; i < numCat; ++i) { 2358 for (i = 0; i < numCat; ++i) {
2359 numEnt = numEntries(i); 2359 numEnt = numEntries(i);
2360 2360
2361 exp = "\n== Category: "; 2361 exp = "\n== Category: ";
2362 exp += dti.dta[i].name; 2362 exp += dti.dta[i].name;
2363 exp += " ==\n"; 2363 exp += " ==\n";
2364#ifndef PWM_EMBEDDED 2364#ifndef PWM_EMBEDDED
2365 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { 2365 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) {
2366 unlockAll_tempoary(true); 2366 unlockAll_tempoary(true);
2367 f.close(); 2367 f.close();
2368 return e_writeFile; 2368 return e_writeFile;
2369 } 2369 }
2370#else 2370#else
2371 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { 2371 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) {
2372 unlockAll_tempoary(true); 2372 unlockAll_tempoary(true);
2373 f.close(); 2373 f.close();
2374 return e_writeFile; 2374 return e_writeFile;
2375 } 2375 }
2376#endif 2376#endif
2377 for (j = 0; j < numEnt; ++j) { 2377 for (j = 0; j < numEnt; ++j) {
2378 exp = "\n-- "; 2378 exp = "\n-- ";
2379 exp += dti.dta[i].d[j].desc; 2379 exp += dti.dta[i].d[j].desc;
2380 exp += " --\n"; 2380 exp += " --\n";
2381 2381
2382 exp += i18n("Username: ").latin1(); 2382 exp += i18n("Username: ").latin1();
2383 exp += dti.dta[i].d[j].name; 2383 exp += dti.dta[i].d[j].name;
2384 exp += "\n"; 2384 exp += "\n";
2385 2385
2386 exp += i18n("Password: ").latin1(); 2386 exp += i18n("Password: ").latin1();
2387 exp += dti.dta[i].d[j].pw; 2387 exp += dti.dta[i].d[j].pw;
2388 exp += "\n"; 2388 exp += "\n";
2389 2389
2390 exp += i18n("Comment: ").latin1(); 2390 exp += i18n("Comment: ").latin1();
2391 exp += dti.dta[i].d[j].comment; 2391 exp += dti.dta[i].d[j].comment;
2392 exp += "\n"; 2392 exp += "\n";
2393 2393
2394 exp += i18n("URL: ").latin1(); 2394 exp += i18n("URL: ").latin1();
2395 exp += dti.dta[i].d[j].url; 2395 exp += dti.dta[i].d[j].url;
2396 exp += "\n"; 2396 exp += "\n";
2397 2397
2398 exp += i18n("Launcher: ").latin1(); 2398 exp += i18n("Launcher: ").latin1();
2399 exp += dti.dta[i].d[j].launcher; 2399 exp += dti.dta[i].d[j].launcher;
2400 exp += "\n"; 2400 exp += "\n";
2401 2401
2402#ifndef PWM_EMBEDDED 2402#ifndef PWM_EMBEDDED
2403 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) { 2403 if (f.writeBlock(exp.c_str(), exp.length()) != (Q_LONG)exp.length()) {
2404 unlockAll_tempoary(true); 2404 unlockAll_tempoary(true);
2405 f.close(); 2405 f.close();
2406 return e_writeFile; 2406 return e_writeFile;
2407 } 2407 }
2408#else 2408#else
2409 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) { 2409 if (f.writeBlock(exp.c_str(), exp.length()) != (long)exp.length()) {
2410 unlockAll_tempoary(true); 2410 unlockAll_tempoary(true);
2411 f.close(); 2411 f.close();
2412 return e_writeFile; 2412 return e_writeFile;
2413 } 2413 }
2414#endif 2414#endif
2415 } 2415 }
2416 } 2416 }
2417 unlockAll_tempoary(true); 2417 unlockAll_tempoary(true);
2418 f.close(); 2418 f.close();
2419 2419
2420 return e_success; 2420 return e_success;
2421} 2421}
2422 2422
2423PwMerror PwMDoc::importFromText(const QString *file, int format) 2423PwMerror PwMDoc::importFromText(const QString *file, int format)
2424{ 2424{
2425 PWM_ASSERT(file); 2425 PWM_ASSERT(file);
2426 if (format == 0) 2426 if (format == 0)
2427 return importText_PwM(file); 2427 return importText_PwM(file);
2428 else if (format == -1) { 2428 else if (format == -1) {
2429 // probe for all formats 2429 // probe for all formats
@@ -2925,213 +2925,213 @@ void PwMDoc::ensureLvp()
2925 2925
2926 while (entrI != entrEnd) { 2926 while (entrI != entrEnd) {
2927 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos); 2927 qDebug("check: %s, pos=%i", (*entrI).desc.c_str(), (*entrI).listViewPos);
2928 ++entrI; 2928 ++entrI;
2929 } 2929 }
2930 */ 2930 */
2931 2931
2932 ++catI; 2932 ++catI;
2933 } 2933 }
2934} 2934}
2935 2935
2936QString PwMDoc::getTitle() 2936QString PwMDoc::getTitle()
2937{ 2937{
2938 /* NOTE: We have to ensure, that the returned title 2938 /* NOTE: We have to ensure, that the returned title
2939 * is unique and not reused somewhere else while 2939 * is unique and not reused somewhere else while
2940 * this document is valid (open). 2940 * this document is valid (open).
2941 */ 2941 */
2942 QString title(getFilename()); 2942 QString title(getFilename());
2943 2943
2944 //US ENH: The whole filename on PDAs is too long. So use only the last characters 2944 //US ENH: The whole filename on PDAs is too long. So use only the last characters
2945 if (QApplication::desktop()->width() < 640) 2945 if (QApplication::desktop()->width() < 640)
2946 { 2946 {
2947 if (title.length() > 30) 2947 if (title.length() > 30)
2948 title = "..." + title.right(30); 2948 title = "..." + title.right(30);
2949 2949
2950 } 2950 }
2951 2951
2952 2952
2953 if (title.isEmpty()) { 2953 if (title.isEmpty()) {
2954 if (unnamedNum == 0) { 2954 if (unnamedNum == 0) {
2955 unnamedNum = PwMDocList::getNewUnnamedNumber(); 2955 unnamedNum = PwMDocList::getNewUnnamedNumber();
2956 PWM_ASSERT(unnamedNum != 0); 2956 PWM_ASSERT(unnamedNum != 0);
2957 } 2957 }
2958 title = DEFAULT_TITLE; 2958 title = DEFAULT_TITLE;
2959 title += " "; 2959 title += " ";
2960 title += tostr(unnamedNum).c_str(); 2960 title += tostr(unnamedNum).c_str();
2961 } 2961 }
2962 return title; 2962 return title;
2963} 2963}
2964 2964
2965bool PwMDoc::tryDelete() 2965bool PwMDoc::tryDelete()
2966{ 2966{
2967 if (deleted) 2967 if (deleted)
2968 return true; 2968 return true;
2969 int ret; 2969 int ret;
2970 if (isDirty()) { 2970 if (isDirty()) {
2971 ret = dirtyAskSave(getTitle()); 2971 ret = dirtyAskSave(getTitle());
2972 if (ret == 0) { // save to disk 2972 if (ret == 0) { // save to disk
2973 if (!saveDocUi(this)) 2973 if (!saveDocUi(this))
2974 goto out_ignore; 2974 goto out_ignore;
2975 } else if (ret == 1) { // don't save and delete 2975 } else if (ret == 1) { // don't save and delete
2976 goto out_accept; 2976 goto out_accept;
2977 } else { // cancel operation 2977 } else { // cancel operation
2978 goto out_ignore; 2978 goto out_ignore;
2979 } 2979 }
2980 } 2980 }
2981out_accept: 2981out_accept:
2982 deleted = true; 2982 deleted = true;
2983 delete this; 2983 delete this;
2984 return true; 2984 return true;
2985out_ignore: 2985out_ignore:
2986 return false; 2986 return false;
2987} 2987}
2988 2988
2989 2989
2990 2990
2991#ifdef PWM_EMBEDDED 2991#ifdef PWM_EMBEDDED
2992//US ENH: this is the magic function that syncronizes the this doc with the remote doc 2992//US ENH: this is the magic function that syncronizes the this doc with the remote doc
2993//US it could have been defined as static, but I did not want to. 2993//US it could have been defined as static, but I did not want to.
2994PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) 2994PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode )
2995{ 2995{
2996 int addedPasswordsLocal = 0; 2996 int addedPasswordsLocal = 0;
2997 int addedPasswordsRemote = 0; 2997 int addedPasswordsRemote = 0;
2998 int deletedPasswordsRemote = 0; 2998 int deletedPasswordsRemote = 0;
2999 int deletedPasswordsLocal = 0; 2999 int deletedPasswordsLocal = 0;
3000 int changedLocal = 0; 3000 int changedLocal = 0;
3001 int changedRemote = 0; 3001 int changedRemote = 0;
3002 3002
3003 PwMSyncItem* syncItemLocal; 3003 PwMSyncItem* syncItemLocal;
3004 PwMSyncItem* syncItemRemote; 3004 PwMSyncItem* syncItemRemote;
3005 3005
3006 QString mCurrentSyncName = manager->getCurrentSyncName(); 3006 QString mCurrentSyncName = manager->getCurrentSyncName();
3007 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3007 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3008 3008
3009 bool fullDateRange = false; 3009 bool fullDateRange = false;
3010 int take; 3010 int take;
3011 // local->resetTempSyncStat(); 3011 // local->resetTempSyncStat();
3012 QDateTime mLastSync = QDateTime::currentDateTime(); 3012 QDateTime mLastSync = QDateTime::currentDateTime();
3013 QDateTime modifiedSync = mLastSync; 3013 QDateTime modifiedSync = mLastSync;
3014 3014
3015 unsigned int index; 3015 unsigned int index;
3016 //Step 1. Find syncinfo in Local file and create if not existent. 3016 //Step 1. Find syncinfo in Local file and create if not existent.
3017 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 3017 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
3018 if (found == false) 3018 if (found == false)
3019 { 3019 {
3020 PwMSyncItem newSyncItemLocal; 3020 PwMSyncItem newSyncItemLocal;
3021 newSyncItemLocal.syncName = mCurrentSyncDevice; 3021 newSyncItemLocal.syncName = mCurrentSyncDevice.latin1();
3022 newSyncItemLocal.lastSyncDate = mLastSync; 3022 newSyncItemLocal.lastSyncDate = mLastSync;
3023 syncLocal->addSyncDataEntry(&newSyncItemLocal, true); 3023 syncLocal->addSyncDataEntry(&newSyncItemLocal, true);
3024 found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 3024 found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
3025 if (found == false) { 3025 if (found == false) {
3026 qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); 3026 qDebug("PwMDoc::syncronize : newly created local sync data could not be found");
3027 return e_syncError; 3027 return e_syncError;
3028 } 3028 }
3029 } 3029 }
3030 3030
3031 syncItemLocal = syncLocal->getSyncDataEntry(index); 3031 syncItemLocal = syncLocal->getSyncDataEntry(index);
3032 qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1()); 3032 qDebug("Last Sync Local %s ", syncItemLocal->lastSyncDate.toString().latin1());
3033 3033
3034 //Step 2. Find syncinfo in remote file and create if not existent. 3034 //Step 2. Find syncinfo in remote file and create if not existent.
3035 found = syncRemote->findSyncData(mCurrentSyncName, &index); 3035 found = syncRemote->findSyncData(mCurrentSyncName, &index);
3036 if (found == false) 3036 if (found == false)
3037 { 3037 {
3038 qDebug("FULLDATE 1"); 3038 qDebug("FULLDATE 1");
3039 fullDateRange = true; 3039 fullDateRange = true;
3040 PwMSyncItem newSyncItemRemote; 3040 PwMSyncItem newSyncItemRemote;
3041 newSyncItemRemote.syncName = mCurrentSyncName; 3041 newSyncItemRemote.syncName = mCurrentSyncName.latin1();
3042 newSyncItemRemote.lastSyncDate = mLastSync; 3042 newSyncItemRemote.lastSyncDate = mLastSync;
3043 syncRemote->addSyncDataEntry(&newSyncItemRemote, true); 3043 syncRemote->addSyncDataEntry(&newSyncItemRemote, true);
3044 found = syncRemote->findSyncData(mCurrentSyncName, &index); 3044 found = syncRemote->findSyncData(mCurrentSyncName, &index);
3045 if (found == false) { 3045 if (found == false) {
3046 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); 3046 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found");
3047 return e_syncError; 3047 return e_syncError;
3048 } 3048 }
3049 } 3049 }
3050 3050
3051 syncItemRemote = syncRemote->getSyncDataEntry(index); 3051 syncItemRemote = syncRemote->getSyncDataEntry(index);
3052 qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1()); 3052 qDebug("Last Sync Remote %s ", syncItemRemote->lastSyncDate.toString().latin1());
3053 //and remove the found entry here. We will reenter it later again. 3053 //and remove the found entry here. We will reenter it later again.
3054 //US syncRemote->delSyncDataEntry(index, true); 3054 //US syncRemote->delSyncDataEntry(index, true);
3055 3055
3056 3056
3057 if ( syncItemLocal->lastSyncDate == mLastSync ) { 3057 if ( syncItemLocal->lastSyncDate == mLastSync ) {
3058 qDebug("FULLDATE 2"); 3058 qDebug("FULLDATE 2");
3059 fullDateRange = true; 3059 fullDateRange = true;
3060 } 3060 }
3061 3061
3062 if ( ! fullDateRange ) { 3062 if ( ! fullDateRange ) {
3063 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { 3063 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) {
3064 3064
3065 fullDateRange = true; 3065 fullDateRange = true;
3066 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); 3066 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() );
3067 } 3067 }
3068 } 3068 }
3069 // fullDateRange = true; // debug only! 3069 // fullDateRange = true; // debug only!
3070 if ( fullDateRange ) 3070 if ( fullDateRange )
3071 mLastSync = QDateTime::currentDateTime().addDays( -100*365); 3071 mLastSync = QDateTime::currentDateTime().addDays( -100*365);
3072 else 3072 else
3073 mLastSync = syncItemLocal->lastSyncDate; 3073 mLastSync = syncItemLocal->lastSyncDate;
3074 3074
3075 3075
3076 qDebug("*************************** "); 3076 qDebug("*************************** ");
3077 qDebug("mLastSync %s ",mLastSync.toString().latin1() ); 3077 qDebug("mLastSync %s ",mLastSync.toString().latin1() );
3078 QStringList er = syncRemote->getIDEntryList(); 3078 QStringList er = syncRemote->getIDEntryList();
3079 PwMDataItem* inRemote ;//= er.first(); 3079 PwMDataItem* inRemote ;//= er.first();
3080 PwMDataItem* inLocal; 3080 PwMDataItem* inLocal;
3081 unsigned int catLocal, indexLocal; 3081 unsigned int catLocal, indexLocal;
3082 unsigned int catRemote, indexRemote; 3082 unsigned int catRemote, indexRemote;
3083 3083
3084 QString uid; 3084 QString uid;
3085 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3085 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3086 3086
3087 int modulo = (er.count()/10)+1; 3087 int modulo = (er.count()/10)+1;
3088 unsigned int incCounter = 0; 3088 unsigned int incCounter = 0;
3089 while ( incCounter < er.count()) { 3089 while ( incCounter < er.count()) {
3090 if (manager->isProgressBarCanceled()) 3090 if (manager->isProgressBarCanceled())
3091 return e_syncError; 3091 return e_syncError;
3092 if ( incCounter % modulo == 0 ) 3092 if ( incCounter % modulo == 0 )
3093 manager->showProgressBar(incCounter); 3093 manager->showProgressBar(incCounter);
3094 3094
3095 uid = er[ incCounter ]; 3095 uid = er[ incCounter ];
3096 qDebug("sync uid %s from remote file", uid.latin1()); 3096 qDebug("sync uid %s from remote file", uid.latin1());
3097 3097
3098 qApp->processEvents(); 3098 qApp->processEvents();
3099 3099
3100 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 3100 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
3101 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 3101 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
3102 PWM_ASSERT(inRemote); 3102 PWM_ASSERT(inRemote);
3103 if ( inLocal != 0 ) { // maybe conflict - same uid in both files 3103 if ( inLocal != 0 ) { // maybe conflict - same uid in both files
3104 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { 3104 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) {
3105 qDebug("take %d %s ", take, inLocal->desc.c_str()); 3105 qDebug("take %d %s ", take, inLocal->desc.c_str());
3106 if ( take == 3 ) 3106 if ( take == 3 )
3107 return e_syncError; 3107 return e_syncError;
3108 if ( take == 1 ) {// take local 3108 if ( take == 1 ) {// take local
3109 int oldlistpos = inRemote->listViewPos; 3109 int oldlistpos = inRemote->listViewPos;
3110 (*inRemote) = (*inLocal); 3110 (*inRemote) = (*inLocal);
3111 inRemote->listViewPos = oldlistpos; 3111 inRemote->listViewPos = oldlistpos;
3112 ++changedRemote; 3112 ++changedRemote;
3113 } else { // take == 2 take remote 3113 } else { // take == 2 take remote
3114 int oldlistpos = inLocal->listViewPos; 3114 int oldlistpos = inLocal->listViewPos;
3115 (*inLocal) = (*inRemote); 3115 (*inLocal) = (*inRemote);
3116 inLocal->listViewPos = oldlistpos; 3116 inLocal->listViewPos = oldlistpos;
3117 ++changedLocal; 3117 ++changedLocal;
3118 } 3118 }
3119 } 3119 }
3120 } else { // no conflict 3120 } else { // no conflict
3121 if ( inRemote->meta.update > mLastSync || mode == 5 ) { 3121 if ( inRemote->meta.update > mLastSync || mode == 5 ) {
3122 inRemote->meta.update = modifiedSync; 3122 inRemote->meta.update = modifiedSync;
3123 3123
3124 //first check if we have a matching category in the local file 3124 //first check if we have a matching category in the local file
3125 const string* remotecat = syncRemote->getCategory(catRemote); 3125 const string* remotecat = syncRemote->getCategory(catRemote);
3126 //US syncRemote->insertAddressee( inRemote, false ); 3126 //US syncRemote->insertAddressee( inRemote, false );
3127 //US syncLocal->insertAddressee( inRemote, false ); 3127 //US syncLocal->insertAddressee( inRemote, false );
3128 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false); 3128 syncLocal->addEntry(remotecat->c_str(), inRemote, true, false);
3129 3129
3130 ++addedPasswordsLocal; 3130 ++addedPasswordsLocal;
3131 } else { 3131 } else {
3132 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3132 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3133 syncRemote->delEntry(catRemote, indexRemote, true); 3133 syncRemote->delEntry(catRemote, indexRemote, true);
3134 //USsyncRemote->removeAddressee( inRemote ); 3134 //USsyncRemote->removeAddressee( inRemote );
3135 ++deletedPasswordsRemote; 3135 ++deletedPasswordsRemote;
3136 } 3136 }
3137 } 3137 }