summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt10
-rw-r--r--libkdepim/ksyncmanager.cpp43
-rw-r--r--libkdepim/ksyncmanager.h6
3 files changed, 42 insertions, 17 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index 2275f3a..4f29ca3 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -1205,30 +1205,40 @@
1205{ "<p><i>Completed on %1</i></p>","<p><i>Erledigt am %1</i></p>" }, 1205{ "<p><i>Completed on %1</i></p>","<p><i>Erledigt am %1</i></p>" },
1206{ "Default todo done color:","Standard Todo erledigt Farbe" }, 1206{ "Default todo done color:","Standard Todo erledigt Farbe" },
1207{ "Select week %1-%2","Wähle Woche %1-%2" }, 1207{ "Select week %1-%2","Wähle Woche %1-%2" },
1208{ "Select Week","Wähle Woche" }, 1208{ "Select Week","Wähle Woche" },
1209{ "Set alarm for selected...","Setze Alarm für Selekt..." }, 1209{ "Set alarm for selected...","Setze Alarm für Selekt..." },
1210{ "Set Alarm!","Setze Alarm!" }, 1210{ "Set Alarm!","Setze Alarm!" },
1211{ "Canged alarm for %1 items","Alarm für %1 Items geändert" }, 1211{ "Canged alarm for %1 items","Alarm für %1 Items geändert" },
1212{ " and "," und " }, 1212{ " and "," und " },
1213{ "<IMG src="%1"> only )","nur <IMG src="%1"> )" }, 1213{ "<IMG src="%1"> only )","nur <IMG src="%1"> )" },
1214{ "Mail to selected","Mail an Ausgewählte" }, 1214{ "Mail to selected","Mail an Ausgewählte" },
1215{ "Mail to all","Mail an Alle" }, 1215{ "Mail to all","Mail an Alle" },
1216{ "Week view mode uses bigger font","Wochenansicht Modus nutzt größeren Font" }, 1216{ "Week view mode uses bigger font","Wochenansicht Modus nutzt größeren Font" },
1217{ "Set reminder ON with offset to:","Alarm AN mit Offset auf:" }, 1217{ "Set reminder ON with offset to:","Alarm AN mit Offset auf:" },
1218{ " on"," am" }, 1218{ " on"," am" },
1219{ " completed on "," erledigt am " }, 1219{ " completed on "," erledigt am " },
1220{ "Save as Event template","Speichere als Vorlage" }, 1220{ "Save as Event template","Speichere als Vorlage" },
1221{ "Load Event template","Lade Termin Vorlage" }, 1221{ "Load Event template","Lade Termin Vorlage" },
1222{ "Save as Journal template","Speichere als Journal Vorlage" }, 1222{ "Save as Journal template","Speichere als Journal Vorlage" },
1223{ "Insert Journal template","Füge Journal Vorlage ein" }, 1223{ "Insert Journal template","Füge Journal Vorlage ein" },
1224{ "Sub todos:<br>","Unter Todos:<br>" }, 1224{ "Sub todos:<br>","Unter Todos:<br>" },
1225{ "Parent todo:<br>","Über Todo:<br>" }, 1225{ "Parent todo:<br>","Über Todo:<br>" },
1226{ "Set current as color category","Setze Gewählte als Farbkategorie" }, 1226{ "Set current as color category","Setze Gewählte als Farbkategorie" },
1227{ " completed"," erledigt" }, 1227{ " completed"," erledigt" },
1228{ "(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.net --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!","(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi basiert auf KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) und das KDE Team.\nKOrganizer/Pi ist lizensiert unter der GPL.\nKO/Pi kann kompiliert werden für\nLinux, Zaurus-PDA und Windows\nwww.pi-sync.net --- www.korganizer.org\nBesonderen Dank an Michael und Ben\nfür intensives Testen!" }, 1228{ "(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.net --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!","(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi basiert auf KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) und das KDE Team.\nKOrganizer/Pi ist lizensiert unter der GPL.\nKO/Pi kann kompiliert werden für\nLinux, Zaurus-PDA und Windows\nwww.pi-sync.net --- www.korganizer.org\nBesonderen Dank an Michael und Ben\nfür intensives Testen!" },
1229{ "Syncing aborted. Nothing synced.","Syncing abgebrochen.Nichts wurde gesynct." },
1230{ "Connected! Sending request for remote file ...","Verbunden! Sende Daten Anfrage..." },
1231{ "Trying to connect to remote...","Versuche mit Gegenstelle zu verbinden..." },
1232{ "Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?","Verbindungsversuch wegen\nZeitüberschreitung gescheitert!\nWurde vergessen Pi-Sync auf\nder Gegenstelle anzuschalten?" },
1233{ "ERROR: Receiving remote file failed.","FEHLER: Empfang der entfernten Daten fehlgeschlagen." },
1234{ "Error","Fehler" },
1235{ "","" },
1236{ "","" },
1237{ "","" },
1238{ "","" },
1229{ "","" }, 1239{ "","" },
1230{ "","" }, 1240{ "","" },
1231{ "","" }, 1241{ "","" },
1232{ "","" }, 1242{ "","" },
1233{ "","" }, 1243{ "","" },
1234{ "","" }, 1244{ "","" },
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index df5a0d9..1f5f4c7 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1031,93 +1031,92 @@ QString KSyncManager::syncFileName()
1031 } 1031 }
1032#ifdef _WIN32_ 1032#ifdef _WIN32_
1033 return locateLocal( "tmp", fn ); 1033 return locateLocal( "tmp", fn );
1034#else 1034#else
1035 return (QString( "/tmp/" )+ fn ); 1035 return (QString( "/tmp/" )+ fn );
1036#endif 1036#endif
1037} 1037}
1038 1038
1039void KSyncManager::syncPi() 1039void KSyncManager::syncPi()
1040{ 1040{
1041 mIsKapiFile = true; 1041 mIsKapiFile = true;
1042 mPisyncFinished = false; 1042 mPisyncFinished = false;
1043 qApp->processEvents(); 1043 qApp->processEvents();
1044 if ( mAskForPreferences ) 1044 if ( mAskForPreferences )
1045 if ( !edit_pisync_options()) { 1045 if ( !edit_pisync_options()) {
1046 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1046 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1047 return; 1047 return;
1048 } 1048 }
1049 bool ok; 1049 bool ok;
1050 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1050 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1051 if ( ! ok ) { 1051 if ( ! ok ) {
1052 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1052 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1053 return; 1053 return;
1054 } 1054 }
1055 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 1055 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1056 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1056 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1057 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
1058 commandSocket->readFile( syncFileName() ); 1057 commandSocket->readFile( syncFileName() );
1059} 1058}
1060 1059
1061void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1060void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1062{ 1061{
1063 //enum { success, errorW, errorR, quiet }; 1062 //enum { success, errorW, errorR, quiet };
1064 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 1063 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
1065 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1064 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1066 delete s; 1065 delete s;
1067 if ( state == KCommandSocket::errorR ) { 1066 if ( state == KCommandSocket::errorR ) {
1068 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1067 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1069 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1068 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1070 commandSocket->sendStop(); 1069 commandSocket->sendStop();
1071 } 1070 }
1072 mPisyncFinished = true; 1071 mPisyncFinished = true;
1073 return; 1072 return;
1074 1073
1075 } else if ( state == KCommandSocket::errorW ) { 1074 } else if ( state == KCommandSocket::errorW ) {
1076 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1075 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1077 mPisyncFinished = true; 1076 mPisyncFinished = true;
1078 1077
1079 } else if ( state == KCommandSocket::successR ) { 1078 } else if ( state == KCommandSocket::successR ) {
1080 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1079 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1081 1080
1082 } else if ( state == KCommandSocket::successW ) { 1081 } else if ( state == KCommandSocket::successW ) {
1083 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1082 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1084 mPisyncFinished = true; 1083 mPisyncFinished = true;
1085 } 1084 }
1086 1085
1087 delete s; 1086 delete s;
1088} 1087}
1089 1088
1090void KSyncManager::readFileFromSocket() 1089void KSyncManager::readFileFromSocket()
1091{ 1090{
1092 QString fileName = syncFileName(); 1091 QString fileName = syncFileName();
1093 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1092 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1094 if ( ! syncWithFile( fileName , true ) ) { 1093 if ( ! syncWithFile( fileName , true ) ) {
1095 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1094 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1096 mPisyncFinished = true; 1095 mPisyncFinished = true;
1097 return; 1096 return;
1098 } 1097 }
1099 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1098 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1100 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1099 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1101 if ( mWriteBackFile ) 1100 if ( mWriteBackFile )
1102 commandSocket->writeFile( fileName ); 1101 commandSocket->writeFile( fileName );
1103 else { 1102 else {
1104 commandSocket->sendStop(); 1103 commandSocket->sendStop();
1105 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1104 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1106 mPisyncFinished = true; 1105 mPisyncFinished = true;
1107 } 1106 }
1108} 1107}
1109 1108
1110KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1109KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1111{ 1110{
1112 mPassWord = pw; 1111 mPassWord = pw;
1113 mSocket = 0; 1112 mSocket = 0;
1114 mSyncActionDialog = 0; 1113 mSyncActionDialog = 0;
1115 blockRC = false; 1114 blockRC = false;
1116}; 1115};
1117 1116
1118void KServerSocket::newConnection ( int socket ) 1117void KServerSocket::newConnection ( int socket )
1119{ 1118{
1120 // qDebug("KServerSocket:New connection %d ", socket); 1119 // qDebug("KServerSocket:New connection %d ", socket);
1121 if ( mSocket ) { 1120 if ( mSocket ) {
1122 qDebug("KSS::newConnection Socket deleted! "); 1121 qDebug("KSS::newConnection Socket deleted! ");
1123 delete mSocket; 1122 delete mSocket;
@@ -1242,49 +1241,49 @@ void KServerSocket::send_file()
1242 mSyncActionDialog->setFixedSize( 230, 120); 1241 mSyncActionDialog->setFixedSize( 230, 120);
1243 mSyncActionDialog->show(); 1242 mSyncActionDialog->show();
1244 mSyncActionDialog->raise(); 1243 mSyncActionDialog->raise();
1245 emit request_file(); 1244 emit request_file();
1246 qApp->processEvents(); 1245 qApp->processEvents();
1247 QString fileName = mFileName; 1246 QString fileName = mFileName;
1248 QFile file( fileName ); 1247 QFile file( fileName );
1249 if (!file.open( IO_ReadOnly ) ) { 1248 if (!file.open( IO_ReadOnly ) ) {
1250 delete mSyncActionDialog; 1249 delete mSyncActionDialog;
1251 mSyncActionDialog = 0; 1250 mSyncActionDialog = 0;
1252 qDebug("KSS::error open sync file: %s ", fileName.latin1()); 1251 qDebug("KSS::error open sync file: %s ", fileName.latin1());
1253 mSocket->close(); 1252 mSocket->close();
1254 if ( mSocket->state() == QSocket::Idle ) 1253 if ( mSocket->state() == QSocket::Idle )
1255 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1254 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1256 return ; 1255 return ;
1257 1256
1258 } 1257 }
1259 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1258 mSyncActionDialog->setCaption( i18n("Sending file...") );
1260 QTextStream ts( &file ); 1259 QTextStream ts( &file );
1261 ts.setEncoding( QTextStream::Latin1 ); 1260 ts.setEncoding( QTextStream::Latin1 );
1262 1261
1263 QTextStream os( mSocket ); 1262 QTextStream os( mSocket );
1264 os.setEncoding( QTextStream::Latin1 ); 1263 os.setEncoding( QTextStream::Latin1 );
1265 while ( ! ts.atEnd() ) { 1264 while ( ! ts.atEnd() ) {
1266 os << ts.readLine() << "\r\n"; 1265 os << ts.readLine() << "\r\n\r\n";
1267 } 1266 }
1268 //os << ts.read(); 1267 //os << ts.read();
1269 file.close(); 1268 file.close();
1270 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1269 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1271 mSocket->close(); 1270 mSocket->close();
1272 if ( mSocket->state() == QSocket::Idle ) 1271 if ( mSocket->state() == QSocket::Idle )
1273 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1272 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1274} 1273}
1275void KServerSocket::get_file() 1274void KServerSocket::get_file()
1276{ 1275{
1277 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1276 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1278 1277
1279 piTime.start(); 1278 piTime.start();
1280 piFileString = ""; 1279 piFileString = "";
1281 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1280 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1282} 1281}
1283 1282
1284 1283
1285void KServerSocket::readBackFileFromSocket() 1284void KServerSocket::readBackFileFromSocket()
1286{ 1285{
1287 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1286 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1288 while ( mSocket->canReadLine () ) { 1287 while ( mSocket->canReadLine () ) {
1289 piTime.restart(); 1288 piTime.restart();
1290 QString line = mSocket->readLine (); 1289 QString line = mSocket->readLine ();
@@ -1308,122 +1307,134 @@ void KServerSocket::readBackFileFromSocket()
1308 piFileString = ""; 1307 piFileString = "";
1309 emit file_received( false ); 1308 emit file_received( false );
1310 blockRC = false; 1309 blockRC = false;
1311 return ; 1310 return ;
1312 1311
1313 } 1312 }
1314 1313
1315 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1314 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1316 QTextStream ts ( &file ); 1315 QTextStream ts ( &file );
1317 ts.setEncoding( QTextStream::Latin1 ); 1316 ts.setEncoding( QTextStream::Latin1 );
1318 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1317 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1319 ts << piFileString; 1318 ts << piFileString;
1320 mSocket->close(); 1319 mSocket->close();
1321 if ( mSocket->state() == QSocket::Idle ) 1320 if ( mSocket->state() == QSocket::Idle )
1322 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1321 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1323 file.close(); 1322 file.close();
1324 piFileString = ""; 1323 piFileString = "";
1325 emit file_received( true ); 1324 emit file_received( true );
1326 delete mSyncActionDialog; 1325 delete mSyncActionDialog;
1327 mSyncActionDialog = 0; 1326 mSyncActionDialog = 0;
1328 blockRC = false; 1327 blockRC = false;
1329 1328
1330} 1329}
1331 1330
1332KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1331KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1333{ 1332{
1334 mPassWord = password; 1333 mPassWord = password;
1335 mSocket = 0; 1334 mSocket = 0;
1335 mFirst = false;
1336 mPort = port; 1336 mPort = port;
1337 mHost = host; 1337 mHost = host;
1338 1338 tlw = cap;
1339 mRetVal = quiet; 1339 mRetVal = quiet;
1340 mTimerSocket = new QTimer ( this ); 1340 mTimerSocket = new QTimer ( this );
1341 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1341 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1342} 1342}
1343void KCommandSocket::sendFileRequest()
1344{
1345 if ( tlw )
1346 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1347 mTimerSocket->start( 300000 );
1348 QTextStream os( mSocket );
1349 os.setEncoding( QTextStream::Latin1 );
1350
1351 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1352 os << "GET " << mPassWord << curDt <<"\r\n\r\n";
1353}
1354
1343void KCommandSocket::readFile( QString fn ) 1355void KCommandSocket::readFile( QString fn )
1344{ 1356{
1345 if ( !mSocket ) { 1357 if ( !mSocket ) {
1346 mSocket = new QSocket( this ); 1358 mSocket = new QSocket( this );
1347 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1359 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1348 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1360 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1361 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1349 } 1362 }
1350 mFileString = ""; 1363 mFileString = "";
1351 mFileName = fn; 1364 mFileName = fn;
1352 mFirst = true; 1365 mFirst = true;
1366 if ( tlw )
1367 tlw->setCaption( i18n("Trying to connect to remote...") );
1353 mSocket->connectToHost( mHost, mPort ); 1368 mSocket->connectToHost( mHost, mPort );
1354 QTextStream os( mSocket ); 1369 qDebug("KSS: Waiting for connection");
1355 os.setEncoding( QTextStream::Latin1 ); 1370 mTimerSocket->start( 20000 );
1356
1357 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1358 os << "GET " << mPassWord << curDt <<"\r\n";
1359 mTimerSocket->start( 300000 );
1360} 1371}
1361 1372
1362void KCommandSocket::writeFile( QString fileName ) 1373void KCommandSocket::writeFile( QString fileName )
1363{ 1374{
1364 if ( !mSocket ) { 1375 if ( !mSocket ) {
1365 mSocket = new QSocket( this ); 1376 mSocket = new QSocket( this );
1366 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1377 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1367 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1378 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1368 } 1379 }
1369 mFileName = fileName ; 1380 mFileName = fileName ;
1370 mSocket->connectToHost( mHost, mPort ); 1381 mSocket->connectToHost( mHost, mPort );
1371} 1382}
1372void KCommandSocket::writeFileToSocket() 1383void KCommandSocket::writeFileToSocket()
1373{ 1384{
1374 QFile file2( mFileName ); 1385 QFile file2( mFileName );
1375 if (!file2.open( IO_ReadOnly ) ) { 1386 if (!file2.open( IO_ReadOnly ) ) {
1376 mRetVal= errorW; 1387 mRetVal= errorW;
1377 mSocket->close(); 1388 mSocket->close();
1378 if ( mSocket->state() == QSocket::Idle ) 1389 if ( mSocket->state() == QSocket::Idle )
1379 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1390 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1380 return ; 1391 return ;
1381 } 1392 }
1382 QTextStream ts2( &file2 ); 1393 QTextStream ts2( &file2 );
1383 ts2.setEncoding( QTextStream::Latin1 ); 1394 ts2.setEncoding( QTextStream::Latin1 );
1384 QTextStream os2( mSocket ); 1395 QTextStream os2( mSocket );
1385 os2.setEncoding( QTextStream::Latin1 ); 1396 os2.setEncoding( QTextStream::Latin1 );
1386 os2 << "PUT " << mPassWord << "\r\n";; 1397 os2 << "PUT " << mPassWord << "\r\n\r\n";;
1387 while ( ! ts2.atEnd() ) { 1398 while ( ! ts2.atEnd() ) {
1388 os2 << ts2.readLine() << "\r\n"; 1399 os2 << ts2.readLine() << "\r\n\r\n";
1389 } 1400 }
1390 mRetVal= successW; 1401 mRetVal= successW;
1391 file2.close(); 1402 file2.close();
1392 mSocket->close(); 1403 mSocket->close();
1393 if ( mSocket->state() == QSocket::Idle ) 1404 if ( mSocket->state() == QSocket::Idle )
1394 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1405 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1395} 1406}
1396void KCommandSocket::sendStop() 1407void KCommandSocket::sendStop()
1397{ 1408{
1398 if ( !mSocket ) { 1409 if ( !mSocket ) {
1399 mSocket = new QSocket( this ); 1410 mSocket = new QSocket( this );
1400 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1411 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1401 } 1412 }
1402 mSocket->connectToHost( mHost, mPort ); 1413 mSocket->connectToHost( mHost, mPort );
1403 QTextStream os2( mSocket ); 1414 QTextStream os2( mSocket );
1404 os2.setEncoding( QTextStream::Latin1 ); 1415 os2.setEncoding( QTextStream::Latin1 );
1405 os2 << "STOP\r\n"; 1416 os2 << "STOP\r\n\r\n";
1406 mSocket->close(); 1417 mSocket->close();
1407 if ( mSocket->state() == QSocket::Idle ) 1418 if ( mSocket->state() == QSocket::Idle )
1408 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1419 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1409} 1420}
1410 1421
1411void KCommandSocket::startReadFileFromSocket() 1422void KCommandSocket::startReadFileFromSocket()
1412{ 1423{
1413 if ( ! mFirst ) 1424 if ( ! mFirst )
1414 return; 1425 return;
1415 mFirst = false; 1426 mFirst = false;
1416 mTimerSocket->stop(); 1427 mTimerSocket->stop();
1417 mFileString = ""; 1428 mFileString = "";
1418 mTime.start(); 1429 mTime.start();
1419 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1430 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1420 1431
1421} 1432}
1422void KCommandSocket::readFileFromSocket() 1433void KCommandSocket::readFileFromSocket()
1423{ 1434{
1424 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1435 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1425 while ( mSocket->canReadLine () ) { 1436 while ( mSocket->canReadLine () ) {
1426 mTime.restart(); 1437 mTime.restart();
1427 QString line = mSocket->readLine (); 1438 QString line = mSocket->readLine ();
1428 mFileString += line; 1439 mFileString += line;
1429 //qDebug("readline: %s ", line.latin1()); 1440 //qDebug("readline: %s ", line.latin1());
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 6d89950..9a3066e 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -54,61 +54,65 @@ class KServerSocket : public QServerSocket
54 void saveFile(); 54 void saveFile();
55 void endConnect(); 55 void endConnect();
56 private slots: 56 private slots:
57 void discardClient(); 57 void discardClient();
58 void readClient(); 58 void readClient();
59 void readBackFileFromSocket(); 59 void readBackFileFromSocket();
60 private : 60 private :
61 bool blockRC; 61 bool blockRC;
62 void send_file(); 62 void send_file();
63 void get_file(); 63 void get_file();
64 void end_connect(); 64 void end_connect();
65 QDialog* mSyncActionDialog; 65 QDialog* mSyncActionDialog;
66 QSocket* mSocket; 66 QSocket* mSocket;
67 QString mPassWord; 67 QString mPassWord;
68 QString mFileName; 68 QString mFileName;
69 QTime piTime; 69 QTime piTime;
70 QString piFileString; 70 QString piFileString;
71}; 71};
72 72
73class KCommandSocket : public QObject 73class KCommandSocket : public QObject
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76 public: 76 public:
77 enum state { successR, errorR, successW, errorW, errorTO, quiet }; 77 enum state { successR, errorR, successW, errorW, errorTO, quiet };
78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
79 void readFile( QString ); 79 void readFile( QString );
80 void writeFile( QString ); 80 void writeFile( QString );
81 void sendStop(); 81 void sendStop();
82 82
83 private slots :
84 void sendFileRequest();
85
83 signals: 86 signals:
84 void commandFinished( KCommandSocket*, int ); 87 void commandFinished( KCommandSocket*, int );
85 private slots: 88 private slots:
86 void startReadFileFromSocket(); 89 void startReadFileFromSocket();
87 void readFileFromSocket(); 90 void readFileFromSocket();
88 void deleteSocket(); 91 void deleteSocket();
89 void writeFileToSocket(); 92 void writeFileToSocket();
90 private : 93 private :
94 QWidget* tlw;
91 QSocket* mSocket; 95 QSocket* mSocket;
92 QString mPassWord; 96 QString mPassWord;
93 Q_UINT16 mPort; 97 Q_UINT16 mPort;
94 QString mHost; 98 QString mHost;
95 QString mFileName; 99 QString mFileName;
96 QTimer* mTimerSocket; 100 QTimer* mTimerSocket;
97 int mRetVal; 101 int mRetVal;
98 QTime mTime; 102 QTime mTime;
99 QString mFileString; 103 QString mFileString;
100 bool mFirst; 104 bool mFirst;
101}; 105};
102 106
103 107
104class KSyncManager : public QObject 108class KSyncManager : public QObject
105{ 109{
106 Q_OBJECT 110 Q_OBJECT
107 111
108 public: 112 public:
109 enum TargetApp { 113 enum TargetApp {
110 KOPI = 0, 114 KOPI = 0,
111 KAPI = 1, 115 KAPI = 1,
112 PWMPI = 2 }; 116 PWMPI = 2 };
113 117
114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 118 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);