summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index f488a07..3adbf61 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -139,97 +139,97 @@ void KSyncManager::fillSyncMenu()
139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
140 mSyncProfileNames = prof; 140 mSyncProfileNames = prof;
141 unsigned int i; 141 unsigned int i;
142 for ( i = 0; i < prof.count(); ++i ) { 142 for ( i = 0; i < prof.count(); ++i ) {
143 mSyncMenu->insertItem( prof[i], 1000+i ); 143 mSyncMenu->insertItem( prof[i], 1000+i );
144 clearMenu->insertItem( prof[i], 1000+i ); 144 clearMenu->insertItem( prof[i], 1000+i );
145 if ( i == 2 ) 145 if ( i == 2 )
146 mSyncMenu->insertSeparator(); 146 mSyncMenu->insertSeparator();
147 } 147 }
148 QDir app_dir; 148 QDir app_dir;
149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
150 if ( mTargetApp == PWMPI) { 150 if ( mTargetApp == PWMPI) {
151 mSyncMenu->removeItem( 1000 ); 151 mSyncMenu->removeItem( 1000 );
152 clearMenu->removeItem( 1000 ); 152 clearMenu->removeItem( 1000 );
153 } 153 }
154#ifndef DESKTOP_VERSION 154#ifndef DESKTOP_VERSION
155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
156 mSyncMenu->removeItem( 1000 ); 156 mSyncMenu->removeItem( 1000 );
157 clearMenu->removeItem( 1000 ); 157 clearMenu->removeItem( 1000 );
158 } 158 }
159#endif 159#endif
160 mSyncMenu->removeItem( 1002 ); 160 mSyncMenu->removeItem( 1002 );
161 clearMenu->removeItem( 1002 ); 161 clearMenu->removeItem( 1002 );
162} 162}
163void KSyncManager::slotClearMenu( int action ) 163void KSyncManager::slotClearMenu( int action )
164{ 164{
165 QString syncDevice; 165 QString syncDevice;
166 if ( action > 999 ) { 166 if ( action > 999 ) {
167 syncDevice = mSyncProfileNames[action - 1000] ; 167 syncDevice = mSyncProfileNames[action - 1000] ;
168 } 168 }
169 169
170 170
171 171
172 int result = 0; 172 int result = 0;
173 QString sd; 173 QString sd;
174 if ( syncDevice.isEmpty() ) 174 if ( syncDevice.isEmpty() )
175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
176 else 176 else
177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
178 178
179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
180 0, 1 ); 180 0, 1 );
181 if ( result ) 181 if ( result )
182 return; 182 return;
183 mImplementation->removeSyncInfo( syncDevice ); 183 mImplementation->removeSyncInfo( syncDevice );
184} 184}
185void KSyncManager::slotSyncMenu( int action ) 185void KSyncManager::slotSyncMenu( int action )
186{ 186{
187 qDebug("syncaction %d ", action); 187 qDebug("KSM::syncaction %d ", action);
188 if ( action == 5000 ) 188 if ( action == 5000 )
189 return; 189 return;
190 mSyncWithDesktop = false; 190 mSyncWithDesktop = false;
191 if ( action == 0 ) { 191 if ( action == 0 ) {
192 192
193 // seems to be a Qt2 event handling bug 193 // seems to be a Qt2 event handling bug
194 // syncmenu.clear causes a segfault at first time 194 // syncmenu.clear causes a segfault at first time
195 // when we call it after the main event loop, it is ok 195 // when we call it after the main event loop, it is ok
196 // same behaviour when calling OM/Pi via QCOP for the first time 196 // same behaviour when calling OM/Pi via QCOP for the first time
197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
198 //confSync(); 198 //confSync();
199 199
200 return; 200 return;
201 } 201 }
202 if ( action == 1 ) { 202 if ( action == 1 ) {
203 multiSync( true ); 203 multiSync( true );
204 return; 204 return;
205 } 205 }
206 if ( action == 2 ) { 206 if ( action == 2 ) {
207 enableQuick(); 207 enableQuick();
208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
209 return; 209 return;
210 } 210 }
211 if ( action == 3 ) { 211 if ( action == 3 ) {
212 delete mServerSocket; 212 delete mServerSocket;
213 mServerSocket = 0; 213 mServerSocket = 0;
214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
215 return; 215 return;
216 } 216 }
217 217
218 if (blockSave()) 218 if (blockSave())
219 return; 219 return;
220 220
221 setBlockSave(true); 221 setBlockSave(true);
222 bool silent = false; 222 bool silent = false;
223 if ( action == 999 ) { 223 if ( action == 999 ) {
224 //special mode for silent syncing 224 //special mode for silent syncing
225 action = 1000; 225 action = 1000;
226 silent = true; 226 silent = true;
227 } 227 }
228 228
229 mCurrentSyncProfile = action - 1000 ; 229 mCurrentSyncProfile = action - 1000 ;
230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
231 mCurrentSyncName = mLocalMachineName ; 231 mCurrentSyncName = mLocalMachineName ;
232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
233 KSyncProfile* temp = new KSyncProfile (); 233 KSyncProfile* temp = new KSyncProfile ();
234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
235 temp->readConfig(&config); 235 temp->readConfig(&config);
@@ -247,97 +247,97 @@ void KSyncManager::slotSyncMenu( int action )
247 } 247 }
248 mWriteBackExistingOnly = temp->getWriteBackExisting(); 248 mWriteBackExistingOnly = temp->getWriteBackExisting();
249 mIsKapiFile = temp->getIsKapiFile(); 249 mIsKapiFile = temp->getIsKapiFile();
250 mWriteBackInFuture = 0; 250 mWriteBackInFuture = 0;
251 if ( temp->getWriteBackFuture() ) { 251 if ( temp->getWriteBackFuture() ) {
252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
253 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 253 mWriteBackInPast = temp->getWriteBackPastWeeks( );
254 } 254 }
255 mFilterInCal = temp->getFilterInCal(); 255 mFilterInCal = temp->getFilterInCal();
256 mFilterOutCal = temp->getFilterOutCal(); 256 mFilterOutCal = temp->getFilterOutCal();
257 mFilterInAB = temp->getFilterInAB(); 257 mFilterInAB = temp->getFilterInAB();
258 mFilterOutAB = temp->getFilterOutAB(); 258 mFilterOutAB = temp->getFilterOutAB();
259 259
260 if ( action == 1000 ) { 260 if ( action == 1000 ) {
261 mIsKapiFile = false; 261 mIsKapiFile = false;
262#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
263 syncKDE(); 263 syncKDE();
264#else 264#else
265 syncSharp(); 265 syncSharp();
266#endif 266#endif
267 267
268 } else if ( action == 1001 ) { 268 } else if ( action == 1001 ) {
269 syncLocalFile(); 269 syncLocalFile();
270 270
271 } else if ( action == 1002 ) { 271 } else if ( action == 1002 ) {
272 mWriteBackFile = false; 272 mWriteBackFile = false;
273 mAskForPreferences = false; 273 mAskForPreferences = false;
274 mShowSyncSummary = false; 274 mShowSyncSummary = false;
275 mSyncAlgoPrefs = 3; 275 mSyncAlgoPrefs = 3;
276 quickSyncLocalFile(); 276 quickSyncLocalFile();
277 277
278 } else if ( action >= 1003 ) { 278 } else if ( action >= 1003 ) {
279 if ( temp->getIsLocalFileSync() ) { 279 if ( temp->getIsLocalFileSync() ) {
280 switch(mTargetApp) 280 switch(mTargetApp)
281 { 281 {
282 case (KAPI): 282 case (KAPI):
283 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 283 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
284 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 284 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
285 break; 285 break;
286 case (KOPI): 286 case (KOPI):
287 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 287 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
288 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 288 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
289 break; 289 break;
290 case (PWMPI): 290 case (PWMPI):
291 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 291 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
292 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 292 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
293 break; 293 break;
294 default: 294 default:
295 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 295 qDebug("KSM::slotSyncMenu: invalid apptype selected");
296 break; 296 break;
297 297
298 } 298 }
299 } else { 299 } else {
300 if ( temp->getIsPhoneSync() ) { 300 if ( temp->getIsPhoneSync() ) {
301 mPhoneDevice = temp->getPhoneDevice( ) ; 301 mPhoneDevice = temp->getPhoneDevice( ) ;
302 mPhoneConnection = temp->getPhoneConnection( ); 302 mPhoneConnection = temp->getPhoneConnection( );
303 mPhoneModel = temp->getPhoneModel( ); 303 mPhoneModel = temp->getPhoneModel( );
304 syncPhone(); 304 syncPhone();
305 } else if ( temp->getIsPiSync() ) { 305 } else if ( temp->getIsPiSync() ) {
306 if ( mTargetApp == KAPI ) { 306 if ( mTargetApp == KAPI ) {
307 mPassWordPiSync = temp->getRemotePwAB(); 307 mPassWordPiSync = temp->getRemotePwAB();
308 mActiveSyncPort = temp->getRemotePortAB(); 308 mActiveSyncPort = temp->getRemotePortAB();
309 mActiveSyncIP = temp->getRemoteIPAB(); 309 mActiveSyncIP = temp->getRemoteIPAB();
310 } else if ( mTargetApp == KOPI ) { 310 } else if ( mTargetApp == KOPI ) {
311 mPassWordPiSync = temp->getRemotePw(); 311 mPassWordPiSync = temp->getRemotePw();
312 mActiveSyncPort = temp->getRemotePort(); 312 mActiveSyncPort = temp->getRemotePort();
313 mActiveSyncIP = temp->getRemoteIP(); 313 mActiveSyncIP = temp->getRemoteIP();
314 } else { 314 } else {
315 mPassWordPiSync = temp->getRemotePwPWM(); 315 mPassWordPiSync = temp->getRemotePwPWM();
316 mActiveSyncPort = temp->getRemotePortPWM(); 316 mActiveSyncPort = temp->getRemotePortPWM();
317 mActiveSyncIP = temp->getRemoteIPPWM(); 317 mActiveSyncIP = temp->getRemoteIPPWM();
318 } 318 }
319 syncPi(); 319 syncPi();
320 while ( !mPisyncFinished ) { 320 while ( !mPisyncFinished ) {
321 //qDebug("waiting "); 321 //qDebug("waiting ");
322 qApp->processEvents(); 322 qApp->processEvents();
323 } 323 }
324 } else 324 } else
325 syncRemote( temp ); 325 syncRemote( temp );
326 326
327 } 327 }
328 } 328 }
329 delete temp; 329 delete temp;
330 setBlockSave(false); 330 setBlockSave(false);
331} 331}
332 332
333void KSyncManager::enableQuick( bool ask ) 333void KSyncManager::enableQuick( bool ask )
334{ 334{
335 bool autoStart; 335 bool autoStart;
336 bool changed = false; 336 bool changed = false;
337 if ( ask ) { 337 if ( ask ) {
338 QDialog dia ( 0, "input-dialog", true ); 338 QDialog dia ( 0, "input-dialog", true );
339 QLineEdit lab ( &dia ); 339 QLineEdit lab ( &dia );
340 QVBoxLayout lay( &dia ); 340 QVBoxLayout lay( &dia );
341 lab.setText( mPrefs->mPassiveSyncPort ); 341 lab.setText( mPrefs->mPassiveSyncPort );
342 lay.setMargin(7); 342 lay.setMargin(7);
343 lay.setSpacing(7); 343 lay.setSpacing(7);
@@ -395,411 +395,411 @@ void KSyncManager::enableQuick( bool ask )
395 } 395 }
396 else 396 else
397 autoStart = mPrefs->mPassiveSyncAutoStart; 397 autoStart = mPrefs->mPassiveSyncAutoStart;
398 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 398 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
399 changed = true; 399 changed = true;
400 bool ok; 400 bool ok;
401 mPrefs->mPassiveSyncAutoStart = false; 401 mPrefs->mPassiveSyncAutoStart = false;
402 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 402 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
403 if ( ! ok ) { 403 if ( ! ok ) {
404 KMessageBox::information( 0, i18n("No valid port")); 404 KMessageBox::information( 0, i18n("No valid port"));
405 return; 405 return;
406 } 406 }
407 //qDebug("port %d ", port); 407 //qDebug("port %d ", port);
408 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 408 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
409 mServerSocket->setFileName( defaultFileName() );//bbb 409 mServerSocket->setFileName( defaultFileName() );//bbb
410 //qDebug("connected "); 410 //qDebug("connected ");
411 if ( !mServerSocket->ok() ) { 411 if ( !mServerSocket->ok() ) {
412 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 412 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
413 delete mServerSocket; 413 delete mServerSocket;
414 mServerSocket = 0; 414 mServerSocket = 0;
415 return; 415 return;
416 } 416 }
417 mPrefs->mPassiveSyncAutoStart = autoStart; 417 mPrefs->mPassiveSyncAutoStart = autoStart;
418 if ( changed ) { 418 if ( changed ) {
419 mPrefs->writeConfig(); 419 mPrefs->writeConfig();
420 } 420 }
421 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 421 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
422 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 422 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
423} 423}
424 424
425void KSyncManager::syncLocalFile() 425void KSyncManager::syncLocalFile()
426{ 426{
427 427
428 QString fn =mPrefs->mLastSyncedLocalFile; 428 QString fn =mPrefs->mLastSyncedLocalFile;
429 QString ext; 429 QString ext;
430 430
431 switch(mTargetApp) 431 switch(mTargetApp)
432 { 432 {
433 case (KAPI): 433 case (KAPI):
434 ext = "(*.vcf)"; 434 ext = "(*.vcf)";
435 break; 435 break;
436 case (KOPI): 436 case (KOPI):
437 ext = "(*.ics/*.vcs)"; 437 ext = "(*.ics/*.vcs)";
438 break; 438 break;
439 case (PWMPI): 439 case (PWMPI):
440 ext = "(*.pwm)"; 440 ext = "(*.pwm)";
441 break; 441 break;
442 default: 442 default:
443 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 443 qDebug("KSM::syncLocalFile: invalid apptype selected");
444 break; 444 break;
445 445
446 } 446 }
447 447
448 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 448 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
449 if ( fn == "" ) 449 if ( fn == "" )
450 return; 450 return;
451 if ( syncWithFile( fn, false ) ) { 451 if ( syncWithFile( fn, false ) ) {
452 qDebug("syncLocalFile() successful "); 452 qDebug("KSM::syncLocalFile() successful ");
453 } 453 }
454 454
455} 455}
456 456
457bool KSyncManager::syncWithFile( QString fn , bool quick ) 457bool KSyncManager::syncWithFile( QString fn , bool quick )
458{ 458{
459 bool ret = false; 459 bool ret = false;
460 QFileInfo info; 460 QFileInfo info;
461 info.setFile( fn ); 461 info.setFile( fn );
462 QString mess; 462 QString mess;
463 bool loadbup = true; 463 bool loadbup = true;
464 if ( !info. exists() ) { 464 if ( !info. exists() ) {
465 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 465 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
466 int result = QMessageBox::warning( mParent, i18n("Warning!"), 466 int result = QMessageBox::warning( mParent, i18n("Warning!"),
467 mess ); 467 mess );
468 return ret; 468 return ret;
469 } 469 }
470 int result = 0; 470 int result = 0;
471 if ( !quick ) { 471 if ( !quick ) {
472 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 472 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
473 result = QMessageBox::warning( mParent, i18n("Warning!"), 473 result = QMessageBox::warning( mParent, i18n("Warning!"),
474 mess, 474 mess,
475 i18n("Sync"), i18n("Cancel"), 0, 475 i18n("Sync"), i18n("Cancel"), 0,
476 0, 1 ); 476 0, 1 );
477 if ( result ) 477 if ( result )
478 return false; 478 return false;
479 } 479 }
480 if ( mAskForPreferences ) 480 if ( mAskForPreferences )
481 if ( !edit_sync_options()) { 481 if ( !edit_sync_options()) {
482 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 482 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
483 return false; 483 return false;
484 } 484 }
485 if ( result == 0 ) { 485 if ( result == 0 ) {
486 //qDebug("Now sycing ... "); 486 //qDebug("Now sycing ... ");
487 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 487 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
488 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 488 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
489 else 489 else
490 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 490 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
491 if ( ! quick ) 491 if ( ! quick )
492 mPrefs->mLastSyncedLocalFile = fn; 492 mPrefs->mLastSyncedLocalFile = fn;
493 } 493 }
494 return ret; 494 return ret;
495} 495}
496 496
497void KSyncManager::quickSyncLocalFile() 497void KSyncManager::quickSyncLocalFile()
498{ 498{
499 499
500 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 500 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
501 qDebug("quick syncLocalFile() successful "); 501 qDebug("KSM::quick syncLocalFile() successful ");
502 502
503 } 503 }
504} 504}
505 505
506void KSyncManager::multiSync( bool askforPrefs ) 506void KSyncManager::multiSync( bool askforPrefs )
507{ 507{
508 if (blockSave()) 508 if (blockSave())
509 return; 509 return;
510 setBlockSave(true); 510 setBlockSave(true);
511 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 511 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
512 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 512 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
513 question, 513 question,
514 i18n("Yes"), i18n("No"), 514 i18n("Yes"), i18n("No"),
515 0, 0 ) != 0 ) { 515 0, 0 ) != 0 ) {
516 setBlockSave(false); 516 setBlockSave(false);
517 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 517 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
518 return; 518 return;
519 } 519 }
520 mCurrentSyncDevice = i18n("Multiple profiles") ; 520 mCurrentSyncDevice = i18n("Multiple profiles") ;
521 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 521 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
522 if ( askforPrefs ) { 522 if ( askforPrefs ) {
523 if ( !edit_sync_options()) { 523 if ( !edit_sync_options()) {
524 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 524 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
525 return; 525 return;
526 } 526 }
527 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 527 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
528 } 528 }
529 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 529 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
530 qApp->processEvents(); 530 qApp->processEvents();
531 int num = ringSync() ; 531 int num = ringSync() ;
532 if ( num > 1 ) 532 if ( num > 1 )
533 ringSync(); 533 ringSync();
534 setBlockSave(false); 534 setBlockSave(false);
535 if ( num ) 535 if ( num )
536 emit save(); 536 emit save();
537 if ( num ) 537 if ( num )
538 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 538 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
539 else 539 else
540 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 540 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
541 return; 541 return;
542} 542}
543 543
544int KSyncManager::ringSync() 544int KSyncManager::ringSync()
545{ 545{
546 546
547 int syncedProfiles = 0; 547 int syncedProfiles = 0;
548 unsigned int i; 548 unsigned int i;
549 QTime timer; 549 QTime timer;
550 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 550 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
551 QStringList syncProfileNames = mSyncProfileNames; 551 QStringList syncProfileNames = mSyncProfileNames;
552 KSyncProfile* temp = new KSyncProfile (); 552 KSyncProfile* temp = new KSyncProfile ();
553 mAskForPreferences = false; 553 mAskForPreferences = false;
554 for ( i = 0; i < syncProfileNames.count(); ++i ) { 554 for ( i = 0; i < syncProfileNames.count(); ++i ) {
555 mCurrentSyncProfile = i; 555 mCurrentSyncProfile = i;
556 temp->setName(syncProfileNames[mCurrentSyncProfile]); 556 temp->setName(syncProfileNames[mCurrentSyncProfile]);
557 temp->readConfig(&config); 557 temp->readConfig(&config);
558 558
559 bool includeInRingSync; 559 bool includeInRingSync;
560 switch(mTargetApp) 560 switch(mTargetApp)
561 { 561 {
562 case (KAPI): 562 case (KAPI):
563 includeInRingSync = temp->getIncludeInRingSyncAB(); 563 includeInRingSync = temp->getIncludeInRingSyncAB();
564 break; 564 break;
565 case (KOPI): 565 case (KOPI):
566 includeInRingSync = temp->getIncludeInRingSync(); 566 includeInRingSync = temp->getIncludeInRingSync();
567 break; 567 break;
568 case (PWMPI): 568 case (PWMPI):
569 includeInRingSync = temp->getIncludeInRingSyncPWM(); 569 includeInRingSync = temp->getIncludeInRingSyncPWM();
570 break; 570 break;
571 default: 571 default:
572 qDebug("KSyncManager::ringSync: invalid apptype selected"); 572 qDebug("KSM::ringSync: invalid apptype selected");
573 break; 573 break;
574 574
575 } 575 }
576 576
577 577
578 if ( includeInRingSync && ( i < 1 || i > 2 )) { 578 if ( includeInRingSync && ( i < 1 || i > 2 )) {
579 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 579 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
580 ++syncedProfiles; 580 ++syncedProfiles;
581 mSyncWithDesktop = false; 581 mSyncWithDesktop = false;
582 // mAskForPreferences = temp->getAskForPreferences(); 582 // mAskForPreferences = temp->getAskForPreferences();
583 mWriteBackFile = temp->getWriteBackFile(); 583 mWriteBackFile = temp->getWriteBackFile();
584 mWriteBackExistingOnly = temp->getWriteBackExisting(); 584 mWriteBackExistingOnly = temp->getWriteBackExisting();
585 mIsKapiFile = temp->getIsKapiFile(); 585 mIsKapiFile = temp->getIsKapiFile();
586 mWriteBackInFuture = 0; 586 mWriteBackInFuture = 0;
587 if ( temp->getWriteBackFuture() ) { 587 if ( temp->getWriteBackFuture() ) {
588 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 588 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
589 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 589 mWriteBackInPast = temp->getWriteBackPastWeeks( );
590 } 590 }
591 mFilterInCal = temp->getFilterInCal(); 591 mFilterInCal = temp->getFilterInCal();
592 mFilterOutCal = temp->getFilterOutCal(); 592 mFilterOutCal = temp->getFilterOutCal();
593 mFilterInAB = temp->getFilterInAB(); 593 mFilterInAB = temp->getFilterInAB();
594 mFilterOutAB = temp->getFilterOutAB(); 594 mFilterOutAB = temp->getFilterOutAB();
595 mShowSyncSummary = false; 595 mShowSyncSummary = false;
596 mCurrentSyncDevice = syncProfileNames[i] ; 596 mCurrentSyncDevice = syncProfileNames[i] ;
597 mCurrentSyncName = mLocalMachineName; 597 mCurrentSyncName = mLocalMachineName;
598 if ( i == 0 ) { 598 if ( i == 0 ) {
599 mIsKapiFile = false; 599 mIsKapiFile = false;
600#ifdef DESKTOP_VERSION 600#ifdef DESKTOP_VERSION
601 syncKDE(); 601 syncKDE();
602#else 602#else
603 syncSharp(); 603 syncSharp();
604#endif 604#endif
605 } else { 605 } else {
606 if ( temp->getIsLocalFileSync() ) { 606 if ( temp->getIsLocalFileSync() ) {
607 switch(mTargetApp) 607 switch(mTargetApp)
608 { 608 {
609 case (KAPI): 609 case (KAPI):
610 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 610 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
611 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 611 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
612 break; 612 break;
613 case (KOPI): 613 case (KOPI):
614 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 614 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
615 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 615 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
616 break; 616 break;
617 case (PWMPI): 617 case (PWMPI):
618 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 618 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
619 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 619 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
620 break; 620 break;
621 default: 621 default:
622 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 622 qDebug("KSM: invalid apptype selected");
623 break; 623 break;
624 } 624 }
625 } else { 625 } else {
626 if ( temp->getIsPhoneSync() ) { 626 if ( temp->getIsPhoneSync() ) {
627 mPhoneDevice = temp->getPhoneDevice( ) ; 627 mPhoneDevice = temp->getPhoneDevice( ) ;
628 mPhoneConnection = temp->getPhoneConnection( ); 628 mPhoneConnection = temp->getPhoneConnection( );
629 mPhoneModel = temp->getPhoneModel( ); 629 mPhoneModel = temp->getPhoneModel( );
630 syncPhone(); 630 syncPhone();
631 } else if ( temp->getIsPiSync() ) { 631 } else if ( temp->getIsPiSync() ) {
632 if ( mTargetApp == KAPI ) { 632 if ( mTargetApp == KAPI ) {
633 mPassWordPiSync = temp->getRemotePwAB(); 633 mPassWordPiSync = temp->getRemotePwAB();
634 mActiveSyncPort = temp->getRemotePortAB(); 634 mActiveSyncPort = temp->getRemotePortAB();
635 mActiveSyncIP = temp->getRemoteIPAB(); 635 mActiveSyncIP = temp->getRemoteIPAB();
636 } else if ( mTargetApp == KOPI ) { 636 } else if ( mTargetApp == KOPI ) {
637 mPassWordPiSync = temp->getRemotePw(); 637 mPassWordPiSync = temp->getRemotePw();
638 mActiveSyncPort = temp->getRemotePort(); 638 mActiveSyncPort = temp->getRemotePort();
639 mActiveSyncIP = temp->getRemoteIP(); 639 mActiveSyncIP = temp->getRemoteIP();
640 } else { 640 } else {
641 mPassWordPiSync = temp->getRemotePwPWM(); 641 mPassWordPiSync = temp->getRemotePwPWM();
642 mActiveSyncPort = temp->getRemotePortPWM(); 642 mActiveSyncPort = temp->getRemotePortPWM();
643 mActiveSyncIP = temp->getRemoteIPPWM(); 643 mActiveSyncIP = temp->getRemoteIPPWM();
644 } 644 }
645 syncPi(); 645 syncPi();
646 while ( !mPisyncFinished ) { 646 while ( !mPisyncFinished ) {
647 //qDebug("waiting "); 647 //qDebug("waiting ");
648 qApp->processEvents(); 648 qApp->processEvents();
649 } 649 }
650 timer.start(); 650 timer.start();
651 while ( timer.elapsed () < 2000 ) { 651 while ( timer.elapsed () < 2000 ) {
652 qApp->processEvents(); 652 qApp->processEvents();
653 } 653 }
654 } else 654 } else
655 syncRemote( temp, false ); 655 syncRemote( temp, false );
656 656
657 } 657 }
658 } 658 }
659 timer.start(); 659 timer.start();
660 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 660 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
661 while ( timer.elapsed () < 2000 ) { 661 while ( timer.elapsed () < 2000 ) {
662 qApp->processEvents(); 662 qApp->processEvents();
663#ifndef _WIN32_ 663#ifndef _WIN32_
664 sleep (1); 664 sleep (1);
665#endif 665#endif
666 } 666 }
667 667
668 } 668 }
669 669
670 } 670 }
671 delete temp; 671 delete temp;
672 return syncedProfiles; 672 return syncedProfiles;
673} 673}
674 674
675void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 675void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
676{ 676{
677 QString question; 677 QString question;
678 if ( ask ) { 678 if ( ask ) {
679 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 679 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
680 if ( QMessageBox::information( mParent, i18n("Sync"), 680 if ( QMessageBox::information( mParent, i18n("Sync"),
681 question, 681 question,
682 i18n("Yes"), i18n("No"), 682 i18n("Yes"), i18n("No"),
683 0, 0 ) != 0 ) 683 0, 0 ) != 0 )
684 return; 684 return;
685 } 685 }
686 686
687 QString preCommand; 687 QString preCommand;
688 QString localTempFile; 688 QString localTempFile;
689 QString postCommand; 689 QString postCommand;
690 690
691 switch(mTargetApp) 691 switch(mTargetApp)
692 { 692 {
693 case (KAPI): 693 case (KAPI):
694 preCommand = prof->getPreSyncCommandAB(); 694 preCommand = prof->getPreSyncCommandAB();
695 postCommand = prof->getPostSyncCommandAB(); 695 postCommand = prof->getPostSyncCommandAB();
696 localTempFile = prof->getLocalTempFileAB(); 696 localTempFile = prof->getLocalTempFileAB();
697 break; 697 break;
698 case (KOPI): 698 case (KOPI):
699 preCommand = prof->getPreSyncCommand(); 699 preCommand = prof->getPreSyncCommand();
700 postCommand = prof->getPostSyncCommand(); 700 postCommand = prof->getPostSyncCommand();
701 localTempFile = prof->getLocalTempFile(); 701 localTempFile = prof->getLocalTempFile();
702 break; 702 break;
703 case (PWMPI): 703 case (PWMPI):
704 preCommand = prof->getPreSyncCommandPWM(); 704 preCommand = prof->getPreSyncCommandPWM();
705 postCommand = prof->getPostSyncCommandPWM(); 705 postCommand = prof->getPostSyncCommandPWM();
706 localTempFile = prof->getLocalTempFilePWM(); 706 localTempFile = prof->getLocalTempFilePWM();
707 break; 707 break;
708 default: 708 default:
709 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 709 qDebug("KSM::syncRemote: invalid apptype selected");
710 break; 710 break;
711 } 711 }
712 712
713 713
714 int fi; 714 int fi;
715 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 715 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
716 QString pwd = getPassword(); 716 QString pwd = getPassword();
717 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 717 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
718 718
719 } 719 }
720 int maxlen = 30; 720 int maxlen = 30;
721 if ( QApplication::desktop()->width() > 320 ) 721 if ( QApplication::desktop()->width() > 320 )
722 maxlen += 25; 722 maxlen += 25;
723 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 723 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
724 int fileSize = 0; 724 int fileSize = 0;
725 int result = system ( preCommand ); 725 int result = system ( preCommand );
726 // 0 : okay 726 // 0 : okay
727 // 256: no such file or dir 727 // 256: no such file or dir
728 // 728 //
729 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 729 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
730 if ( result != 0 ) { 730 if ( result != 0 ) {
731 unsigned int len = maxlen; 731 unsigned int len = maxlen;
732 while ( len < preCommand.length() ) { 732 while ( len < preCommand.length() ) {
733 preCommand.insert( len , "\n" ); 733 preCommand.insert( len , "\n" );
734 len += maxlen +2; 734 len += maxlen +2;
735 } 735 }
736 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 736 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
737 QMessageBox::information( mParent, i18n("Sync - ERROR"), 737 QMessageBox::information( mParent, i18n("Sync - ERROR"),
738 question, 738 question,
739 i18n("Okay!")) ; 739 i18n("Okay!")) ;
740 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 740 mParent->topLevelWidget()->setCaption ("KDE-Pim");
741 return; 741 return;
742 } 742 }
743 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 743 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
744 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 744 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
745 745
746 if ( syncWithFile( localTempFile, true ) ) { 746 if ( syncWithFile( localTempFile, true ) ) {
747 747
748 if ( mWriteBackFile ) { 748 if ( mWriteBackFile ) {
749 int fi; 749 int fi;
750 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 750 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
751 QString pwd = getPassword(); 751 QString pwd = getPassword();
752 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 752 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
753 753
754 } 754 }
755 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 755 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
756 result = system ( postCommand ); 756 result = system ( postCommand );
757 qDebug("Sync:Writing back file result: %d ", result); 757 qDebug("KSM::Sync:Writing back file result: %d ", result);
758 if ( result != 0 ) { 758 if ( result != 0 ) {
759 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 759 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
760 return; 760 return;
761 } else { 761 } else {
762 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 762 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
763 } 763 }
764 } 764 }
765 } 765 }
766 return; 766 return;
767} 767}
768bool KSyncManager::edit_pisync_options() 768bool KSyncManager::edit_pisync_options()
769{ 769{
770 QDialog dia( mParent, "dia", true ); 770 QDialog dia( mParent, "dia", true );
771 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 771 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
772 QVBoxLayout lay ( &dia ); 772 QVBoxLayout lay ( &dia );
773 lay.setSpacing( 5 ); 773 lay.setSpacing( 5 );
774 lay.setMargin( 3 ); 774 lay.setMargin( 3 );
775 QLabel lab1 ( i18n("Password for remote access:"), &dia); 775 QLabel lab1 ( i18n("Password for remote access:"), &dia);
776 lay.addWidget( &lab1 ); 776 lay.addWidget( &lab1 );
777 QLineEdit le1 (&dia ); 777 QLineEdit le1 (&dia );
778 lay.addWidget( &le1 ); 778 lay.addWidget( &le1 );
779 QLabel lab2 ( i18n("Remote IP address:"), &dia); 779 QLabel lab2 ( i18n("Remote IP address:"), &dia);
780 lay.addWidget( &lab2 ); 780 lay.addWidget( &lab2 );
781 QLineEdit le2 (&dia ); 781 QLineEdit le2 (&dia );
782 lay.addWidget( &le2 ); 782 lay.addWidget( &le2 );
783 QLabel lab3 ( i18n("Remote port number:"), &dia); 783 QLabel lab3 ( i18n("Remote port number:"), &dia);
784 lay.addWidget( &lab3 ); 784 lay.addWidget( &lab3 );
785 QLineEdit le3 (&dia ); 785 QLineEdit le3 (&dia );
786 lay.addWidget( &le3 ); 786 lay.addWidget( &le3 );
787 QPushButton pb ( "OK", &dia); 787 QPushButton pb ( "OK", &dia);
788 lay.addWidget( &pb ); 788 lay.addWidget( &pb );
789 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 789 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
790 le1.setText( mPassWordPiSync ); 790 le1.setText( mPassWordPiSync );
791 le2.setText( mActiveSyncIP ); 791 le2.setText( mActiveSyncIP );
792 le3.setText( mActiveSyncPort ); 792 le3.setText( mActiveSyncPort );
793 if ( dia.exec() ) { 793 if ( dia.exec() ) {
794 mPassWordPiSync = le1.text(); 794 mPassWordPiSync = le1.text();
795 mActiveSyncPort = le3.text(); 795 mActiveSyncPort = le3.text();
796 mActiveSyncIP = le2.text(); 796 mActiveSyncIP = le2.text();
797 return true; 797 return true;
798 } 798 }
799 return false; 799 return false;
800} 800}
801bool KSyncManager::edit_sync_options() 801bool KSyncManager::edit_sync_options()
802{ 802{
803 803
804 QDialog dia( mParent, "dia", true ); 804 QDialog dia( mParent, "dia", true );
805 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 805 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
@@ -904,121 +904,121 @@ void KSyncManager::syncKDE()
904 mSyncWithDesktop = true; 904 mSyncWithDesktop = true;
905 emit save(); 905 emit save();
906 switch(mTargetApp) 906 switch(mTargetApp)
907 { 907 {
908 case (KAPI): 908 case (KAPI):
909 { 909 {
910#ifdef DESKTOP_VERSION 910#ifdef DESKTOP_VERSION
911 QString command = qApp->applicationDirPath () + "/kdeabdump"; 911 QString command = qApp->applicationDirPath () + "/kdeabdump";
912#else 912#else
913 QString command = "kdeabdump"; 913 QString command = "kdeabdump";
914#endif 914#endif
915 if ( ! QFile::exists ( command ) ) 915 if ( ! QFile::exists ( command ) )
916 command = "kdeabdump"; 916 command = "kdeabdump";
917 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 917 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
918 system ( command.latin1()); 918 system ( command.latin1());
919 if ( syncWithFile( fileName,true ) ) { 919 if ( syncWithFile( fileName,true ) ) {
920 if ( mWriteBackFile ) { 920 if ( mWriteBackFile ) {
921 command += " --read"; 921 command += " --read";
922 system ( command.latin1()); 922 system ( command.latin1());
923 } 923 }
924 } 924 }
925 925
926 } 926 }
927 break; 927 break;
928 case (KOPI): 928 case (KOPI):
929 { 929 {
930#ifdef DESKTOP_VERSION 930#ifdef DESKTOP_VERSION
931 QString command = qApp->applicationDirPath () + "/kdecaldump"; 931 QString command = qApp->applicationDirPath () + "/kdecaldump";
932#else 932#else
933 QString command = "kdecaldump"; 933 QString command = "kdecaldump";
934#endif 934#endif
935 if ( ! QFile::exists ( command ) ) 935 if ( ! QFile::exists ( command ) )
936 command = "kdecaldump"; 936 command = "kdecaldump";
937 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 937 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
938 system ( command.latin1()); 938 system ( command.latin1());
939 if ( syncWithFile( fileName,true ) ) { 939 if ( syncWithFile( fileName,true ) ) {
940 if ( mWriteBackFile ) { 940 if ( mWriteBackFile ) {
941 command += " --read"; 941 command += " --read";
942 system ( command.latin1()); 942 system ( command.latin1());
943 } 943 }
944 } 944 }
945 945
946 } 946 }
947 break; 947 break;
948 case (PWMPI): 948 case (PWMPI):
949 949
950 break; 950 break;
951 default: 951 default:
952 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 952 qDebug("KSM::slotSyncMenu: invalid apptype selected");
953 break; 953 break;
954 954
955 } 955 }
956} 956}
957 957
958void KSyncManager::syncSharp() 958void KSyncManager::syncSharp()
959{ 959{
960 960
961 if ( ! syncExternalApplication("sharp") ) 961 if ( ! syncExternalApplication("sharp") )
962 qDebug("ERROR sync sharp "); 962 qDebug("KSM::ERROR sync sharp ");
963} 963}
964 964
965bool KSyncManager::syncExternalApplication(QString resource) 965bool KSyncManager::syncExternalApplication(QString resource)
966{ 966{
967 967
968 emit save(); 968 emit save();
969 969
970 if ( mAskForPreferences ) 970 if ( mAskForPreferences )
971 if ( !edit_sync_options()) { 971 if ( !edit_sync_options()) {
972 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 972 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
973 return false; 973 return false;
974 } 974 }
975 975
976 qDebug("Sync extern %s", resource.latin1()); 976 qDebug("KSM::Sync extern %s", resource.latin1());
977 977
978 bool syncOK = mImplementation->syncExternal(this, resource); 978 bool syncOK = mImplementation->syncExternal(this, resource);
979 979
980 return syncOK; 980 return syncOK;
981 981
982} 982}
983 983
984void KSyncManager::syncPhone() 984void KSyncManager::syncPhone()
985{ 985{
986 986
987 syncExternalApplication("phone"); 987 syncExternalApplication("phone");
988 988
989} 989}
990 990
991void KSyncManager::showProgressBar(int percentage, QString caption, int total) 991void KSyncManager::showProgressBar(int percentage, QString caption, int total)
992{ 992{
993 if (!bar->isVisible()) 993 if (!bar->isVisible())
994 { 994 {
995 bar->setCaption (caption); 995 bar->setCaption (caption);
996 bar->setTotalSteps ( total ) ; 996 bar->setTotalSteps ( total ) ;
997 bar->show(); 997 bar->show();
998 } 998 }
999 bar->raise(); 999 bar->raise();
1000 bar->setProgress( percentage ); 1000 bar->setProgress( percentage );
1001 qApp->processEvents(); 1001 qApp->processEvents();
1002} 1002}
1003 1003
1004void KSyncManager::hideProgressBar() 1004void KSyncManager::hideProgressBar()
1005{ 1005{
1006 bar->hide(); 1006 bar->hide();
1007 qApp->processEvents(); 1007 qApp->processEvents();
1008} 1008}
1009 1009
1010bool KSyncManager::isProgressBarCanceled() 1010bool KSyncManager::isProgressBarCanceled()
1011{ 1011{
1012 return !bar->isVisible(); 1012 return !bar->isVisible();
1013} 1013}
1014 1014
1015QString KSyncManager::syncFileName() 1015QString KSyncManager::syncFileName()
1016{ 1016{
1017 1017
1018 QString fn = "tempfile"; 1018 QString fn = "tempfile";
1019 switch(mTargetApp) 1019 switch(mTargetApp)
1020 { 1020 {
1021 case (KAPI): 1021 case (KAPI):
1022 fn = "tempsyncab.vcf"; 1022 fn = "tempsyncab.vcf";
1023 break; 1023 break;
1024 case (KOPI): 1024 case (KOPI):
@@ -1075,196 +1075,196 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1075 1075
1076 } else if ( state == KCommandSocket::errorW ) { 1076 } else if ( state == KCommandSocket::errorW ) {
1077 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1077 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1078 mPisyncFinished = true; 1078 mPisyncFinished = true;
1079 1079
1080 } else if ( state == KCommandSocket::successR ) { 1080 } else if ( state == KCommandSocket::successR ) {
1081 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1081 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1082 1082
1083 } else if ( state == KCommandSocket::successW ) { 1083 } else if ( state == KCommandSocket::successW ) {
1084 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1084 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1085 mPisyncFinished = true; 1085 mPisyncFinished = true;
1086 } 1086 }
1087 1087
1088 delete s; 1088 delete s;
1089} 1089}
1090 1090
1091void KSyncManager::readFileFromSocket() 1091void KSyncManager::readFileFromSocket()
1092{ 1092{
1093 QString fileName = syncFileName(); 1093 QString fileName = syncFileName();
1094 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1094 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1095 if ( ! syncWithFile( fileName , true ) ) { 1095 if ( ! syncWithFile( fileName , true ) ) {
1096 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1096 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1097 mPisyncFinished = true; 1097 mPisyncFinished = true;
1098 return; 1098 return;
1099 } 1099 }
1100 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1100 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1101 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1101 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1102 if ( mWriteBackFile ) 1102 if ( mWriteBackFile )
1103 commandSocket->writeFile( fileName ); 1103 commandSocket->writeFile( fileName );
1104 else { 1104 else {
1105 commandSocket->sendStop(); 1105 commandSocket->sendStop();
1106 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1106 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1107 mPisyncFinished = true; 1107 mPisyncFinished = true;
1108 } 1108 }
1109} 1109}
1110 1110
1111KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1111KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1112{ 1112{
1113 mPassWord = pw; 1113 mPassWord = pw;
1114 mSocket = 0; 1114 mSocket = 0;
1115 mSyncActionDialog = 0; 1115 mSyncActionDialog = 0;
1116 blockRC = false; 1116 blockRC = false;
1117}; 1117};
1118 1118
1119void KServerSocket::newConnection ( int socket ) 1119void KServerSocket::newConnection ( int socket )
1120{ 1120{
1121 // qDebug("KServerSocket:New connection %d ", socket); 1121 // qDebug("KServerSocket:New connection %d ", socket);
1122 if ( mSocket ) { 1122 if ( mSocket ) {
1123 qDebug("KServerSocket::newConnection Socket deleted! "); 1123 qDebug("KSS::newConnection Socket deleted! ");
1124 delete mSocket; 1124 delete mSocket;
1125 mSocket = 0; 1125 mSocket = 0;
1126 } 1126 }
1127 mSocket = new QSocket( this ); 1127 mSocket = new QSocket( this );
1128 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1128 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1129 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1129 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1130 mSocket->setSocket( socket ); 1130 mSocket->setSocket( socket );
1131} 1131}
1132 1132
1133void KServerSocket::discardClient() 1133void KServerSocket::discardClient()
1134{ 1134{
1135 //qDebug(" KServerSocket::discardClient()"); 1135 //qDebug(" KServerSocket::discardClient()");
1136 if ( mSocket ) { 1136 if ( mSocket ) {
1137 delete mSocket; 1137 delete mSocket;
1138 mSocket = 0; 1138 mSocket = 0;
1139 } 1139 }
1140 //emit endConnect(); 1140 //emit endConnect();
1141} 1141}
1142void KServerSocket::readClient() 1142void KServerSocket::readClient()
1143{ 1143{
1144 if ( blockRC ) 1144 if ( blockRC )
1145 return; 1145 return;
1146 if ( mSocket == 0 ) { 1146 if ( mSocket == 0 ) {
1147 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 1147 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1148 return; 1148 return;
1149 } 1149 }
1150 //qDebug("KServerSocket::readClient()"); 1150 //qDebug("KServerSocket::readClient()");
1151 if ( mSocket->canReadLine() ) { 1151 if ( mSocket->canReadLine() ) {
1152 QString line = mSocket->readLine(); 1152 QString line = mSocket->readLine();
1153 //qDebug("KServerSocket readline: %s ", line.latin1()); 1153 //qDebug("KServerSocket readline: %s ", line.latin1());
1154 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1154 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1155 if ( tokens[0] == "GET" ) { 1155 if ( tokens[0] == "GET" ) {
1156 if ( tokens[1] == mPassWord ) { 1156 if ( tokens[1] == mPassWord ) {
1157 //emit sendFile( mSocket ); 1157 //emit sendFile( mSocket );
1158 bool ok = false; 1158 bool ok = false;
1159 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1159 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1160 if ( ok ) { 1160 if ( ok ) {
1161 KSyncManager::mRequestedSyncEvent = dt; 1161 KSyncManager::mRequestedSyncEvent = dt;
1162 } 1162 }
1163 else 1163 else
1164 KSyncManager::mRequestedSyncEvent = QDateTime(); 1164 KSyncManager::mRequestedSyncEvent = QDateTime();
1165 send_file(); 1165 send_file();
1166 } 1166 }
1167 else { 1167 else {
1168 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 1168 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
1169 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1169 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1170 } 1170 }
1171 } 1171 }
1172 if ( tokens[0] == "PUT" ) { 1172 if ( tokens[0] == "PUT" ) {
1173 if ( tokens[1] == mPassWord ) { 1173 if ( tokens[1] == mPassWord ) {
1174 //emit getFile( mSocket ); 1174 //emit getFile( mSocket );
1175 blockRC = true; 1175 blockRC = true;
1176 get_file(); 1176 get_file();
1177 } 1177 }
1178 else { 1178 else {
1179 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 1179 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
1180 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1180 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1181 } 1181 }
1182 } 1182 }
1183 if ( tokens[0] == "STOP" ) { 1183 if ( tokens[0] == "STOP" ) {
1184 //emit endConnect(); 1184 //emit endConnect();
1185 end_connect(); 1185 end_connect();
1186 } 1186 }
1187 } 1187 }
1188} 1188}
1189void KServerSocket::end_connect() 1189void KServerSocket::end_connect()
1190{ 1190{
1191 delete mSyncActionDialog; 1191 delete mSyncActionDialog;
1192 mSyncActionDialog = 0; 1192 mSyncActionDialog = 0;
1193} 1193}
1194void KServerSocket::send_file() 1194void KServerSocket::send_file()
1195{ 1195{
1196 //qDebug("MainWindow::sendFile(QSocket* s) "); 1196 //qDebug("MainWindow::sendFile(QSocket* s) ");
1197 if ( mSyncActionDialog ) 1197 if ( mSyncActionDialog )
1198 delete mSyncActionDialog; 1198 delete mSyncActionDialog;
1199 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1199 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1200 mSyncActionDialog->setCaption(i18n("Received sync request")); 1200 mSyncActionDialog->setCaption(i18n("Received sync request"));
1201 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1201 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1202 label->setAlignment ( Qt::AlignHCenter ); 1202 label->setAlignment ( Qt::AlignHCenter );
1203 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1203 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1204 lay->addWidget( label); 1204 lay->addWidget( label);
1205 lay->setMargin(7); 1205 lay->setMargin(7);
1206 lay->setSpacing(7); 1206 lay->setSpacing(7);
1207 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1207 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1208 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1208 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1209 if ( secs < 0 ) 1209 if ( secs < 0 )
1210 secs = secs * (-1); 1210 secs = secs * (-1);
1211 if ( secs > 30 ) 1211 if ( secs > 30 )
1212 //if ( true ) 1212 //if ( true )
1213 { 1213 {
1214 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1214 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1215 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1215 QLabel* label = new QLabel( warning, mSyncActionDialog );
1216 label->setAlignment ( Qt::AlignHCenter ); 1216 label->setAlignment ( Qt::AlignHCenter );
1217 lay->addWidget( label); 1217 lay->addWidget( label);
1218 if ( secs > 180 ) 1218 if ( secs > 180 )
1219 { 1219 {
1220 if ( secs > 300 ) { 1220 if ( secs > 300 ) {
1221 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1221 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1222 qDebug("cancelled "); 1222 qDebug("KSS::Sync cancelled ,cs");
1223 return ; 1223 return ;
1224 } 1224 }
1225 } 1225 }
1226 QFont f = label->font(); 1226 QFont f = label->font();
1227 f.setPointSize ( f.pointSize() *2 ); 1227 f.setPointSize ( f.pointSize() *2 );
1228 f. setBold (true ); 1228 f. setBold (true );
1229 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1229 QLabel* label = new QLabel( warning, mSyncActionDialog );
1230 label->setFont( f ); 1230 label->setFont( f );
1231 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1231 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1232 label->setText( warning ); 1232 label->setText( warning );
1233 label->setAlignment ( Qt::AlignHCenter ); 1233 label->setAlignment ( Qt::AlignHCenter );
1234 lay->addWidget( label); 1234 lay->addWidget( label);
1235 mSyncActionDialog->setFixedSize( 230, 300); 1235 mSyncActionDialog->setFixedSize( 230, 300);
1236 } else { 1236 } else {
1237 mSyncActionDialog->setFixedSize( 230, 200); 1237 mSyncActionDialog->setFixedSize( 230, 200);
1238 } 1238 }
1239 } else { 1239 } else {
1240 mSyncActionDialog->setFixedSize( 230, 120); 1240 mSyncActionDialog->setFixedSize( 230, 120);
1241 } 1241 }
1242 } else 1242 } else
1243 mSyncActionDialog->setFixedSize( 230, 120); 1243 mSyncActionDialog->setFixedSize( 230, 120);
1244 mSyncActionDialog->show(); 1244 mSyncActionDialog->show();
1245 mSyncActionDialog->raise(); 1245 mSyncActionDialog->raise();
1246 emit request_file(); 1246 emit request_file();
1247 qApp->processEvents(); 1247 qApp->processEvents();
1248 QString fileName = mFileName; 1248 QString fileName = mFileName;
1249 QFile file( fileName ); 1249 QFile file( fileName );
1250 if (!file.open( IO_ReadOnly ) ) { 1250 if (!file.open( IO_ReadOnly ) ) {
1251 delete mSyncActionDialog; 1251 delete mSyncActionDialog;
1252 mSyncActionDialog = 0; 1252 mSyncActionDialog = 0;
1253 qDebug("KSS::error open sync file: %s ", fileName.latin1()); 1253 qDebug("KSS::error open sync file: %s ", fileName.latin1());
1254 mSocket->close(); 1254 mSocket->close();
1255 if ( mSocket->state() == QSocket::Idle ) 1255 if ( mSocket->state() == QSocket::Idle )
1256 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1256 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1257 return ; 1257 return ;
1258 1258
1259 } 1259 }
1260 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1260 mSyncActionDialog->setCaption( i18n("Sending file...") );
1261 QTextStream ts( &file ); 1261 QTextStream ts( &file );
1262 ts.setEncoding( QTextStream::Latin1 ); 1262 ts.setEncoding( QTextStream::Latin1 );
1263 1263
1264 QTextStream os( mSocket ); 1264 QTextStream os( mSocket );
1265 os.setEncoding( QTextStream::Latin1 ); 1265 os.setEncoding( QTextStream::Latin1 );
1266 while ( ! ts.atEnd() ) { 1266 while ( ! ts.atEnd() ) {
1267 os << ts.readLine() << "\r\n"; 1267 os << ts.readLine() << "\r\n";
1268 } 1268 }
1269 //os << ts.read(); 1269 //os << ts.read();
1270 file.close(); 1270 file.close();
@@ -1420,66 +1420,66 @@ void KCommandSocket::startReadFileFromSocket()
1420 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1420 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1421 1421
1422} 1422}
1423void KCommandSocket::readFileFromSocket() 1423void KCommandSocket::readFileFromSocket()
1424{ 1424{
1425 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1425 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1426 while ( mSocket->canReadLine () ) { 1426 while ( mSocket->canReadLine () ) {
1427 mTime.restart(); 1427 mTime.restart();
1428 QString line = mSocket->readLine (); 1428 QString line = mSocket->readLine ();
1429 mFileString += line; 1429 mFileString += line;
1430 //qDebug("readline: %s ", line.latin1()); 1430 //qDebug("readline: %s ", line.latin1());
1431 } 1431 }
1432 if ( mTime.elapsed () < 3000 ) { 1432 if ( mTime.elapsed () < 3000 ) {
1433 // wait for more 1433 // wait for more
1434 //qDebug("waitformore "); 1434 //qDebug("waitformore ");
1435 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1435 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1436 return; 1436 return;
1437 } 1437 }
1438 QString fileName = mFileName; 1438 QString fileName = mFileName;
1439 QFile file ( fileName ); 1439 QFile file ( fileName );
1440 if (!file.open( IO_WriteOnly ) ) { 1440 if (!file.open( IO_WriteOnly ) ) {
1441 mFileString = ""; 1441 mFileString = "";
1442 mRetVal = errorR; 1442 mRetVal = errorR;
1443 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1443 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1444 deleteSocket(); 1444 deleteSocket();
1445 return ; 1445 return ;
1446 1446
1447 } 1447 }
1448 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1448 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1449 QTextStream ts ( &file ); 1449 QTextStream ts ( &file );
1450 ts.setEncoding( QTextStream::Latin1 ); 1450 ts.setEncoding( QTextStream::Latin1 );
1451 ts << mFileString; 1451 ts << mFileString;
1452 file.close(); 1452 file.close();
1453 mFileString = ""; 1453 mFileString = "";
1454 mRetVal = successR; 1454 mRetVal = successR;
1455 mSocket->close(); 1455 mSocket->close();
1456 // if state is not idle, deleteSocket(); is called via 1456 // if state is not idle, deleteSocket(); is called via
1457 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1457 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1458 if ( mSocket->state() == QSocket::Idle ) 1458 if ( mSocket->state() == QSocket::Idle )
1459 deleteSocket(); 1459 deleteSocket();
1460} 1460}
1461 1461
1462void KCommandSocket::deleteSocket() 1462void KCommandSocket::deleteSocket()
1463{ 1463{
1464 //qDebug("KCommandSocket::deleteSocket() "); 1464 //qDebug("KCommandSocket::deleteSocket() ");
1465 if ( mTimerSocket->isActive () ) { 1465 if ( mTimerSocket->isActive () ) {
1466 mTimerSocket->stop(); 1466 mTimerSocket->stop();
1467 mRetVal = errorTO; 1467 mRetVal = errorTO;
1468 qDebug("Connection to remote host timed out"); 1468 qDebug("KCS::Connection to remote host timed out");
1469 if ( mSocket ) { 1469 if ( mSocket ) {
1470 mSocket->close(); 1470 mSocket->close();
1471 //if ( mSocket->state() == QSocket::Idle ) 1471 //if ( mSocket->state() == QSocket::Idle )
1472 // deleteSocket(); 1472 // deleteSocket();
1473 delete mSocket; 1473 delete mSocket;
1474 mSocket = 0; 1474 mSocket = 0;
1475 } 1475 }
1476 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1476 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1477 emit commandFinished( this, mRetVal ); 1477 emit commandFinished( this, mRetVal );
1478 return; 1478 return;
1479 } 1479 }
1480 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1480 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1481 if ( mSocket) 1481 if ( mSocket)
1482 delete mSocket; 1482 delete mSocket;
1483 mSocket = 0; 1483 mSocket = 0;
1484 emit commandFinished( this, mRetVal ); 1484 emit commandFinished( this, mRetVal );
1485} 1485}