summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index a64eb34..719d80b 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -193,13 +193,14 @@ void KSyncManager::slotClearMenu( int action )
193 return; 193 return;
194 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
195} 195}
196void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
197{ 197{
198 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = ""; 199 mCurrentResourceLocal = "";
200 emit multiResourceSyncStart( false );
200 if ( action == 5000 ) 201 if ( action == 5000 )
201 return; 202 return;
202 mSyncWithDesktop = false; 203 mSyncWithDesktop = false;
203 if ( action == 0 ) { 204 if ( action == 0 ) {
204 205
205 // seems to be a Qt2 event handling bug 206 // seems to be a Qt2 event handling bug
@@ -438,12 +439,14 @@ void KSyncManager::enableQuick( bool ask )
438 mPrefs->mPassiveSyncAutoStart = autoStart; 439 mPrefs->mPassiveSyncAutoStart = autoStart;
439 if ( changed ) { 440 if ( changed ) {
440 mPrefs->writeConfig(); 441 mPrefs->writeConfig();
441 } 442 }
442 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 443 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
443 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 444 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
445 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) );
446 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) );
444} 447}
445void KSyncManager::displayErrorPort() 448void KSyncManager::displayErrorPort()
446{ 449{
447 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 450 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
448} 451}
449void KSyncManager::syncLocalFile() 452void KSyncManager::syncLocalFile()
@@ -566,13 +569,13 @@ void KSyncManager::multiSync( bool askforPrefs )
566 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 569 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
567 return; 570 return;
568} 571}
569 572
570int KSyncManager::ringSync() 573int KSyncManager::ringSync()
571{ 574{
572 575 emit multiResourceSyncStart( false );
573 int syncedProfiles = 0; 576 int syncedProfiles = 0;
574 unsigned int i; 577 unsigned int i;
575 QTime timer; 578 QTime timer;
576 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 579 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
577 QStringList syncProfileNames = mSyncProfileNames; 580 QStringList syncProfileNames = mSyncProfileNames;
578 KSyncProfile* temp = new KSyncProfile (); 581 KSyncProfile* temp = new KSyncProfile ();
@@ -1137,13 +1140,16 @@ void KSyncManager::syncPi()
1137 } 1140 }
1138 mCurrentResourceLocal = ""; 1141 mCurrentResourceLocal = "";
1139 mCurrentResourceRemote = ""; 1142 mCurrentResourceRemote = "";
1140 if ( mSpecificResources.count() ) { 1143 if ( mSpecificResources.count() ) {
1141 int startLocal = 0; 1144 int startLocal = 0;
1142 int startRemote = mSpecificResources.count()/2; 1145 int startRemote = mSpecificResources.count()/2;
1146 emit multiResourceSyncStart( true );
1143 while ( startLocal < mSpecificResources.count()/2 ) { 1147 while ( startLocal < mSpecificResources.count()/2 ) {
1148 if ( startLocal+1 >= mSpecificResources.count()/2 )
1149 emit multiResourceSyncStart( false );
1144 mPisyncFinished = false; 1150 mPisyncFinished = false;
1145 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1151 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1146 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1152 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1147 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1153 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1148 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1154 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1149 commandSocket->readFile( syncFileName() ); 1155 commandSocket->readFile( syncFileName() );
@@ -1216,13 +1222,13 @@ void KSyncManager::readFileFromSocket()
1216 bool syncOK = true; 1222 bool syncOK = true;
1217 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1223 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1218 if ( ! syncWithFile( fileName , true ) ) { 1224 if ( ! syncWithFile( fileName , true ) ) {
1219 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1225 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1220 syncOK = false; 1226 syncOK = false;
1221 } 1227 }
1222 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1228 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1223 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1229 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1224 if ( mWriteBackFile && syncOK ) { 1230 if ( mWriteBackFile && syncOK ) {
1225 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1231 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1226 commandSocket->writeFile( fileName ); 1232 commandSocket->writeFile( fileName );
1227 } 1233 }
1228 else { 1234 else {
@@ -1280,12 +1286,13 @@ void KServerSocket::readClient()
1280 } 1286 }
1281 if ( mErrorMessage ) { 1287 if ( mErrorMessage ) {
1282 mErrorMessage = 999; 1288 mErrorMessage = 999;
1283 error_connect("ERROR_ED\r\n\r\n"); 1289 error_connect("ERROR_ED\r\n\r\n");
1284 return; 1290 return;
1285 } 1291 }
1292 mResource = "";
1286 mErrorMessage = 0; 1293 mErrorMessage = 0;
1287 //qDebug("KServerSocket::readClient()"); 1294 //qDebug("KServerSocket::readClient()");
1288 if ( mSocket->canReadLine() ) { 1295 if ( mSocket->canReadLine() ) {
1289 QString line = mSocket->readLine(); 1296 QString line = mSocket->readLine();
1290 //qDebug("KServerSocket readline: %s ", line.latin1()); 1297 //qDebug("KServerSocket readline: %s ", line.latin1());
1291 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1298 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
@@ -1296,23 +1303,25 @@ void KServerSocket::readClient()
1296 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1303 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1297 if ( ok ) { 1304 if ( ok ) {
1298 KSyncManager::mRequestedSyncEvent = dt; 1305 KSyncManager::mRequestedSyncEvent = dt;
1299 } 1306 }
1300 else 1307 else
1301 KSyncManager::mRequestedSyncEvent = QDateTime(); 1308 KSyncManager::mRequestedSyncEvent = QDateTime();
1309 mResource =tokens[3];
1302 send_file(); 1310 send_file();
1303 } 1311 }
1304 else { 1312 else {
1305 mErrorMessage = 1; 1313 mErrorMessage = 1;
1306 error_connect("ERROR_PW\r\n\r\n"); 1314 error_connect("ERROR_PW\r\n\r\n");
1307 } 1315 }
1308 } 1316 }
1309 if ( tokens[0] == "PUT" ) { 1317 if ( tokens[0] == "PUT" ) {
1310 if ( tokens[1] == mPassWord ) { 1318 if ( tokens[1] == mPassWord ) {
1311 //emit getFile( mSocket ); 1319 //emit getFile( mSocket );
1312 blockRC = true; 1320 blockRC = true;
1321 mResource =tokens[2];
1313 get_file(); 1322 get_file();
1314 } 1323 }
1315 else { 1324 else {
1316 mErrorMessage = 2; 1325 mErrorMessage = 2;
1317 error_connect("ERROR_PW\r\n\r\n"); 1326 error_connect("ERROR_PW\r\n\r\n");
1318 end_connect(); 1327 end_connect();
@@ -1403,12 +1412,13 @@ void KServerSocket::send_file()
1403 mSyncActionDialog->setFixedSize( 230, 120); 1412 mSyncActionDialog->setFixedSize( 230, 120);
1404 } 1413 }
1405 } else 1414 } else
1406 mSyncActionDialog->setFixedSize( 230, 120); 1415 mSyncActionDialog->setFixedSize( 230, 120);
1407 mSyncActionDialog->show(); 1416 mSyncActionDialog->show();
1408 mSyncActionDialog->raise(); 1417 mSyncActionDialog->raise();
1418 emit request_file(mResource);
1409 emit request_file(); 1419 emit request_file();
1410 qApp->processEvents(); 1420 qApp->processEvents();
1411 QString fileName = mFileName; 1421 QString fileName = mFileName;
1412 QFile file( fileName ); 1422 QFile file( fileName );
1413 if (!file.open( IO_ReadOnly ) ) { 1423 if (!file.open( IO_ReadOnly ) ) {
1414 mErrorMessage = 0; 1424 mErrorMessage = 0;
@@ -1464,13 +1474,14 @@ void KServerSocket::readBackFileFromSocket()
1464 QFile file ( fileName ); 1474 QFile file ( fileName );
1465 if (!file.open( IO_WriteOnly ) ) { 1475 if (!file.open( IO_WriteOnly ) ) {
1466 delete mSyncActionDialog; 1476 delete mSyncActionDialog;
1467 mSyncActionDialog = 0; 1477 mSyncActionDialog = 0;
1468 qDebug("KSS:Error open read back file "); 1478 qDebug("KSS:Error open read back file ");
1469 piFileString = ""; 1479 piFileString = "";
1470 emit file_received( false ); 1480 emit file_received( false, mResource);
1481 emit file_received( false);
1471 blockRC = false; 1482 blockRC = false;
1472 return ; 1483 return ;
1473 1484
1474 } 1485 }
1475 1486
1476 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1487 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
@@ -1480,13 +1491,14 @@ void KServerSocket::readBackFileFromSocket()
1480 ts << piFileString; 1491 ts << piFileString;
1481 mSocket->close(); 1492 mSocket->close();
1482 if ( mSocket->state() == QSocket::Idle ) 1493 if ( mSocket->state() == QSocket::Idle )
1483 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1494 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1484 file.close(); 1495 file.close();
1485 piFileString = ""; 1496 piFileString = "";
1486 emit file_received( true ); 1497 emit file_received( true, mResource );
1498 emit file_received( true);
1487 delete mSyncActionDialog; 1499 delete mSyncActionDialog;
1488 mSyncActionDialog = 0; 1500 mSyncActionDialog = 0;
1489 blockRC = false; 1501 blockRC = false;
1490 1502
1491} 1503}
1492 1504
@@ -1593,13 +1605,13 @@ void KCommandSocket::writeFileToSocket()
1593 mConnectProgress.setProgress( count ); 1605 mConnectProgress.setProgress( count );
1594 mConnectProgress.blockSignals( true ); 1606 mConnectProgress.blockSignals( true );
1595 QTextStream ts2( &file2 ); 1607 QTextStream ts2( &file2 );
1596 ts2.setEncoding( QTextStream::Latin1 ); 1608 ts2.setEncoding( QTextStream::Latin1 );
1597 QTextStream os2( mSocket ); 1609 QTextStream os2( mSocket );
1598 os2.setEncoding( QTextStream::Latin1 ); 1610 os2.setEncoding( QTextStream::Latin1 );
1599 os2 << "PUT " << mPassWord << "\r\n\r\n";; 1611 os2 << "PUT " << mPassWord << mRemoteResource << "\r\n\r\n";;
1600 int byteCount = 0; 1612 int byteCount = 0;
1601 int byteMax = file2.size()/53; 1613 int byteMax = file2.size()/53;
1602 while ( ! ts2.atEnd() ) { 1614 while ( ! ts2.atEnd() ) {
1603 qApp->processEvents(); 1615 qApp->processEvents();
1604 if ( byteCount > byteMax ) { 1616 if ( byteCount > byteMax ) {
1605 byteCount = 0; 1617 byteCount = 0;