author | zautrix <zautrix> | 2004-12-05 13:41:41 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-05 13:41:41 (UTC) |
commit | 06bebf5be01898145c4f721a8d002519141e7f3b (patch) (side-by-side diff) | |
tree | bc44d996a58a63de8c43cb5ba54d55bf1494eb5c | |
parent | 5ab47964d8b52897bb0662ef4a5fcf9604acaf6c (diff) | |
download | kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.zip kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.tar.gz kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.tar.bz2 |
added better debug output to sync file problems
-rw-r--r-- | kaddressbook/kabcore.cpp | 8 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 4 |
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 @@ -1765,65 +1765,67 @@ void KABCore::initGUI() mViewManager = new ViewManager( this, viewSpace ); viewSpace->setStretchFactor( mViewManager, 1 ); mDetails = new ViewContainer( mDetailsSplitter ); topLayout->addWidget( mDetailsSplitter ); topLayout->setStretchFactor( mDetailsSplitter, 100 ); #else //KAB_NOSPLITTER QHBoxLayout *topLayout = new QHBoxLayout( this ); //US topLayout->setSpacing( KDialogBase::spacingHint() ); topLayout->setSpacing( 10 ); // mDetailsSplitter = new QSplitter( this ); QVBox *viewSpace = new QVBox( this ); mViewManager = new ViewManager( this, viewSpace ); viewSpace->setStretchFactor( mViewManager, 1 ); mDetails = new ViewContainer( this ); topLayout->addWidget( viewSpace ); // topLayout->setStretchFactor( mDetailsSplitter, 100 ); topLayout->addWidget( mDetails ); #endif //KAB_NOSPLITTER */ syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); syncManager->setBlockSave(false); connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); - syncManager->setDefaultFileName( sentSyncFile()); + QString sync_file = sentSyncFile(); + qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); + syncManager->setDefaultFileName( sync_file ); //connect(syncManager , SIGNAL( ), this, SLOT( ) ); #endif //KAB_EMBEDDED initActions(); #ifdef KAB_EMBEDDED addActionsManually(); //US make sure the export and import menues are initialized before creating the xxPortManager. mXXPortManager = new XXPortManager( this, this ); // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); // mActionQuit->plug ( mMainWindow->toolBar()); //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); // mIncSearchWidget->hide(); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); mJumpButtonBar = new JumpButtonBar( this, this ); topLayout->addWidget( mJumpButtonBar ); //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); // mMainWindow->getIconToolBar()->raise(); #endif //KAB_EMBEDDED } void KABCore::initActions() @@ -2977,64 +2979,66 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); addresseeRSync.setNote( "" ) ; addresseeLSync.setNote( "" ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->insertAddressee( addresseeRSync, false ); local->insertAddressee( addresseeLSync, false ); QString mes; 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 ); qDebug( mes ); mes = i18n("Local addressbook changed!\n") +mes; if ( syncManager->mShowSyncSummary ) { if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, i18n("KA/Pi Synchronization"),i18n("Write back"))) { qDebug("cancelled "); return false; } } return syncOK; } //this is a overwritten callbackmethods from the syncinterface bool KABCore::sync(KSyncManager* manager, QString filename, int mode) { //pending prepare addresseeview for output //pending detect, if remote file has REV field. if not switch to external sync mGlobalSyncMode = SYNC_MODE_NORMAL; + if ( manager != syncManager ) + qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); AddressBook abLocal(filename,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); bool external = false; bool isXML = false; if ( filename.right(4) == ".xml") { mGlobalSyncMode = SYNC_MODE_EXTERNAL; isXML = true; abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); } else { external = !manager->mIsKapiFile; if ( external ) { qDebug("Setting vcf mode to external "); mGlobalSyncMode = SYNC_MODE_EXTERNAL; AddressBook::Iterator it; for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { (*it).setID( mCurrentSyncDevice, (*it).uid() ); (*it).computeCsum( mCurrentSyncDevice ); } } } //AddressBook::Iterator it; //QStringList vcards; //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { // qDebug("Name %s ", (*it).familyName().latin1()); //} syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); if ( syncOK ) { if ( syncManager->mWriteBackFile ) @@ -3044,64 +3048,66 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) qDebug("Saving remote AB "); if ( ! abLocal.saveAB()) qDebug("Error writing back AB to file "); if ( external ) { // afterwrite processing abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); } } } setModified(); } abLocal.removeResources(); if ( syncOK ) mViewManager->refreshView(); return syncOK; } void KABCore::removeSyncInfo( QString syncProfile) { qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); mAddressBook->removeSyncInfo( syncProfile ); setModified(); } //this is a overwritten callbackmethods from the syncinterface bool KABCore::syncExternal(KSyncManager* manager, QString resource) { if ( resource == "phone" ) return syncPhone(); disableBR( true ); + if ( manager != syncManager ) + qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); AddressBook abLocal( resource,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); mGlobalSyncMode = SYNC_MODE_EXTERNAL; abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); if ( syncOK ) { if ( syncManager->mWriteBackFile ) { abLocal.removeSyncAddressees( false ); abLocal.saveAB(); abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); } } else message( i18n("Sync cancelled or failed.") ); setModified(); } abLocal.removeResources(); if ( syncOK ) mViewManager->refreshView(); disableBR( false ); return syncOK; } void KABCore::message( QString m ) { topLevelWidget()->setCaption( m ); mMessageTimer->start( 15000, true ); } bool KABCore::syncPhone() diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index c12ba1c..7c53948 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -371,65 +371,65 @@ void KSyncManager::enableQuick( bool ask ) dia.show(); if ( ! dia.exec() ) return; dia.hide(); qApp->processEvents(); if ( mPrefs->mPassiveSyncPw != lepw.text() ) { changed = true; mPrefs->mPassiveSyncPw = lepw.text(); } if ( mPrefs->mPassiveSyncPort != lab.text() ) { mPrefs->mPassiveSyncPort = lab.text(); changed = true; } autoStart = autostart.isChecked(); if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { changed = true; mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); } } else autoStart = mPrefs->mPassiveSyncAutoStart; if ( autoStart != mPrefs->mPassiveSyncAutoStart ) changed = true; bool ok; mPrefs->mPassiveSyncAutoStart = false; Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); if ( ! ok ) { KMessageBox::information( 0, i18n("No valid port")); return; } //qDebug("port %d ", port); mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); - mServerSocket->setFileName( defaultFileName() ); + mServerSocket->setFileName( defaultFileName() );//bbb //qDebug("connected "); if ( !mServerSocket->ok() ) { KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); delete mServerSocket; mServerSocket = 0; return; } mPrefs->mPassiveSyncAutoStart = autoStart; if ( changed ) { mPrefs->writeConfig(); } connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); } void KSyncManager::syncLocalFile() { QString fn =mPrefs->mLastSyncedLocalFile; QString ext; switch(mTargetApp) { case (KAPI): ext = "(*.vcf)"; break; case (KOPI): ext = "(*.ics/*.vcs)"; break; case (PWMPI): ext = "(*.pwm)"; break; @@ -1208,65 +1208,65 @@ void KServerSocket::send_file() 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!"))) { qDebug("cancelled "); return ; } } QFont f = label->font(); f.setPointSize ( f.pointSize() *2 ); f. setBold (true ); QLabel* label = new QLabel( warning, mSyncActionDialog ); label->setFont( f ); warning = i18n("ADJUST\nYOUR\nCLOCKS!"); label->setText( warning ); label->setAlignment ( Qt::AlignHCenter ); lay->addWidget( label); mSyncActionDialog->setFixedSize( 230, 300); } else { mSyncActionDialog->setFixedSize( 230, 200); } } else { mSyncActionDialog->setFixedSize( 230, 120); } } else mSyncActionDialog->setFixedSize( 230, 120); mSyncActionDialog->show(); mSyncActionDialog->raise(); emit request_file(); qApp->processEvents(); QString fileName = mFileName; QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { delete mSyncActionDialog; mSyncActionDialog = 0; - qDebug("KSS::error open file "); + qDebug("KSS::error open sync file: %s ", fileName.latin1()); mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); return ; } mSyncActionDialog->setCaption( i18n("Sending file...") ); QTextStream ts( &file ); ts.setEncoding( QTextStream::Latin1 ); QTextStream os( mSocket ); os.setEncoding( QTextStream::Latin1 ); while ( ! ts.atEnd() ) { os << ts.readLine() << "\r\n"; } //os << ts.read(); file.close(); mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); } void KServerSocket::get_file() { mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); piTime.start(); piFileString = ""; QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); } |