summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2004-12-05 13:41:41 (UTC)
committer zautrix <zautrix>2004-12-05 13:41:41 (UTC)
commit06bebf5be01898145c4f721a8d002519141e7f3b (patch) (unidiff)
treebc44d996a58a63de8c43cb5ba54d55bf1494eb5c /libkdepim
parent5ab47964d8b52897bb0662ef4a5fcf9604acaf6c (diff)
downloadkdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.zip
kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.tar.gz
kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.tar.bz2
added better debug output to sync file problems
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index c12ba1c..7c53948 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -339,129 +339,129 @@ void KSyncManager::enableQuick( bool ask )
339 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 339 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
340 lay.addWidget( &label); 340 lay.addWidget( &label);
341 lay.addWidget( &lab); 341 lay.addWidget( &lab);
342 342
343 QLineEdit lepw ( &dia ); 343 QLineEdit lepw ( &dia );
344 lepw.setText( mPrefs->mPassiveSyncPw ); 344 lepw.setText( mPrefs->mPassiveSyncPw );
345 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 345 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
346 lay.addWidget( &label2); 346 lay.addWidget( &label2);
347 lay.addWidget( &lepw); 347 lay.addWidget( &lepw);
348 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 348 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
349 lay.addWidget( &autostart); 349 lay.addWidget( &autostart);
350 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 350 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
351#ifdef DESKTOP_VERSION 351#ifdef DESKTOP_VERSION
352#ifdef _WIN32_ 352#ifdef _WIN32_
353 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 353 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
354 syncdesktop.hide();// not implemented! 354 syncdesktop.hide();// not implemented!
355#else 355#else
356 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 356 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
357#endif 357#endif
358 lay.addWidget( &syncdesktop); 358 lay.addWidget( &syncdesktop);
359#else 359#else
360 mPrefs->mPassiveSyncWithDesktop = false; 360 mPrefs->mPassiveSyncWithDesktop = false;
361 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 361 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
362 syncdesktop.hide(); 362 syncdesktop.hide();
363#endif 363#endif
364 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 364 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
365 365
366 dia.setFixedSize( 230,120 ); 366 dia.setFixedSize( 230,120 );
367 dia.setCaption( i18n("Enter port for Pi-Sync") ); 367 dia.setCaption( i18n("Enter port for Pi-Sync") );
368 QPushButton pb ( "OK", &dia); 368 QPushButton pb ( "OK", &dia);
369 lay.addWidget( &pb ); 369 lay.addWidget( &pb );
370 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 370 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
371 dia.show(); 371 dia.show();
372 if ( ! dia.exec() ) 372 if ( ! dia.exec() )
373 return; 373 return;
374 dia.hide(); 374 dia.hide();
375 qApp->processEvents(); 375 qApp->processEvents();
376 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 376 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
377 changed = true; 377 changed = true;
378 mPrefs->mPassiveSyncPw = lepw.text(); 378 mPrefs->mPassiveSyncPw = lepw.text();
379 } 379 }
380 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 380 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
381 mPrefs->mPassiveSyncPort = lab.text(); 381 mPrefs->mPassiveSyncPort = lab.text();
382 changed = true; 382 changed = true;
383 } 383 }
384 autoStart = autostart.isChecked(); 384 autoStart = autostart.isChecked();
385 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 385 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
386 changed = true; 386 changed = true;
387 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 387 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
388 } 388 }
389 } 389 }
390 else 390 else
391 autoStart = mPrefs->mPassiveSyncAutoStart; 391 autoStart = mPrefs->mPassiveSyncAutoStart;
392 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 392 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
393 changed = true; 393 changed = true;
394 bool ok; 394 bool ok;
395 mPrefs->mPassiveSyncAutoStart = false; 395 mPrefs->mPassiveSyncAutoStart = false;
396 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 396 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
397 if ( ! ok ) { 397 if ( ! ok ) {
398 KMessageBox::information( 0, i18n("No valid port")); 398 KMessageBox::information( 0, i18n("No valid port"));
399 return; 399 return;
400 } 400 }
401 //qDebug("port %d ", port); 401 //qDebug("port %d ", port);
402 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 402 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
403 mServerSocket->setFileName( defaultFileName() ); 403 mServerSocket->setFileName( defaultFileName() );//bbb
404 //qDebug("connected "); 404 //qDebug("connected ");
405 if ( !mServerSocket->ok() ) { 405 if ( !mServerSocket->ok() ) {
406 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 406 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
407 delete mServerSocket; 407 delete mServerSocket;
408 mServerSocket = 0; 408 mServerSocket = 0;
409 return; 409 return;
410 } 410 }
411 mPrefs->mPassiveSyncAutoStart = autoStart; 411 mPrefs->mPassiveSyncAutoStart = autoStart;
412 if ( changed ) { 412 if ( changed ) {
413 mPrefs->writeConfig(); 413 mPrefs->writeConfig();
414 } 414 }
415 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 415 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
416 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 416 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
417} 417}
418 418
419void KSyncManager::syncLocalFile() 419void KSyncManager::syncLocalFile()
420{ 420{
421 421
422 QString fn =mPrefs->mLastSyncedLocalFile; 422 QString fn =mPrefs->mLastSyncedLocalFile;
423 QString ext; 423 QString ext;
424 424
425 switch(mTargetApp) 425 switch(mTargetApp)
426 { 426 {
427 case (KAPI): 427 case (KAPI):
428 ext = "(*.vcf)"; 428 ext = "(*.vcf)";
429 break; 429 break;
430 case (KOPI): 430 case (KOPI):
431 ext = "(*.ics/*.vcs)"; 431 ext = "(*.ics/*.vcs)";
432 break; 432 break;
433 case (PWMPI): 433 case (PWMPI):
434 ext = "(*.pwm)"; 434 ext = "(*.pwm)";
435 break; 435 break;
436 default: 436 default:
437 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 437 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
438 break; 438 break;
439 439
440 } 440 }
441 441
442 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 442 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
443 if ( fn == "" ) 443 if ( fn == "" )
444 return; 444 return;
445 if ( syncWithFile( fn, false ) ) { 445 if ( syncWithFile( fn, false ) ) {
446 qDebug("syncLocalFile() successful "); 446 qDebug("syncLocalFile() successful ");
447 } 447 }
448 448
449} 449}
450 450
451bool KSyncManager::syncWithFile( QString fn , bool quick ) 451bool KSyncManager::syncWithFile( QString fn , bool quick )
452{ 452{
453 bool ret = false; 453 bool ret = false;
454 QFileInfo info; 454 QFileInfo info;
455 info.setFile( fn ); 455 info.setFile( fn );
456 QString mess; 456 QString mess;
457 bool loadbup = true; 457 bool loadbup = true;
458 if ( !info. exists() ) { 458 if ( !info. exists() ) {
459 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 459 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
460 int result = QMessageBox::warning( mParent, i18n("Warning!"), 460 int result = QMessageBox::warning( mParent, i18n("Warning!"),
461 mess ); 461 mess );
462 return ret; 462 return ret;
463 } 463 }
464 int result = 0; 464 int result = 0;
465 if ( !quick ) { 465 if ( !quick ) {
466 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 466 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
467 result = QMessageBox::warning( mParent, i18n("Warning!"), 467 result = QMessageBox::warning( mParent, i18n("Warning!"),
@@ -1176,129 +1176,129 @@ void KServerSocket::readClient()
1176void KServerSocket::end_connect() 1176void KServerSocket::end_connect()
1177{ 1177{
1178 delete mSyncActionDialog; 1178 delete mSyncActionDialog;
1179 mSyncActionDialog = 0; 1179 mSyncActionDialog = 0;
1180} 1180}
1181void KServerSocket::send_file() 1181void KServerSocket::send_file()
1182{ 1182{
1183 //qDebug("MainWindow::sendFile(QSocket* s) "); 1183 //qDebug("MainWindow::sendFile(QSocket* s) ");
1184 if ( mSyncActionDialog ) 1184 if ( mSyncActionDialog )
1185 delete mSyncActionDialog; 1185 delete mSyncActionDialog;
1186 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1186 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1187 mSyncActionDialog->setCaption(i18n("Received sync request")); 1187 mSyncActionDialog->setCaption(i18n("Received sync request"));
1188 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1188 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1189 label->setAlignment ( Qt::AlignHCenter ); 1189 label->setAlignment ( Qt::AlignHCenter );
1190 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1190 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1191 lay->addWidget( label); 1191 lay->addWidget( label);
1192 lay->setMargin(7); 1192 lay->setMargin(7);
1193 lay->setSpacing(7); 1193 lay->setSpacing(7);
1194 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1194 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1195 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1195 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1196 if ( secs < 0 ) 1196 if ( secs < 0 )
1197 secs = secs * (-1); 1197 secs = secs * (-1);
1198 if ( secs > 30 ) 1198 if ( secs > 30 )
1199 //if ( true ) 1199 //if ( true )
1200 { 1200 {
1201 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1201 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1202 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1202 QLabel* label = new QLabel( warning, mSyncActionDialog );
1203 label->setAlignment ( Qt::AlignHCenter ); 1203 label->setAlignment ( Qt::AlignHCenter );
1204 lay->addWidget( label); 1204 lay->addWidget( label);
1205 if ( secs > 180 ) 1205 if ( secs > 180 )
1206 { 1206 {
1207 if ( secs > 300 ) { 1207 if ( secs > 300 ) {
1208 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1208 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1209 qDebug("cancelled "); 1209 qDebug("cancelled ");
1210 return ; 1210 return ;
1211 } 1211 }
1212 } 1212 }
1213 QFont f = label->font(); 1213 QFont f = label->font();
1214 f.setPointSize ( f.pointSize() *2 ); 1214 f.setPointSize ( f.pointSize() *2 );
1215 f. setBold (true ); 1215 f. setBold (true );
1216 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1216 QLabel* label = new QLabel( warning, mSyncActionDialog );
1217 label->setFont( f ); 1217 label->setFont( f );
1218 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1218 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1219 label->setText( warning ); 1219 label->setText( warning );
1220 label->setAlignment ( Qt::AlignHCenter ); 1220 label->setAlignment ( Qt::AlignHCenter );
1221 lay->addWidget( label); 1221 lay->addWidget( label);
1222 mSyncActionDialog->setFixedSize( 230, 300); 1222 mSyncActionDialog->setFixedSize( 230, 300);
1223 } else { 1223 } else {
1224 mSyncActionDialog->setFixedSize( 230, 200); 1224 mSyncActionDialog->setFixedSize( 230, 200);
1225 } 1225 }
1226 } else { 1226 } else {
1227 mSyncActionDialog->setFixedSize( 230, 120); 1227 mSyncActionDialog->setFixedSize( 230, 120);
1228 } 1228 }
1229 } else 1229 } else
1230 mSyncActionDialog->setFixedSize( 230, 120); 1230 mSyncActionDialog->setFixedSize( 230, 120);
1231 mSyncActionDialog->show(); 1231 mSyncActionDialog->show();
1232 mSyncActionDialog->raise(); 1232 mSyncActionDialog->raise();
1233 emit request_file(); 1233 emit request_file();
1234 qApp->processEvents(); 1234 qApp->processEvents();
1235 QString fileName = mFileName; 1235 QString fileName = mFileName;
1236 QFile file( fileName ); 1236 QFile file( fileName );
1237 if (!file.open( IO_ReadOnly ) ) { 1237 if (!file.open( IO_ReadOnly ) ) {
1238 delete mSyncActionDialog; 1238 delete mSyncActionDialog;
1239 mSyncActionDialog = 0; 1239 mSyncActionDialog = 0;
1240 qDebug("KSS::error open file "); 1240 qDebug("KSS::error open sync file: %s ", fileName.latin1());
1241 mSocket->close(); 1241 mSocket->close();
1242 if ( mSocket->state() == QSocket::Idle ) 1242 if ( mSocket->state() == QSocket::Idle )
1243 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1243 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1244 return ; 1244 return ;
1245 1245
1246 } 1246 }
1247 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1247 mSyncActionDialog->setCaption( i18n("Sending file...") );
1248 QTextStream ts( &file ); 1248 QTextStream ts( &file );
1249 ts.setEncoding( QTextStream::Latin1 ); 1249 ts.setEncoding( QTextStream::Latin1 );
1250 1250
1251 QTextStream os( mSocket ); 1251 QTextStream os( mSocket );
1252 os.setEncoding( QTextStream::Latin1 ); 1252 os.setEncoding( QTextStream::Latin1 );
1253 while ( ! ts.atEnd() ) { 1253 while ( ! ts.atEnd() ) {
1254 os << ts.readLine() << "\r\n"; 1254 os << ts.readLine() << "\r\n";
1255 } 1255 }
1256 //os << ts.read(); 1256 //os << ts.read();
1257 file.close(); 1257 file.close();
1258 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1258 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1259 mSocket->close(); 1259 mSocket->close();
1260 if ( mSocket->state() == QSocket::Idle ) 1260 if ( mSocket->state() == QSocket::Idle )
1261 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1261 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1262} 1262}
1263void KServerSocket::get_file() 1263void KServerSocket::get_file()
1264{ 1264{
1265 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1265 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1266 1266
1267 piTime.start(); 1267 piTime.start();
1268 piFileString = ""; 1268 piFileString = "";
1269 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1269 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1270} 1270}
1271 1271
1272 1272
1273void KServerSocket::readBackFileFromSocket() 1273void KServerSocket::readBackFileFromSocket()
1274{ 1274{
1275 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1275 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1276 while ( mSocket->canReadLine () ) { 1276 while ( mSocket->canReadLine () ) {
1277 piTime.restart(); 1277 piTime.restart();
1278 QString line = mSocket->readLine (); 1278 QString line = mSocket->readLine ();
1279 piFileString += line; 1279 piFileString += line;
1280 //qDebug("readline: %s ", line.latin1()); 1280 //qDebug("readline: %s ", line.latin1());
1281 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1281 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1282 1282
1283 } 1283 }
1284 if ( piTime.elapsed () < 3000 ) { 1284 if ( piTime.elapsed () < 3000 ) {
1285 // wait for more 1285 // wait for more
1286 //qDebug("waitformore "); 1286 //qDebug("waitformore ");
1287 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1287 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1288 return; 1288 return;
1289 } 1289 }
1290 QString fileName = mFileName; 1290 QString fileName = mFileName;
1291 QFile file ( fileName ); 1291 QFile file ( fileName );
1292 if (!file.open( IO_WriteOnly ) ) { 1292 if (!file.open( IO_WriteOnly ) ) {
1293 delete mSyncActionDialog; 1293 delete mSyncActionDialog;
1294 mSyncActionDialog = 0; 1294 mSyncActionDialog = 0;
1295 qDebug("KSS:Error open read back file "); 1295 qDebug("KSS:Error open read back file ");
1296 piFileString = ""; 1296 piFileString = "";
1297 emit file_received( false ); 1297 emit file_received( false );
1298 blockRC = false; 1298 blockRC = false;
1299 return ; 1299 return ;
1300 1300
1301 } 1301 }
1302 1302
1303 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1303 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1304 QTextStream ts ( &file ); 1304 QTextStream ts ( &file );