summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
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
@@ -330,48 +330,49 @@ void KSyncManager::enableQuick( bool ask )
330 bool changed = false; 330 bool changed = false;
331 if ( ask ) { 331 if ( ask ) {
332 QDialog dia ( 0, "input-dialog", true ); 332 QDialog dia ( 0, "input-dialog", true );
333 QLineEdit lab ( &dia ); 333 QLineEdit lab ( &dia );
334 QVBoxLayout lay( &dia ); 334 QVBoxLayout lay( &dia );
335 lab.setText( mPrefs->mPassiveSyncPort ); 335 lab.setText( mPrefs->mPassiveSyncPort );
336 lay.setMargin(7); 336 lay.setMargin(7);
337 lay.setSpacing(7); 337 lay.setSpacing(7);
338 int po = 9197+mTargetApp; 338 int po = 9197+mTargetApp;
339 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 339 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
340 lay.addWidget( &label); 340 lay.addWidget( &label);
341 lay.addWidget( &lab); 341 lay.addWidget( &lab);
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 );
366 dia.setCaption( i18n("Enter port for Pi-Sync") ); 367 dia.setCaption( i18n("Enter port for Pi-Sync") );
367 QPushButton pb ( "OK", &dia); 368 QPushButton pb ( "OK", &dia);
368 lay.addWidget( &pb ); 369 lay.addWidget( &pb );
369 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 370 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
370 dia.show(); 371 dia.show();
371 if ( ! dia.exec() ) 372 if ( ! dia.exec() )
372 return; 373 return;
373 dia.hide(); 374 dia.hide();
374 qApp->processEvents(); 375 qApp->processEvents();
375 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 376 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
376 changed = true; 377 changed = true;
377 mPrefs->mPassiveSyncPw = lepw.text(); 378 mPrefs->mPassiveSyncPw = lepw.text();
@@ -552,55 +553,57 @@ int KSyncManager::ringSync()
552 switch(mTargetApp) 553 switch(mTargetApp)
553 { 554 {
554 case (KAPI): 555 case (KAPI):
555 includeInRingSync = temp->getIncludeInRingSyncAB(); 556 includeInRingSync = temp->getIncludeInRingSyncAB();
556 break; 557 break;
557 case (KOPI): 558 case (KOPI):
558 includeInRingSync = temp->getIncludeInRingSync(); 559 includeInRingSync = temp->getIncludeInRingSync();
559 break; 560 break;
560 case (PWMPI): 561 case (PWMPI):
561 includeInRingSync = temp->getIncludeInRingSyncPWM(); 562 includeInRingSync = temp->getIncludeInRingSyncPWM();
562 break; 563 break;
563 default: 564 default:
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();
595 break; 598 break;
596 case (KOPI): 599 case (KOPI):
597 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 600 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
598 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 601 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
599 break; 602 break;
600 case (PWMPI): 603 case (PWMPI):
601 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 604 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
602 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 605 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
603 break; 606 break;
604 default: 607 default:
605 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 608 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
606 break; 609 break;
@@ -1000,48 +1003,49 @@ QString KSyncManager::syncFileName()
1000 QString fn = "tempfile"; 1003 QString fn = "tempfile";
1001 switch(mTargetApp) 1004 switch(mTargetApp)
1002 { 1005 {
1003 case (KAPI): 1006 case (KAPI):
1004 fn = "tempsyncab.vcf"; 1007 fn = "tempsyncab.vcf";
1005 break; 1008 break;
1006 case (KOPI): 1009 case (KOPI):
1007 fn = "tempsynccal.ics"; 1010 fn = "tempsynccal.ics";
1008 break; 1011 break;
1009 case (PWMPI): 1012 case (PWMPI):
1010 fn = "tempsyncpw.pwm"; 1013 fn = "tempsyncpw.pwm";
1011 break; 1014 break;
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;
1036 } 1040 }
1037 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 1041 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
1038 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1042 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1039 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 1043 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
1040 commandSocket->readFile( syncFileName() ); 1044 commandSocket->readFile( syncFileName() );
1041} 1045}
1042 1046
1043void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1047void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1044{ 1048{
1045 //enum { success, errorW, errorR, quiet }; 1049 //enum { success, errorW, errorR, quiet };
1046 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 1050 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
1047 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1051 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
@@ -1117,94 +1121,115 @@ void KServerSocket::discardClient()
1117 if ( mSocket ) { 1121 if ( mSocket ) {
1118 delete mSocket; 1122 delete mSocket;
1119 mSocket = 0; 1123 mSocket = 0;
1120 } 1124 }
1121 //emit endConnect(); 1125 //emit endConnect();
1122} 1126}
1123void KServerSocket::readClient() 1127void KServerSocket::readClient()
1124{ 1128{
1125 if ( blockRC ) 1129 if ( blockRC )
1126 return; 1130 return;
1127 if ( mSocket == 0 ) { 1131 if ( mSocket == 0 ) {
1128 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 1132 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
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 );
1155 blockRC = true; 1160 blockRC = true;
1156 get_file(); 1161 get_file();
1157 } 1162 }
1158 else { 1163 else {
1159 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 1164 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
1160 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1165 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1161 } 1166 }
1162 } 1167 }
1163 if ( tokens[0] == "STOP" ) { 1168 if ( tokens[0] == "STOP" ) {
1164 //emit endConnect(); 1169 //emit endConnect();
1165 end_connect(); 1170 end_connect();
1166 } 1171 }
1167 } 1172 }
1168} 1173}
1169void KServerSocket::end_connect() 1174void KServerSocket::end_connect()
1170{ 1175{
1171 delete mSyncActionDialog; 1176 delete mSyncActionDialog;
1172 mSyncActionDialog = 0; 1177 mSyncActionDialog = 0;
1173} 1178}
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 )
1199 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1224 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1200 return ; 1225 return ;
1201 1226
1202 } 1227 }
1203 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1228 mSyncActionDialog->setCaption( i18n("Sending file...") );
1204 QTextStream ts( &file ); 1229 QTextStream ts( &file );
1205 ts.setEncoding( QTextStream::Latin1 ); 1230 ts.setEncoding( QTextStream::Latin1 );
1206 1231
1207 QTextStream os( mSocket ); 1232 QTextStream os( mSocket );
1208 os.setEncoding( QTextStream::Latin1 ); 1233 os.setEncoding( QTextStream::Latin1 );
1209 while ( ! ts.atEnd() ) { 1234 while ( ! ts.atEnd() ) {
1210 os << ts.readLine() << "\r\n"; 1235 os << ts.readLine() << "\r\n";
@@ -1277,49 +1302,49 @@ KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host,
1277{ 1302{
1278 mPassWord = password; 1303 mPassWord = password;
1279 mSocket = 0; 1304 mSocket = 0;
1280 mPort = port; 1305 mPort = port;
1281 mHost = host; 1306 mHost = host;
1282 1307
1283 mRetVal = quiet; 1308 mRetVal = quiet;
1284 mTimerSocket = new QTimer ( this ); 1309 mTimerSocket = new QTimer ( this );
1285 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1310 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1286} 1311}
1287void KCommandSocket::readFile( QString fn ) 1312void KCommandSocket::readFile( QString fn )
1288{ 1313{
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 ;
1314 mSocket->connectToHost( mHost, mPort ); 1339 mSocket->connectToHost( mHost, mPort );
1315} 1340}
1316void KCommandSocket::writeFileToSocket() 1341void KCommandSocket::writeFileToSocket()
1317{ 1342{
1318 QFile file2( mFileName ); 1343 QFile file2( mFileName );
1319 if (!file2.open( IO_ReadOnly ) ) { 1344 if (!file2.open( IO_ReadOnly ) ) {
1320 mRetVal= errorW; 1345 mRetVal= errorW;
1321 mSocket->close(); 1346 mSocket->close();
1322 if ( mSocket->state() == QSocket::Idle ) 1347 if ( mSocket->state() == QSocket::Idle )
1323 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1348 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1324 return ; 1349 return ;
1325 } 1350 }