summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 61a9899..795cd30 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1131,52 +1131,57 @@ void KSyncManager::syncPi()
1131 mPisyncFinished = true; 1131 mPisyncFinished = true;
1132 return; 1132 return;
1133 } 1133 }
1134 bool ok; 1134 bool ok;
1135 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1135 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1136 if ( ! ok ) { 1136 if ( ! ok ) {
1137 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1137 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1138 mPisyncFinished = true; 1138 mPisyncFinished = true;
1139 return; 1139 return;
1140 } 1140 }
1141 mCurrentResourceLocal = ""; 1141 mCurrentResourceLocal = "";
1142 mCurrentResourceRemote = ""; 1142 mCurrentResourceRemote = "";
1143 qDebug ( "KSM: sync pi %d",mSpecificResources.count() );
1143 if ( mSpecificResources.count() ) { 1144 if ( mSpecificResources.count() ) {
1144 int lastSyncRes = mSpecificResources.count()/2; 1145 int lastSyncRes = mSpecificResources.count()/2;
1145 int ccc = mSpecificResources.count()-1; 1146 int ccc = mSpecificResources.count()-1;
1146 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { 1147 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) {
1147 --ccc; 1148 --ccc;
1148 --lastSyncRes; 1149 --lastSyncRes;
1150 qDebug ( "KSM: sync pi %d",ccc );
1149 } 1151 }
1150 int startLocal = 0; 1152 int startLocal = 0;
1151 int startRemote = mSpecificResources.count()/2; 1153 int startRemote = mSpecificResources.count()/2;
1152 emit multiResourceSyncStart( true ); 1154 emit multiResourceSyncStart( true );
1153 while ( startLocal < mSpecificResources.count()/2 ) { 1155 while ( startLocal < mSpecificResources.count()/2 ) {
1154 if ( startLocal+1 >= lastSyncRes ) 1156 if ( startLocal+1 >= lastSyncRes )
1155 emit multiResourceSyncStart( false ); 1157 emit multiResourceSyncStart( false );
1156 mPisyncFinished = false; 1158 mPisyncFinished = false;
1157 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1159 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1158 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1160 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1161 qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1159 if ( !mCurrentResourceRemote.isEmpty() ) { 1162 if ( !mCurrentResourceRemote.isEmpty() ) {
1160 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1163 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1161 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1164 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1162 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1165 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1163 commandSocket->readFile( syncFileName() ); 1166 commandSocket->readFile( syncFileName() );
1164 while ( !mPisyncFinished ) { 1167 while ( !mPisyncFinished ) {
1165 //qDebug("waiting "); 1168 //qDebug("waiting ");
1166 qApp->processEvents(); 1169 qApp->processEvents();
1167 } 1170 }
1168 } 1171 }
1172 ++startRemote;
1169 ++startLocal; 1173 ++startLocal;
1170 } 1174 }
1175 mPisyncFinished = true;
1171 } else { 1176 } else {
1172 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1177 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1173 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1178 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1174 commandSocket->readFile( syncFileName() ); 1179 commandSocket->readFile( syncFileName() );
1175 } 1180 }
1176} 1181}
1177 1182
1178void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1183void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1179{ 1184{
1180 //enum { success, errorW, errorR, quiet }; 1185 //enum { success, errorW, errorR, quiet };
1181 1186
1182 1187
@@ -1507,24 +1512,26 @@ void KServerSocket::readBackFileFromSocket()
1507 emit file_received( true); 1512 emit file_received( true);
1508 delete mSyncActionDialog; 1513 delete mSyncActionDialog;
1509 mSyncActionDialog = 0; 1514 mSyncActionDialog = 0;
1510 blockRC = false; 1515 blockRC = false;
1511 1516
1512} 1517}
1513 1518
1514KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1519KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1515{ 1520{
1516 mRemoteResource = remres; 1521 mRemoteResource = remres;
1517 if ( mRemoteResource.isEmpty() ) 1522 if ( mRemoteResource.isEmpty() )
1518 mRemoteResource = "ALL"; 1523 mRemoteResource = "ALL";
1524 else
1525 mRemoteResource.replace (QRegExp (" "),"_" );
1519 mPassWord = password; 1526 mPassWord = password;
1520 mSocket = 0; 1527 mSocket = 0;
1521 mFirst = false; 1528 mFirst = false;
1522 mFirstLine = true; 1529 mFirstLine = true;
1523 mPort = port; 1530 mPort = port;
1524 mHost = host; 1531 mHost = host;
1525 tlw = cap; 1532 tlw = cap;
1526 mRetVal = quiet; 1533 mRetVal = quiet;
1527 mTimerSocket = new QTimer ( this ); 1534 mTimerSocket = new QTimer ( this );
1528 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); 1535 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
1529 mConnectProgress.setCaption( i18n("Pi-Sync") ); 1536 mConnectProgress.setCaption( i18n("Pi-Sync") );
1530 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); 1537 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
@@ -1533,25 +1540,25 @@ KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port
1533void KCommandSocket::sendFileRequest() 1540void KCommandSocket::sendFileRequest()
1534{ 1541{
1535 if ( tlw ) 1542 if ( tlw )
1536 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1543 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1537 mConnectProgress.hide(); 1544 mConnectProgress.hide();
1538 mConnectCount = 300;mConnectMax = 300; 1545 mConnectCount = 300;mConnectMax = 300;
1539 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1546 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1540 mTimerSocket->start( 100, true ); 1547 mTimerSocket->start( 100, true );
1541 QTextStream os( mSocket ); 1548 QTextStream os( mSocket );
1542 os.setEncoding( QTextStream::Latin1 ); 1549 os.setEncoding( QTextStream::Latin1 );
1543 1550
1544 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1551 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1545 os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n"; 1552 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n";
1546} 1553}
1547 1554
1548void KCommandSocket::readFile( QString fn ) 1555void KCommandSocket::readFile( QString fn )
1549{ 1556{
1550 if ( !mSocket ) { 1557 if ( !mSocket ) {
1551 mSocket = new QSocket( this ); 1558 mSocket = new QSocket( this );
1552 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1559 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1553 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1560 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1554 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1561 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1555 } 1562 }
1556 mFileString = ""; 1563 mFileString = "";
1557 mFileName = fn; 1564 mFileName = fn;
@@ -1608,25 +1615,25 @@ void KCommandSocket::writeFileToSocket()
1608 return ; 1615 return ;
1609 } 1616 }
1610 mConnectProgress.setTotalSteps ( file2.size() ); 1617 mConnectProgress.setTotalSteps ( file2.size() );
1611 mConnectProgress.show(); 1618 mConnectProgress.show();
1612 int count = 0; 1619 int count = 0;
1613 mConnectProgress.setLabelText( i18n("Sending back synced file...") ); 1620 mConnectProgress.setLabelText( i18n("Sending back synced file...") );
1614 mConnectProgress.setProgress( count ); 1621 mConnectProgress.setProgress( count );
1615 mConnectProgress.blockSignals( true ); 1622 mConnectProgress.blockSignals( true );
1616 QTextStream ts2( &file2 ); 1623 QTextStream ts2( &file2 );
1617 ts2.setEncoding( QTextStream::Latin1 ); 1624 ts2.setEncoding( QTextStream::Latin1 );
1618 QTextStream os2( mSocket ); 1625 QTextStream os2( mSocket );
1619 os2.setEncoding( QTextStream::Latin1 ); 1626 os2.setEncoding( QTextStream::Latin1 );
1620 os2 << "PUT " << mPassWord << mRemoteResource << "\r\n\r\n";; 1627 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";;
1621 int byteCount = 0; 1628 int byteCount = 0;
1622 int byteMax = file2.size()/53; 1629 int byteMax = file2.size()/53;
1623 while ( ! ts2.atEnd() ) { 1630 while ( ! ts2.atEnd() ) {
1624 qApp->processEvents(); 1631 qApp->processEvents();
1625 if ( byteCount > byteMax ) { 1632 if ( byteCount > byteMax ) {
1626 byteCount = 0; 1633 byteCount = 0;
1627 mConnectProgress.setProgress( count ); 1634 mConnectProgress.setProgress( count );
1628 } 1635 }
1629 QString temp = ts2.readLine(); 1636 QString temp = ts2.readLine();
1630 count += temp.length(); 1637 count += temp.length();
1631 byteCount += temp.length(); 1638 byteCount += temp.length();
1632 os2 << temp << "\r\n"; 1639 os2 << temp << "\r\n";