summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp24
-rw-r--r--libkdepim/ksyncmanager.h9
2 files changed, 28 insertions, 5 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 7ee56e4..c6e06f8 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -101,97 +101,97 @@ void KSyncManager::fillSyncMenu()
101 prof.clear(); 101 prof.clear();
102#ifdef DESKTOP_VERSION 102#ifdef DESKTOP_VERSION
103#ifdef _WIN32_ 103#ifdef _WIN32_
104 prof << i18n("OutLook(not_implemented)"); 104 prof << i18n("OutLook(not_implemented)");
105#else 105#else
106 prof << i18n("KDE_Desktop"); 106 prof << i18n("KDE_Desktop");
107#endif 107#endif
108#else 108#else
109 prof << i18n("Sharp_DTM"); 109 prof << i18n("Sharp_DTM");
110#endif 110#endif
111 prof << i18n("Local_file"); 111 prof << i18n("Local_file");
112 prof << i18n("Last_file"); 112 prof << i18n("Last_file");
113 KSyncProfile* temp = new KSyncProfile (); 113 KSyncProfile* temp = new KSyncProfile ();
114 temp->setName( prof[0] ); 114 temp->setName( prof[0] );
115 temp->writeConfig(&config); 115 temp->writeConfig(&config);
116 temp->setName( prof[1] ); 116 temp->setName( prof[1] );
117 temp->writeConfig(&config); 117 temp->writeConfig(&config);
118 temp->setName( prof[2] ); 118 temp->setName( prof[2] );
119 temp->writeConfig(&config); 119 temp->writeConfig(&config);
120 config.setGroup("General"); 120 config.setGroup("General");
121 config.writeEntry("SyncProfileNames",prof); 121 config.writeEntry("SyncProfileNames",prof);
122 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 122 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
123 config.sync(); 123 config.sync();
124 delete temp; 124 delete temp;
125 } 125 }
126 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 126 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
127 mSyncProfileNames = prof; 127 mSyncProfileNames = prof;
128 unsigned int i; 128 unsigned int i;
129 for ( i = 0; i < prof.count(); ++i ) { 129 for ( i = 0; i < prof.count(); ++i ) {
130 mSyncMenu->insertItem( prof[i], 1000+i ); 130 mSyncMenu->insertItem( prof[i], 1000+i );
131 if ( i == 2 ) 131 if ( i == 2 )
132 mSyncMenu->insertSeparator(); 132 mSyncMenu->insertSeparator();
133 } 133 }
134 QDir app_dir; 134 QDir app_dir;
135 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 135 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
136 if ( mTargetApp == PWMPI) { 136 if ( mTargetApp == PWMPI) {
137 mSyncMenu->removeItem( 1000 ); 137 mSyncMenu->removeItem( 1000 );
138 } 138 }
139#ifndef DESKTOP_VERSION 139#ifndef DESKTOP_VERSION
140 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 140 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
141 mSyncMenu->removeItem( 1000 ); 141 mSyncMenu->removeItem( 1000 );
142 } 142 }
143#endif 143#endif
144 mSyncMenu->removeItem( 1002 ); 144 mSyncMenu->removeItem( 1002 );
145} 145}
146 146
147void KSyncManager::slotSyncMenu( int action ) 147void KSyncManager::slotSyncMenu( int action )
148{ 148{
149 //qDebug("syncaction %d ", action); 149 qDebug("syncaction %d ", action);
150 if ( action == 0 ) { 150 if ( action == 0 ) {
151 151
152 // seems to be a Qt2 event handling bug 152 // seems to be a Qt2 event handling bug
153 // syncmenu.clear causes a segfault at first time 153 // syncmenu.clear causes a segfault at first time
154 // when we call it after the main event loop, it is ok 154 // when we call it after the main event loop, it is ok
155 // same behaviour when calling OM/Pi via QCOP for the first time 155 // same behaviour when calling OM/Pi via QCOP for the first time
156 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 156 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
157 //confSync(); 157 //confSync();
158 158
159 return; 159 return;
160 } 160 }
161 if ( action == 1 ) { 161 if ( action == 1 ) {
162 multiSync( true ); 162 multiSync( true );
163 return; 163 return;
164 } 164 }
165 if ( action == 2 ) { 165 if ( action == 2 ) {
166 enableQuick(); 166 enableQuick();
167 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 167 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
168 return; 168 return;
169 } 169 }
170 if ( action == 3 ) { 170 if ( action == 3 ) {
171 delete mServerSocket; 171 delete mServerSocket;
172 mServerSocket = 0; 172 mServerSocket = 0;
173 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 173 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
174 return; 174 return;
175 } 175 }
176 176
177 if (blockSave()) 177 if (blockSave())
178 return; 178 return;
179 179
180 setBlockSave(true); 180 setBlockSave(true);
181 181
182 mCurrentSyncProfile = action - 1000 ; 182 mCurrentSyncProfile = action - 1000 ;
183 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 183 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
184 mCurrentSyncName = mLocalMachineName ; 184 mCurrentSyncName = mLocalMachineName ;
185 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 185 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
186 KSyncProfile* temp = new KSyncProfile (); 186 KSyncProfile* temp = new KSyncProfile ();
187 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 187 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
188 temp->readConfig(&config); 188 temp->readConfig(&config);
189 mAskForPreferences = temp->getAskForPreferences(); 189 mAskForPreferences = temp->getAskForPreferences();
190 mSyncAlgoPrefs = temp->getSyncPrefs(); 190 mSyncAlgoPrefs = temp->getSyncPrefs();
191 mWriteBackFile = temp->getWriteBackFile(); 191 mWriteBackFile = temp->getWriteBackFile();
192 mWriteBackExistingOnly = temp->getWriteBackExisting(); 192 mWriteBackExistingOnly = temp->getWriteBackExisting();
193 mIsKapiFile = temp->getIsKapiFile(); 193 mIsKapiFile = temp->getIsKapiFile();
194 mWriteBackInFuture = 0; 194 mWriteBackInFuture = 0;
195 if ( temp->getWriteBackFuture() ) 195 if ( temp->getWriteBackFuture() )
196 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 196 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
197 mShowSyncSummary = temp->getShowSummaryAfterSync(); 197 mShowSyncSummary = temp->getShowSummaryAfterSync();
@@ -209,96 +209,100 @@ void KSyncManager::slotSyncMenu( int action )
209 mWriteBackFile = false; 209 mWriteBackFile = false;
210 mAskForPreferences = false; 210 mAskForPreferences = false;
211 mShowSyncSummary = false; 211 mShowSyncSummary = false;
212 mSyncAlgoPrefs = 3; 212 mSyncAlgoPrefs = 3;
213 quickSyncLocalFile(); 213 quickSyncLocalFile();
214 214
215 } else if ( action >= 1003 ) { 215 } else if ( action >= 1003 ) {
216 if ( temp->getIsLocalFileSync() ) { 216 if ( temp->getIsLocalFileSync() ) {
217 switch(mTargetApp) 217 switch(mTargetApp)
218 { 218 {
219 case (KAPI): 219 case (KAPI):
220 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 220 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
221 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 221 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
222 break; 222 break;
223 case (KOPI): 223 case (KOPI):
224 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 224 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
225 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 225 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
226 break; 226 break;
227 case (PWMPI): 227 case (PWMPI):
228 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 228 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
229 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 229 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
230 break; 230 break;
231 default: 231 default:
232 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 232 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
233 break; 233 break;
234 234
235 } 235 }
236 } else { 236 } else {
237 if ( temp->getIsPhoneSync() ) { 237 if ( temp->getIsPhoneSync() ) {
238 mPhoneDevice = temp->getPhoneDevice( ) ; 238 mPhoneDevice = temp->getPhoneDevice( ) ;
239 mPhoneConnection = temp->getPhoneConnection( ); 239 mPhoneConnection = temp->getPhoneConnection( );
240 mPhoneModel = temp->getPhoneModel( ); 240 mPhoneModel = temp->getPhoneModel( );
241 syncPhone(); 241 syncPhone();
242 } else if ( temp->getIsPiSync() ) { 242 } else if ( temp->getIsPiSync() ) {
243 if ( mTargetApp == KAPI ) { 243 if ( mTargetApp == KAPI ) {
244 mPassWordPiSync = temp->getRemotePwAB(); 244 mPassWordPiSync = temp->getRemotePwAB();
245 mActiveSyncPort = temp->getRemotePortAB(); 245 mActiveSyncPort = temp->getRemotePortAB();
246 mActiveSyncIP = temp->getRemoteIPAB(); 246 mActiveSyncIP = temp->getRemoteIPAB();
247 } else if ( mTargetApp == KOPI ) { 247 } else if ( mTargetApp == KOPI ) {
248 mPassWordPiSync = temp->getRemotePw(); 248 mPassWordPiSync = temp->getRemotePw();
249 mActiveSyncPort = temp->getRemotePort(); 249 mActiveSyncPort = temp->getRemotePort();
250 mActiveSyncIP = temp->getRemoteIP(); 250 mActiveSyncIP = temp->getRemoteIP();
251 } else { 251 } else {
252 mPassWordPiSync = temp->getRemotePwPWM(); 252 mPassWordPiSync = temp->getRemotePwPWM();
253 mActiveSyncPort = temp->getRemotePortPWM(); 253 mActiveSyncPort = temp->getRemotePortPWM();
254 mActiveSyncIP = temp->getRemoteIPPWM(); 254 mActiveSyncIP = temp->getRemoteIPPWM();
255 } 255 }
256 syncPi(); 256 syncPi();
257 while ( !mPisyncFinished ) {
258 //qDebug("waiting ");
259 qApp->processEvents();
260 }
257 } else 261 } else
258 syncRemote( temp ); 262 syncRemote( temp );
259 263
260 } 264 }
261 } 265 }
262 delete temp; 266 delete temp;
263 setBlockSave(false); 267 setBlockSave(false);
264} 268}
265 269
266void KSyncManager::enableQuick() 270void KSyncManager::enableQuick()
267{ 271{
268 QDialog dia ( 0, "input-dialog", true ); 272 QDialog dia ( 0, "input-dialog", true );
269 QLineEdit lab ( &dia ); 273 QLineEdit lab ( &dia );
270 QVBoxLayout lay( &dia ); 274 QVBoxLayout lay( &dia );
271 lab.setText( mPrefs->mPassiveSyncPort ); 275 lab.setText( mPrefs->mPassiveSyncPort );
272 lay.setMargin(7); 276 lay.setMargin(7);
273 lay.setSpacing(7); 277 lay.setSpacing(7);
274 int po = 9197+mTargetApp; 278 int po = 9197+mTargetApp;
275 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 279 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
276 lay.addWidget( &label); 280 lay.addWidget( &label);
277 lay.addWidget( &lab); 281 lay.addWidget( &lab);
278 282
279 QLineEdit lepw ( &dia ); 283 QLineEdit lepw ( &dia );
280 lepw.setText( mPrefs->mPassiveSyncPw ); 284 lepw.setText( mPrefs->mPassiveSyncPw );
281 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 285 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
282 lay.addWidget( &label2); 286 lay.addWidget( &label2);
283 lay.addWidget( &lepw); 287 lay.addWidget( &lepw);
284 dia.setFixedSize( 230,80 ); 288 dia.setFixedSize( 230,80 );
285 dia.setCaption( i18n("Enter port for Pi-Sync") ); 289 dia.setCaption( i18n("Enter port for Pi-Sync") );
286 QPushButton pb ( "OK", &dia); 290 QPushButton pb ( "OK", &dia);
287 lay.addWidget( &pb ); 291 lay.addWidget( &pb );
288 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 292 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
289 dia.show(); 293 dia.show();
290 if ( ! dia.exec() ) 294 if ( ! dia.exec() )
291 return; 295 return;
292 dia.hide(); 296 dia.hide();
293 qApp->processEvents(); 297 qApp->processEvents();
294 mPrefs->mPassiveSyncPw = lepw.text(); 298 mPrefs->mPassiveSyncPw = lepw.text();
295 mPrefs->mPassiveSyncPort = lab.text(); 299 mPrefs->mPassiveSyncPort = lab.text();
296 bool ok; 300 bool ok;
297 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 301 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
298 if ( ! ok ) { 302 if ( ! ok ) {
299 KMessageBox::information( 0, i18n("No valid port")); 303 KMessageBox::information( 0, i18n("No valid port"));
300 return; 304 return;
301 } 305 }
302 //qDebug("port %d ", port); 306 //qDebug("port %d ", port);
303 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 307 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
304 mServerSocket->setFileName( defaultFileName() ); 308 mServerSocket->setFileName( defaultFileName() );
@@ -427,138 +431,150 @@ void KSyncManager::multiSync( bool askforPrefs )
427} 431}
428 432
429int KSyncManager::ringSync() 433int KSyncManager::ringSync()
430{ 434{
431 int syncedProfiles = 0; 435 int syncedProfiles = 0;
432 unsigned int i; 436 unsigned int i;
433 QTime timer; 437 QTime timer;
434 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 438 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
435 QStringList syncProfileNames = mSyncProfileNames; 439 QStringList syncProfileNames = mSyncProfileNames;
436 KSyncProfile* temp = new KSyncProfile (); 440 KSyncProfile* temp = new KSyncProfile ();
437 mAskForPreferences = false; 441 mAskForPreferences = false;
438 for ( i = 0; i < syncProfileNames.count(); ++i ) { 442 for ( i = 0; i < syncProfileNames.count(); ++i ) {
439 mCurrentSyncProfile = i; 443 mCurrentSyncProfile = i;
440 temp->setName(syncProfileNames[mCurrentSyncProfile]); 444 temp->setName(syncProfileNames[mCurrentSyncProfile]);
441 temp->readConfig(&config); 445 temp->readConfig(&config);
442 446
443 bool includeInRingSync; 447 bool includeInRingSync;
444 switch(mTargetApp) 448 switch(mTargetApp)
445 { 449 {
446 case (KAPI): 450 case (KAPI):
447 includeInRingSync = temp->getIncludeInRingSyncAB(); 451 includeInRingSync = temp->getIncludeInRingSyncAB();
448 break; 452 break;
449 case (KOPI): 453 case (KOPI):
450 includeInRingSync = temp->getIncludeInRingSync(); 454 includeInRingSync = temp->getIncludeInRingSync();
451 break; 455 break;
452 case (PWMPI): 456 case (PWMPI):
453 includeInRingSync = temp->getIncludeInRingSyncPWM(); 457 includeInRingSync = temp->getIncludeInRingSyncPWM();
454 break; 458 break;
455 default: 459 default:
456 qDebug("KSyncManager::ringSync: invalid apptype selected"); 460 qDebug("KSyncManager::ringSync: invalid apptype selected");
457 break; 461 break;
458 462
459 } 463 }
460 464
461 465
462 if ( includeInRingSync && ( i < 1 || i > 2 )) { 466 if ( includeInRingSync && ( i < 1 || i > 2 )) {
463 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 467 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
464 ++syncedProfiles; 468 ++syncedProfiles;
465 // mAskForPreferences = temp->getAskForPreferences(); 469 // mAskForPreferences = temp->getAskForPreferences();
466 mWriteBackFile = temp->getWriteBackFile(); 470 mWriteBackFile = temp->getWriteBackFile();
467 mWriteBackExistingOnly = temp->getWriteBackExisting(); 471 mWriteBackExistingOnly = temp->getWriteBackExisting();
468 mWriteBackInFuture = 0; 472 mWriteBackInFuture = 0;
469 if ( temp->getWriteBackFuture() ) 473 if ( temp->getWriteBackFuture() )
470 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 474 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
471 mShowSyncSummary = false; 475 mShowSyncSummary = false;
472 mCurrentSyncDevice = syncProfileNames[i] ; 476 mCurrentSyncDevice = syncProfileNames[i] ;
473 mCurrentSyncName = mLocalMachineName; 477 mCurrentSyncName = mLocalMachineName;
474 if ( i == 0 ) { 478 if ( i == 0 ) {
479#ifdef DESKTOP_VERSION
480 syncKDE();
481#else
475 syncSharp(); 482 syncSharp();
483#endif
476 } else { 484 } else {
477 if ( temp->getIsLocalFileSync() ) { 485 if ( temp->getIsLocalFileSync() ) {
478 switch(mTargetApp) 486 switch(mTargetApp)
479 { 487 {
480 case (KAPI): 488 case (KAPI):
481 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 489 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
482 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 490 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
483 break; 491 break;
484 case (KOPI): 492 case (KOPI):
485 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 493 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
486 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 494 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
487 break; 495 break;
488 case (PWMPI): 496 case (PWMPI):
489 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 497 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
490 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 498 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
491 break; 499 break;
492 default: 500 default:
493 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 501 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
494 break; 502 break;
495 } 503 }
496 } else { 504 } else {
497 if ( temp->getIsPhoneSync() ) { 505 if ( temp->getIsPhoneSync() ) {
498 mPhoneDevice = temp->getPhoneDevice( ) ; 506 mPhoneDevice = temp->getPhoneDevice( ) ;
499 mPhoneConnection = temp->getPhoneConnection( ); 507 mPhoneConnection = temp->getPhoneConnection( );
500 mPhoneModel = temp->getPhoneModel( ); 508 mPhoneModel = temp->getPhoneModel( );
501 syncPhone(); 509 syncPhone();
502 } else if ( temp->getIsPiSync() ) { 510 } else if ( temp->getIsPiSync() ) {
503 if ( mTargetApp == KAPI ) { 511 if ( mTargetApp == KAPI ) {
504 mPassWordPiSync = temp->getRemotePwAB(); 512 mPassWordPiSync = temp->getRemotePwAB();
505 mActiveSyncPort = temp->getRemotePortAB(); 513 mActiveSyncPort = temp->getRemotePortAB();
506 mActiveSyncIP = temp->getRemoteIPAB(); 514 mActiveSyncIP = temp->getRemoteIPAB();
507 } else if ( mTargetApp == KOPI ) { 515 } else if ( mTargetApp == KOPI ) {
508 mPassWordPiSync = temp->getRemotePw(); 516 mPassWordPiSync = temp->getRemotePw();
509 mActiveSyncPort = temp->getRemotePort(); 517 mActiveSyncPort = temp->getRemotePort();
510 mActiveSyncIP = temp->getRemoteIP(); 518 mActiveSyncIP = temp->getRemoteIP();
511 } else { 519 } else {
512 mPassWordPiSync = temp->getRemotePwPWM(); 520 mPassWordPiSync = temp->getRemotePwPWM();
513 mActiveSyncPort = temp->getRemotePortPWM(); 521 mActiveSyncPort = temp->getRemotePortPWM();
514 mActiveSyncIP = temp->getRemoteIPPWM(); 522 mActiveSyncIP = temp->getRemoteIPPWM();
515 } 523 }
516 syncPi(); 524 syncPi();
525 while ( !mPisyncFinished ) {
526 //qDebug("waiting ");
527 qApp->processEvents();
528 }
529 timer.start();
530 while ( timer.elapsed () < 2000 ) {
531 qApp->processEvents();
532 }
517 } else 533 } else
518 syncRemote( temp, false ); 534 syncRemote( temp, false );
519 535
520 } 536 }
521 } 537 }
522 timer.start(); 538 timer.start();
523 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 539 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
524 while ( timer.elapsed () < 2000 ) { 540 while ( timer.elapsed () < 2000 ) {
525 qApp->processEvents(); 541 qApp->processEvents();
526#ifndef _WIN32_ 542#ifndef _WIN32_
527 sleep (1); 543 sleep (1);
528#endif 544#endif
529 } 545 }
530 546
531 } 547 }
532 548
533 } 549 }
534 delete temp; 550 delete temp;
535 return syncedProfiles; 551 return syncedProfiles;
536} 552}
537 553
538void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 554void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
539{ 555{
540 QString question; 556 QString question;
541 if ( ask ) { 557 if ( ask ) {
542 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 558 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
543 if ( QMessageBox::information( mParent, i18n("Sync"), 559 if ( QMessageBox::information( mParent, i18n("Sync"),
544 question, 560 question,
545 i18n("Yes"), i18n("No"), 561 i18n("Yes"), i18n("No"),
546 0, 0 ) != 0 ) 562 0, 0 ) != 0 )
547 return; 563 return;
548 } 564 }
549 565
550 QString preCommand; 566 QString preCommand;
551 QString localTempFile; 567 QString localTempFile;
552 QString postCommand; 568 QString postCommand;
553 569
554 switch(mTargetApp) 570 switch(mTargetApp)
555 { 571 {
556 case (KAPI): 572 case (KAPI):
557 preCommand = prof->getPreSyncCommandAB(); 573 preCommand = prof->getPreSyncCommandAB();
558 postCommand = prof->getPostSyncCommandAB(); 574 postCommand = prof->getPostSyncCommandAB();
559 localTempFile = prof->getLocalTempFileAB(); 575 localTempFile = prof->getLocalTempFileAB();
560 break; 576 break;
561 case (KOPI): 577 case (KOPI):
562 preCommand = prof->getPreSyncCommand(); 578 preCommand = prof->getPreSyncCommand();
563 postCommand = prof->getPostSyncCommand(); 579 postCommand = prof->getPostSyncCommand();
564 localTempFile = prof->getLocalTempFile(); 580 localTempFile = prof->getLocalTempFile();
@@ -821,152 +837,158 @@ void KSyncManager::showProgressBar(int percentage, QString caption, int total)
821 if (!bar->isVisible()) 837 if (!bar->isVisible())
822 { 838 {
823 bar->setCaption (caption); 839 bar->setCaption (caption);
824 bar->setTotalSteps ( total ) ; 840 bar->setTotalSteps ( total ) ;
825 841
826 bar->show(); 842 bar->show();
827 } 843 }
828 844
829 bar->setProgress( percentage ); 845 bar->setProgress( percentage );
830} 846}
831 847
832void KSyncManager::hideProgressBar() 848void KSyncManager::hideProgressBar()
833{ 849{
834 bar->hide(); 850 bar->hide();
835} 851}
836 852
837bool KSyncManager::isProgressBarCanceled() 853bool KSyncManager::isProgressBarCanceled()
838{ 854{
839 return !bar->isVisible(); 855 return !bar->isVisible();
840} 856}
841 857
842QString KSyncManager::syncFileName() 858QString KSyncManager::syncFileName()
843{ 859{
844 860
845 QString fn = "tempfile"; 861 QString fn = "tempfile";
846 switch(mTargetApp) 862 switch(mTargetApp)
847 { 863 {
848 case (KAPI): 864 case (KAPI):
849 fn = "tempsyncab.vcf"; 865 fn = "tempsyncab.vcf";
850 break; 866 break;
851 case (KOPI): 867 case (KOPI):
852 fn = "tempsynccal.ics"; 868 fn = "tempsynccal.ics";
853 break; 869 break;
854 case (PWMPI): 870 case (PWMPI):
855 fn = "tempsyncpw.pwm"; 871 fn = "tempsyncpw.pwm";
856 break; 872 break;
857 default: 873 default:
858 break; 874 break;
859 } 875 }
860#ifdef _WIN32_ 876#ifdef _WIN32_
861 return locateLocal( "tmp", fn ); 877 return locateLocal( "tmp", fn );
862#else 878#else
863 return (QString( "/tmp/" )+ fn ); 879 return (QString( "/tmp/" )+ fn );
864#endif 880#endif
865} 881}
866 882
867void KSyncManager::syncPi() 883void KSyncManager::syncPi()
868{ 884{
885 mPisyncFinished = false;
869 qApp->processEvents(); 886 qApp->processEvents();
870 if ( mAskForPreferences ) 887 if ( mAskForPreferences )
871 edit_pisync_options(); 888 edit_pisync_options();
872 bool ok; 889 bool ok;
873 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 890 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
874 if ( ! ok ) { 891 if ( ! ok ) {
875 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 892 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
876 return; 893 return;
877 } 894 }
878 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 895 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
879 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 896 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
880 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 897 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
881 commandSocket->readFile( syncFileName() ); 898 commandSocket->readFile( syncFileName() );
882} 899}
883 900
884void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 901void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
885{ 902{
886 //enum { success, errorW, errorR, quiet }; 903 //enum { success, errorW, errorR, quiet };
887 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 904 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
888 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 905 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
889 delete s; 906 delete s;
890 if ( state == KCommandSocket::errorR ) { 907 if ( state == KCommandSocket::errorR ) {
891 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 908 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
892 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 909 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
893 commandSocket->sendStop(); 910 commandSocket->sendStop();
894 } 911 }
912 mPisyncFinished = true;
895 return; 913 return;
896 914
897 } else if ( state == KCommandSocket::errorW ) { 915 } else if ( state == KCommandSocket::errorW ) {
898 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 916 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
917 mPisyncFinished = true;
899 918
900 } else if ( state == KCommandSocket::successR ) { 919 } else if ( state == KCommandSocket::successR ) {
901 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 920 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
902 921
903 } else if ( state == KCommandSocket::successW ) { 922 } else if ( state == KCommandSocket::successW ) {
904 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 923 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
924 mPisyncFinished = true;
905 } 925 }
906 926
907 delete s; 927 delete s;
908} 928}
909 929
910void KSyncManager::readFileFromSocket() 930void KSyncManager::readFileFromSocket()
911{ 931{
912 QString fileName = syncFileName(); 932 QString fileName = syncFileName();
913 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 933 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
914 if ( ! syncWithFile( fileName , true ) ) { 934 if ( ! syncWithFile( fileName , true ) ) {
915 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 935 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
936 mPisyncFinished = true;
916 return; 937 return;
917 } 938 }
918 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 939 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
919 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 940 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
920 if ( mWriteBackFile ) 941 if ( mWriteBackFile )
921 commandSocket->writeFile( fileName ); 942 commandSocket->writeFile( fileName );
922 else { 943 else {
923 commandSocket->sendStop(); 944 commandSocket->sendStop();
924 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 945 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
946 mPisyncFinished = true;
925 } 947 }
926} 948}
927 949
928KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 950KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
929{ 951{
930 mPassWord = pw; 952 mPassWord = pw;
931 mSocket = 0; 953 mSocket = 0;
932 mSyncActionDialog = 0; 954 mSyncActionDialog = 0;
933 blockRC = false; 955 blockRC = false;
934}; 956};
935 957
936void KServerSocket::newConnection ( int socket ) 958void KServerSocket::newConnection ( int socket )
937{ 959{
938 // qDebug("KServerSocket:New connection %d ", socket); 960 // qDebug("KServerSocket:New connection %d ", socket);
939 if ( mSocket ) { 961 if ( mSocket ) {
940 qDebug("KServerSocket::newConnection Socket deleted! "); 962 qDebug("KServerSocket::newConnection Socket deleted! ");
941 delete mSocket; 963 delete mSocket;
942 mSocket = 0; 964 mSocket = 0;
943 } 965 }
944 mSocket = new QSocket( this ); 966 mSocket = new QSocket( this );
945 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 967 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
946 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 968 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
947 mSocket->setSocket( socket ); 969 mSocket->setSocket( socket );
948} 970}
949 971
950void KServerSocket::discardClient() 972void KServerSocket::discardClient()
951{ 973{
952 //qDebug(" KServerSocket::discardClient()"); 974 //qDebug(" KServerSocket::discardClient()");
953 if ( mSocket ) { 975 if ( mSocket ) {
954 delete mSocket; 976 delete mSocket;
955 mSocket = 0; 977 mSocket = 0;
956 } 978 }
957 //emit endConnect(); 979 //emit endConnect();
958} 980}
959void KServerSocket::readClient() 981void KServerSocket::readClient()
960{ 982{
961 if ( blockRC ) 983 if ( blockRC )
962 return; 984 return;
963 if ( mSocket == 0 ) { 985 if ( mSocket == 0 ) {
964 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 986 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
965 return; 987 return;
966 } 988 }
967 //qDebug("KServerSocket::readClient()"); 989 //qDebug("KServerSocket::readClient()");
968 if ( mSocket->canReadLine() ) { 990 if ( mSocket->canReadLine() ) {
969 QString line = mSocket->readLine(); 991 QString line = mSocket->readLine();
970 //qDebug("KServerSocket readline: %s ", line.latin1()); 992 //qDebug("KServerSocket readline: %s ", line.latin1());
971 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 993 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
972 if ( tokens[0] == "GET" ) { 994 if ( tokens[0] == "GET" ) {
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 7d5b05e..ffb1ea4 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -133,78 +133,79 @@ class KSyncManager : public QObject
133 QStringList mExternSyncProfiles; 133 QStringList mExternSyncProfiles;
134 QStringList mSyncProfileNames; 134 QStringList mSyncProfileNames;
135 bool mAskForPreferences; 135 bool mAskForPreferences;
136 bool mShowSyncSummary; 136 bool mShowSyncSummary;
137 bool mIsKapiFile; 137 bool mIsKapiFile;
138 bool mWriteBackExistingOnly; 138 bool mWriteBackExistingOnly;
139 int mSyncAlgoPrefs; 139 int mSyncAlgoPrefs;
140 bool mWriteBackFile; 140 bool mWriteBackFile;
141 int mWriteBackInFuture; 141 int mWriteBackInFuture;
142 QString mPhoneDevice; 142 QString mPhoneDevice;
143 QString mPhoneConnection; 143 QString mPhoneConnection;
144 QString mPhoneModel; 144 QString mPhoneModel;
145 QString mPassWordPiSync; 145 QString mPassWordPiSync;
146 QString mActiveSyncPort; 146 QString mActiveSyncPort;
147 QString mActiveSyncIP ; 147 QString mActiveSyncIP ;
148 148
149 signals: 149 signals:
150 void save(); 150 void save();
151 void request_file(); 151 void request_file();
152 void getFile( bool ); 152 void getFile( bool );
153 153
154 public slots: 154 public slots:
155 void slotSyncMenu( int ); 155 void slotSyncMenu( int );
156 void deleteCommandSocket(KCommandSocket*s, int state); 156 void deleteCommandSocket(KCommandSocket*s, int state);
157 void readFileFromSocket(); 157 void readFileFromSocket();
158 void fillSyncMenu(); 158 void fillSyncMenu();
159 159
160 private: 160 private:
161 void syncPi(); 161 void syncPi();
162 KServerSocket * mServerSocket; 162 KServerSocket * mServerSocket;
163 void enableQuick(); 163 void enableQuick();
164 KPimPrefs* mPrefs; 164 KPimPrefs* mPrefs;
165 QString mDefFileName; 165 QString mDefFileName;
166 QString mCurrentSyncDevice; 166 QString mCurrentSyncDevice;
167 QString mCurrentSyncName; 167 QString mCurrentSyncName;
168 void quickSyncLocalFile(); 168 void quickSyncLocalFile();
169 bool syncWithFile( QString fn , bool quick ); 169 bool syncWithFile( QString fn , bool quick );
170 void syncLocalFile(); 170 void syncLocalFile();
171 void syncPhone(); 171 void syncPhone();
172 void syncSharp(); 172 void syncSharp();
173 void syncKDE(); 173 void syncKDE();
174 bool syncExternalApplication(QString); 174 bool syncExternalApplication(QString);
175 int mCurrentSyncProfile ; 175 int mCurrentSyncProfile ;
176 void syncRemote( KSyncProfile* prof, bool ask = true); 176 void syncRemote( KSyncProfile* prof, bool ask = true);
177 void edit_sync_options(); 177 void edit_sync_options();
178 void edit_pisync_options(); 178 void edit_pisync_options();
179 int ringSync(); 179 int ringSync();
180 QString getPassword( ); 180 QString getPassword( );
181 181 bool mPisyncFinished;
182 private slots:
183 void confSync();
184 private:
185 bool mBlockSaveFlag; 182 bool mBlockSaveFlag;
186 QWidget* mParent; 183 QWidget* mParent;
187 KSyncInterface* mImplementation; 184 KSyncInterface* mImplementation;
188 TargetApp mTargetApp; 185 TargetApp mTargetApp;
189 QPopupMenu* mSyncMenu; 186 QPopupMenu* mSyncMenu;
190 QProgressBar* bar; 187 QProgressBar* bar;
191 188
189private slots:
190 void confSync();
191
192
192}; 193};
193 194
194 195
195class KSyncInterface 196class KSyncInterface
196{ 197{
197 public : 198 public :
198 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 199 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
199 virtual bool syncExternal(KSyncManager* manager, QString resource) 200 virtual bool syncExternal(KSyncManager* manager, QString resource)
200 { 201 {
201 // empty implementation, because some syncable applications do not 202 // empty implementation, because some syncable applications do not
202 // have an external(sharpdtm) syncmode, like pwmanager. 203 // have an external(sharpdtm) syncmode, like pwmanager.
203 return false; 204 return false;
204 } 205 }
205 206
206 207
207}; 208};
208 209
209 210
210#endif 211#endif