summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
authorzautrix <zautrix>2004-10-28 17:07:24 (UTC)
committer zautrix <zautrix>2004-10-28 17:07:24 (UTC)
commit709e2793be2dd47dc0a15488f43fd2f058db2036 (patch) (unidiff)
treef2f90d42bd0125d73bb57f5e3d1c3e1bd9d05196 /libkdepim/ksyncmanager.cpp
parent4254a88dbb00ebf5f5b323e1ddddf3491e3fdb24 (diff)
downloadkdepimpi-709e2793be2dd47dc0a15488f43fd2f058db2036.zip
kdepimpi-709e2793be2dd47dc0a15488f43fd2f058db2036.tar.gz
kdepimpi-709e2793be2dd47dc0a15488f43fd2f058db2036.tar.bz2
showing clcok skew in pisync
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 9857e3e..9a1f2a9 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -342,24 +342,25 @@ void KSyncManager::enableQuick( bool ask )
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#else 355#else
355 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 );
356#endif 357#endif
357 lay.addWidget( &syncdesktop); 358 lay.addWidget( &syncdesktop);
358#else 359#else
359 mPrefs->mPassiveSyncWithDesktop = false; 360 mPrefs->mPassiveSyncWithDesktop = false;
360 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 361 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
361 syncdesktop.hide(); 362 syncdesktop.hide();
362#endif 363#endif
363 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 364 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
364 365
365 dia.setFixedSize( 230,120 ); 366 dia.setFixedSize( 230,120 );
@@ -564,31 +565,33 @@ int KSyncManager::ringSync()
564 qDebug("KSyncManager::ringSync: invalid apptype selected"); 565 qDebug("KSyncManager::ringSync: invalid apptype selected");
565 break; 566 break;
566 567
567 } 568 }
568 569
569 570
570 if ( includeInRingSync && ( i < 1 || i > 2 )) { 571 if ( includeInRingSync && ( i < 1 || i > 2 )) {
571 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 572 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
572 ++syncedProfiles; 573 ++syncedProfiles;
573 // mAskForPreferences = temp->getAskForPreferences(); 574 // mAskForPreferences = temp->getAskForPreferences();
574 mWriteBackFile = temp->getWriteBackFile(); 575 mWriteBackFile = temp->getWriteBackFile();
575 mWriteBackExistingOnly = temp->getWriteBackExisting(); 576 mWriteBackExistingOnly = temp->getWriteBackExisting();
577 mIsKapiFile = temp->getIsKapiFile();
576 mWriteBackInFuture = 0; 578 mWriteBackInFuture = 0;
577 if ( temp->getWriteBackFuture() ) 579 if ( temp->getWriteBackFuture() )
578 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 580 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
579 mShowSyncSummary = false; 581 mShowSyncSummary = false;
580 mCurrentSyncDevice = syncProfileNames[i] ; 582 mCurrentSyncDevice = syncProfileNames[i] ;
581 mCurrentSyncName = mLocalMachineName; 583 mCurrentSyncName = mLocalMachineName;
582 if ( i == 0 ) { 584 if ( i == 0 ) {
585 mIsKapiFile = false;
583#ifdef DESKTOP_VERSION 586#ifdef DESKTOP_VERSION
584 syncKDE(); 587 syncKDE();
585#else 588#else
586 syncSharp(); 589 syncSharp();
587#endif 590#endif
588 } else { 591 } else {
589 if ( temp->getIsLocalFileSync() ) { 592 if ( temp->getIsLocalFileSync() ) {
590 switch(mTargetApp) 593 switch(mTargetApp)
591 { 594 {
592 case (KAPI): 595 case (KAPI):
593 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 596 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
594 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 597 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
@@ -1012,24 +1015,25 @@ QString KSyncManager::syncFileName()
1012 default: 1015 default:
1013 break; 1016 break;
1014 } 1017 }
1015#ifdef _WIN32_ 1018#ifdef _WIN32_
1016 return locateLocal( "tmp", fn ); 1019 return locateLocal( "tmp", fn );
1017#else 1020#else
1018 return (QString( "/tmp/" )+ fn ); 1021 return (QString( "/tmp/" )+ fn );
1019#endif 1022#endif
1020} 1023}
1021 1024
1022void KSyncManager::syncPi() 1025void KSyncManager::syncPi()
1023{ 1026{
1027 mIsKapiFile = true;
1024 mPisyncFinished = false; 1028 mPisyncFinished = false;
1025 qApp->processEvents(); 1029 qApp->processEvents();
1026 if ( mAskForPreferences ) 1030 if ( mAskForPreferences )
1027 if ( !edit_pisync_options()) { 1031 if ( !edit_pisync_options()) {
1028 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1032 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1029 return; 1033 return;
1030 } 1034 }
1031 bool ok; 1035 bool ok;
1032 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1036 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1033 if ( ! ok ) { 1037 if ( ! ok ) {
1034 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1038 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1035 return; 1039 return;
@@ -1129,26 +1133,27 @@ void KServerSocket::readClient()
1129 return; 1133 return;
1130 } 1134 }
1131 //qDebug("KServerSocket::readClient()"); 1135 //qDebug("KServerSocket::readClient()");
1132 if ( mSocket->canReadLine() ) { 1136 if ( mSocket->canReadLine() ) {
1133 QString line = mSocket->readLine(); 1137 QString line = mSocket->readLine();
1134 //qDebug("KServerSocket readline: %s ", line.latin1()); 1138 //qDebug("KServerSocket readline: %s ", line.latin1());
1135 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1139 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1136 if ( tokens[0] == "GET" ) { 1140 if ( tokens[0] == "GET" ) {
1137 if ( tokens[1] == mPassWord ) { 1141 if ( tokens[1] == mPassWord ) {
1138 //emit sendFile( mSocket ); 1142 //emit sendFile( mSocket );
1139 bool ok = false; 1143 bool ok = false;
1140 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1144 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1141 if ( ok ) 1145 if ( ok ) {
1142 KSyncManager::mRequestedSyncEvent = dt; 1146 KSyncManager::mRequestedSyncEvent = dt;
1147 }
1143 else 1148 else
1144 KSyncManager::mRequestedSyncEvent = QDateTime(); 1149 KSyncManager::mRequestedSyncEvent = QDateTime();
1145 send_file(); 1150 send_file();
1146 } 1151 }
1147 else { 1152 else {
1148 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 1153 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
1149 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1154 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1150 } 1155 }
1151 } 1156 }
1152 if ( tokens[0] == "PUT" ) { 1157 if ( tokens[0] == "PUT" ) {
1153 if ( tokens[1] == mPassWord ) { 1158 if ( tokens[1] == mPassWord ) {
1154 //emit getFile( mSocket ); 1159 //emit getFile( mSocket );
@@ -1174,25 +1179,45 @@ void KServerSocket::end_connect()
1174void KServerSocket::send_file() 1179void KServerSocket::send_file()
1175{ 1180{
1176 //qDebug("MainWindow::sendFile(QSocket* s) "); 1181 //qDebug("MainWindow::sendFile(QSocket* s) ");
1177 if ( mSyncActionDialog ) 1182 if ( mSyncActionDialog )
1178 delete mSyncActionDialog; 1183 delete mSyncActionDialog;
1179 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1184 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1180 mSyncActionDialog->setCaption(i18n("Received sync request")); 1185 mSyncActionDialog->setCaption(i18n("Received sync request"));
1181 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1186 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1182 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1187 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1183 lay->addWidget( label); 1188 lay->addWidget( label);
1184 lay->setMargin(7); 1189 lay->setMargin(7);
1185 lay->setSpacing(7); 1190 lay->setSpacing(7);
1186 mSyncActionDialog->setFixedSize( 230, 120); 1191 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1192 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1193 //if ( secs > 30 )
1194 if ( true )
1195 {
1196 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1197 QLabel* label = new QLabel( warning, mSyncActionDialog );
1198 if ( secs > 600 )
1199 {
1200 QFont f = label->font();
1201 f. setBold (true );
1202 f.setPointSize ( f.pointSize() + 10);
1203 label->setFont( f );
1204 }
1205 lay->addWidget( label);
1206 mSyncActionDialog->setFixedSize( 230, 200);
1207 } else {
1208 mSyncActionDialog->setFixedSize( 230, 120);
1209 }
1210 } else
1211 mSyncActionDialog->setFixedSize( 230, 120);
1187 mSyncActionDialog->show(); 1212 mSyncActionDialog->show();
1188 mSyncActionDialog->raise(); 1213 mSyncActionDialog->raise();
1189 emit request_file(); 1214 emit request_file();
1190 qApp->processEvents(); 1215 qApp->processEvents();
1191 QString fileName = mFileName; 1216 QString fileName = mFileName;
1192 QFile file( fileName ); 1217 QFile file( fileName );
1193 if (!file.open( IO_ReadOnly ) ) { 1218 if (!file.open( IO_ReadOnly ) ) {
1194 delete mSyncActionDialog; 1219 delete mSyncActionDialog;
1195 mSyncActionDialog = 0; 1220 mSyncActionDialog = 0;
1196 qDebug("KSS::error open file "); 1221 qDebug("KSS::error open file ");
1197 mSocket->close(); 1222 mSocket->close();
1198 if ( mSocket->state() == QSocket::Idle ) 1223 if ( mSocket->state() == QSocket::Idle )
@@ -1289,25 +1314,25 @@ void KCommandSocket::readFile( QString fn )
1289 if ( !mSocket ) { 1314 if ( !mSocket ) {
1290 mSocket = new QSocket( this ); 1315 mSocket = new QSocket( this );
1291 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1316 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1292 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1317 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1293 } 1318 }
1294 mFileString = ""; 1319 mFileString = "";
1295 mFileName = fn; 1320 mFileName = fn;
1296 mFirst = true; 1321 mFirst = true;
1297 mSocket->connectToHost( mHost, mPort ); 1322 mSocket->connectToHost( mHost, mPort );
1298 QTextStream os( mSocket ); 1323 QTextStream os( mSocket );
1299 os.setEncoding( QTextStream::Latin1 ); 1324 os.setEncoding( QTextStream::Latin1 );
1300 1325
1301 QString curDt = KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1326 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1302 os << "GET " << mPassWord << curDt <<"\r\n"; 1327 os << "GET " << mPassWord << curDt <<"\r\n";
1303 mTimerSocket->start( 20000 ); 1328 mTimerSocket->start( 20000 );
1304} 1329}
1305 1330
1306void KCommandSocket::writeFile( QString fileName ) 1331void KCommandSocket::writeFile( QString fileName )
1307{ 1332{
1308 if ( !mSocket ) { 1333 if ( !mSocket ) {
1309 mSocket = new QSocket( this ); 1334 mSocket = new QSocket( this );
1310 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1335 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1311 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1336 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1312 } 1337 }
1313 mFileName = fileName ; 1338 mFileName = fileName ;