summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-12-05 13:41:41 (UTC)
committer zautrix <zautrix>2004-12-05 13:41:41 (UTC)
commit06bebf5be01898145c4f721a8d002519141e7f3b (patch) (unidiff)
treebc44d996a58a63de8c43cb5ba54d55bf1494eb5c
parent5ab47964d8b52897bb0662ef4a5fcf9604acaf6c (diff)
downloadkdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.zip
kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.tar.gz
kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.tar.bz2
added better debug output to sync file problems
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp8
-rw-r--r--libkdepim/ksyncmanager.cpp4
2 files changed, 9 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 15cab73..b7edccd 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1773,49 +1773,51 @@ void KABCore::initGUI()
1773 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1773 QHBoxLayout *topLayout = new QHBoxLayout( this );
1774//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1774//US topLayout->setSpacing( KDialogBase::spacingHint() );
1775 topLayout->setSpacing( 10 ); 1775 topLayout->setSpacing( 10 );
1776 1776
1777// mDetailsSplitter = new QSplitter( this ); 1777// mDetailsSplitter = new QSplitter( this );
1778 1778
1779 QVBox *viewSpace = new QVBox( this ); 1779 QVBox *viewSpace = new QVBox( this );
1780 1780
1781 mViewManager = new ViewManager( this, viewSpace ); 1781 mViewManager = new ViewManager( this, viewSpace );
1782 viewSpace->setStretchFactor( mViewManager, 1 ); 1782 viewSpace->setStretchFactor( mViewManager, 1 );
1783 1783
1784 mDetails = new ViewContainer( this ); 1784 mDetails = new ViewContainer( this );
1785 1785
1786 topLayout->addWidget( viewSpace ); 1786 topLayout->addWidget( viewSpace );
1787// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1787// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1788 topLayout->addWidget( mDetails ); 1788 topLayout->addWidget( mDetails );
1789#endif //KAB_NOSPLITTER 1789#endif //KAB_NOSPLITTER
1790*/ 1790*/
1791 1791
1792 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1792 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1793 syncManager->setBlockSave(false); 1793 syncManager->setBlockSave(false);
1794 1794
1795 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1795 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1796 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1796 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1797 syncManager->setDefaultFileName( sentSyncFile()); 1797 QString sync_file = sentSyncFile();
1798 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1799 syncManager->setDefaultFileName( sync_file );
1798 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1800 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1799 1801
1800#endif //KAB_EMBEDDED 1802#endif //KAB_EMBEDDED
1801 initActions(); 1803 initActions();
1802 1804
1803#ifdef KAB_EMBEDDED 1805#ifdef KAB_EMBEDDED
1804 addActionsManually(); 1806 addActionsManually();
1805 //US make sure the export and import menues are initialized before creating the xxPortManager. 1807 //US make sure the export and import menues are initialized before creating the xxPortManager.
1806 mXXPortManager = new XXPortManager( this, this ); 1808 mXXPortManager = new XXPortManager( this, this );
1807 1809
1808 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1810 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1809 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1811 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1810 // mActionQuit->plug ( mMainWindow->toolBar()); 1812 // mActionQuit->plug ( mMainWindow->toolBar());
1811 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1813 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1812 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1814 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1813 // mIncSearchWidget->hide(); 1815 // mIncSearchWidget->hide();
1814 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1816 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1815 SLOT( incrementalSearch( const QString& ) ) ); 1817 SLOT( incrementalSearch( const QString& ) ) );
1816 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1818 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1817 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1819 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1818 1820
1819 mJumpButtonBar = new JumpButtonBar( this, this ); 1821 mJumpButtonBar = new JumpButtonBar( this, this );
1820 1822
1821 topLayout->addWidget( mJumpButtonBar ); 1823 topLayout->addWidget( mJumpButtonBar );
@@ -2985,48 +2987,50 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2985 remote->insertAddressee( addresseeRSync, false ); 2987 remote->insertAddressee( addresseeRSync, false );
2986 local->insertAddressee( addresseeLSync, false ); 2988 local->insertAddressee( addresseeLSync, false );
2987 QString mes; 2989 QString mes;
2988 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2990 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2989 qDebug( mes ); 2991 qDebug( mes );
2990 mes = i18n("Local addressbook changed!\n") +mes; 2992 mes = i18n("Local addressbook changed!\n") +mes;
2991 if ( syncManager->mShowSyncSummary ) { 2993 if ( syncManager->mShowSyncSummary ) {
2992 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 2994 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2993 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 2995 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2994 qDebug("cancelled "); 2996 qDebug("cancelled ");
2995 return false; 2997 return false;
2996 } 2998 }
2997 } 2999 }
2998 return syncOK; 3000 return syncOK;
2999} 3001}
3000 3002
3001 3003
3002//this is a overwritten callbackmethods from the syncinterface 3004//this is a overwritten callbackmethods from the syncinterface
3003bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3005bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3004{ 3006{
3005 3007
3006 //pending prepare addresseeview for output 3008 //pending prepare addresseeview for output
3007 //pending detect, if remote file has REV field. if not switch to external sync 3009 //pending detect, if remote file has REV field. if not switch to external sync
3008 mGlobalSyncMode = SYNC_MODE_NORMAL; 3010 mGlobalSyncMode = SYNC_MODE_NORMAL;
3011 if ( manager != syncManager )
3012 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3009 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3013 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3010 3014
3011 AddressBook abLocal(filename,"syncContact"); 3015 AddressBook abLocal(filename,"syncContact");
3012 bool syncOK = false; 3016 bool syncOK = false;
3013 if ( abLocal.load() ) { 3017 if ( abLocal.load() ) {
3014 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3018 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3015 bool external = false; 3019 bool external = false;
3016 bool isXML = false; 3020 bool isXML = false;
3017 if ( filename.right(4) == ".xml") { 3021 if ( filename.right(4) == ".xml") {
3018 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3022 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3019 isXML = true; 3023 isXML = true;
3020 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3024 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3021 } else { 3025 } else {
3022 external = !manager->mIsKapiFile; 3026 external = !manager->mIsKapiFile;
3023 if ( external ) { 3027 if ( external ) {
3024 qDebug("Setting vcf mode to external "); 3028 qDebug("Setting vcf mode to external ");
3025 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3029 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3026 AddressBook::Iterator it; 3030 AddressBook::Iterator it;
3027 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3031 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3028 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3032 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3029 (*it).computeCsum( mCurrentSyncDevice ); 3033 (*it).computeCsum( mCurrentSyncDevice );
3030 } 3034 }
3031 } 3035 }
3032 } 3036 }
@@ -3052,48 +3056,50 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3052 } 3056 }
3053 setModified(); 3057 setModified();
3054 3058
3055 } 3059 }
3056 abLocal.removeResources(); 3060 abLocal.removeResources();
3057 if ( syncOK ) 3061 if ( syncOK )
3058 mViewManager->refreshView(); 3062 mViewManager->refreshView();
3059 return syncOK; 3063 return syncOK;
3060 3064
3061} 3065}
3062void KABCore::removeSyncInfo( QString syncProfile) 3066void KABCore::removeSyncInfo( QString syncProfile)
3063{ 3067{
3064 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3068 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3065 mAddressBook->removeSyncInfo( syncProfile ); 3069 mAddressBook->removeSyncInfo( syncProfile );
3066 setModified(); 3070 setModified();
3067} 3071}
3068 3072
3069 3073
3070//this is a overwritten callbackmethods from the syncinterface 3074//this is a overwritten callbackmethods from the syncinterface
3071bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3075bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3072{ 3076{
3073 if ( resource == "phone" ) 3077 if ( resource == "phone" )
3074 return syncPhone(); 3078 return syncPhone();
3075 disableBR( true ); 3079 disableBR( true );
3080 if ( manager != syncManager )
3081 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3076 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3082 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3077 3083
3078 AddressBook abLocal( resource,"syncContact"); 3084 AddressBook abLocal( resource,"syncContact");
3079 bool syncOK = false; 3085 bool syncOK = false;
3080 if ( abLocal.load() ) { 3086 if ( abLocal.load() ) {
3081 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3087 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3082 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3088 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3083 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3089 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3084 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3090 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3085 if ( syncOK ) { 3091 if ( syncOK ) {
3086 if ( syncManager->mWriteBackFile ) { 3092 if ( syncManager->mWriteBackFile ) {
3087 abLocal.removeSyncAddressees( false ); 3093 abLocal.removeSyncAddressees( false );
3088 abLocal.saveAB(); 3094 abLocal.saveAB();
3089 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3095 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3090 } 3096 }
3091 } else 3097 } else
3092 message( i18n("Sync cancelled or failed.") ); 3098 message( i18n("Sync cancelled or failed.") );
3093 setModified(); 3099 setModified();
3094 } 3100 }
3095 abLocal.removeResources(); 3101 abLocal.removeResources();
3096 if ( syncOK ) 3102 if ( syncOK )
3097 mViewManager->refreshView(); 3103 mViewManager->refreshView();
3098 disableBR( false ); 3104 disableBR( false );
3099 return syncOK; 3105 return syncOK;
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index c12ba1c..7c53948 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -379,49 +379,49 @@ void KSyncManager::enableQuick( bool ask )
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):
@@ -1216,49 +1216,49 @@ void KServerSocket::send_file()
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{