summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 75c0b2b..7ca3ee0 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -228,165 +228,179 @@ void KSyncManager::slotSyncMenu( int action )
228 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 228 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
229 break; 229 break;
230 case (PWMPI): 230 case (PWMPI):
231 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 231 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
232 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 232 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
233 break; 233 break;
234 default: 234 default:
235 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 235 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
236 break; 236 break;
237 237
238 } 238 }
239 } else { 239 } else {
240 if ( temp->getIsPhoneSync() ) { 240 if ( temp->getIsPhoneSync() ) {
241 mPhoneDevice = temp->getPhoneDevice( ) ; 241 mPhoneDevice = temp->getPhoneDevice( ) ;
242 mPhoneConnection = temp->getPhoneConnection( ); 242 mPhoneConnection = temp->getPhoneConnection( );
243 mPhoneModel = temp->getPhoneModel( ); 243 mPhoneModel = temp->getPhoneModel( );
244 syncPhone(); 244 syncPhone();
245 } else if ( temp->getIsPiSync() ) { 245 } else if ( temp->getIsPiSync() ) {
246 if ( mTargetApp == KAPI ) { 246 if ( mTargetApp == KAPI ) {
247 mPassWordPiSync = temp->getRemotePwAB(); 247 mPassWordPiSync = temp->getRemotePwAB();
248 mActiveSyncPort = temp->getRemotePortAB(); 248 mActiveSyncPort = temp->getRemotePortAB();
249 mActiveSyncIP = temp->getRemoteIPAB(); 249 mActiveSyncIP = temp->getRemoteIPAB();
250 } else if ( mTargetApp == KOPI ) { 250 } else if ( mTargetApp == KOPI ) {
251 mPassWordPiSync = temp->getRemotePw(); 251 mPassWordPiSync = temp->getRemotePw();
252 mActiveSyncPort = temp->getRemotePort(); 252 mActiveSyncPort = temp->getRemotePort();
253 mActiveSyncIP = temp->getRemoteIP(); 253 mActiveSyncIP = temp->getRemoteIP();
254 } else { 254 } else {
255 mPassWordPiSync = temp->getRemotePwPWM(); 255 mPassWordPiSync = temp->getRemotePwPWM();
256 mActiveSyncPort = temp->getRemotePortPWM(); 256 mActiveSyncPort = temp->getRemotePortPWM();
257 mActiveSyncIP = temp->getRemoteIPPWM(); 257 mActiveSyncIP = temp->getRemoteIPPWM();
258 } 258 }
259 syncPi(); 259 syncPi();
260 while ( !mPisyncFinished ) { 260 while ( !mPisyncFinished ) {
261 //qDebug("waiting "); 261 //qDebug("waiting ");
262 qApp->processEvents(); 262 qApp->processEvents();
263 } 263 }
264 } else 264 } else
265 syncRemote( temp ); 265 syncRemote( temp );
266 266
267 } 267 }
268 } 268 }
269 delete temp; 269 delete temp;
270 setBlockSave(false); 270 setBlockSave(false);
271} 271}
272 272
273void KSyncManager::enableQuick( bool ask ) 273void KSyncManager::enableQuick( bool ask )
274{ 274{
275 bool autoStart; 275 bool autoStart;
276 bool changed = false;
276 if ( ask ) { 277 if ( ask ) {
277 QDialog dia ( 0, "input-dialog", true ); 278 QDialog dia ( 0, "input-dialog", true );
278 QLineEdit lab ( &dia ); 279 QLineEdit lab ( &dia );
279 QVBoxLayout lay( &dia ); 280 QVBoxLayout lay( &dia );
280 lab.setText( mPrefs->mPassiveSyncPort ); 281 lab.setText( mPrefs->mPassiveSyncPort );
281 lay.setMargin(7); 282 lay.setMargin(7);
282 lay.setSpacing(7); 283 lay.setSpacing(7);
283 int po = 9197+mTargetApp; 284 int po = 9197+mTargetApp;
284 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 285 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
285 lay.addWidget( &label); 286 lay.addWidget( &label);
286 lay.addWidget( &lab); 287 lay.addWidget( &lab);
287 288
288 QLineEdit lepw ( &dia ); 289 QLineEdit lepw ( &dia );
289 lepw.setText( mPrefs->mPassiveSyncPw ); 290 lepw.setText( mPrefs->mPassiveSyncPw );
290 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 291 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
291 lay.addWidget( &label2); 292 lay.addWidget( &label2);
292 lay.addWidget( &lepw); 293 lay.addWidget( &lepw);
293 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 294 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
294 lay.addWidget( &autostart); 295 lay.addWidget( &autostart);
295 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 296 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
296#ifdef DESKTOP_VERSION 297#ifdef DESKTOP_VERSION
297#ifdef _WIN32_ 298#ifdef _WIN32_
298 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 299 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
299#else 300#else
300 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 301 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
301#endif 302#endif
302 lay.addWidget( &syncdesktop); 303 lay.addWidget( &syncdesktop);
303#else 304#else
304 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 305 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
305 syncdesktop.hide(); 306 syncdesktop.hide();
306#endif 307#endif
307 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 308 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
308 309
309 dia.setFixedSize( 230,120 ); 310 dia.setFixedSize( 230,120 );
310 dia.setCaption( i18n("Enter port for Pi-Sync") ); 311 dia.setCaption( i18n("Enter port for Pi-Sync") );
311 QPushButton pb ( "OK", &dia); 312 QPushButton pb ( "OK", &dia);
312 lay.addWidget( &pb ); 313 lay.addWidget( &pb );
313 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 314 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
314 dia.show(); 315 dia.show();
315 if ( ! dia.exec() ) 316 if ( ! dia.exec() )
316 return; 317 return;
317 dia.hide(); 318 dia.hide();
318 qApp->processEvents(); 319 qApp->processEvents();
319 mPrefs->mPassiveSyncPw = lepw.text(); 320 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
320 mPrefs->mPassiveSyncPort = lab.text(); 321 changed = true;
322 mPrefs->mPassiveSyncPw = lepw.text();
323 }
324 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
325 mPrefs->mPassiveSyncPort = lab.text();
326 changed = true;
327 }
321 autoStart = autostart.isChecked(); 328 autoStart = autostart.isChecked();
322 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 329 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
330 changed = true;
331 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
332 }
323 } 333 }
324 else 334 else
325 autoStart = mPrefs->mPassiveSyncAutoStart; 335 autoStart = mPrefs->mPassiveSyncAutoStart;
336 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
337 changed = true;
326 bool ok; 338 bool ok;
327 mPrefs->mPassiveSyncAutoStart = false; 339 mPrefs->mPassiveSyncAutoStart = false;
328 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 340 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
329 if ( ! ok ) { 341 if ( ! ok ) {
330 KMessageBox::information( 0, i18n("No valid port")); 342 KMessageBox::information( 0, i18n("No valid port"));
331 return; 343 return;
332 } 344 }
333 //qDebug("port %d ", port); 345 //qDebug("port %d ", port);
334 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 346 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
335 mServerSocket->setFileName( defaultFileName() ); 347 mServerSocket->setFileName( defaultFileName() );
336 //qDebug("connected "); 348 //qDebug("connected ");
337 if ( !mServerSocket->ok() ) { 349 if ( !mServerSocket->ok() ) {
338 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 350 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
339 delete mServerSocket; 351 delete mServerSocket;
340 mServerSocket = 0; 352 mServerSocket = 0;
341 return; 353 return;
342 } 354 }
343
344 mPrefs->mPassiveSyncAutoStart = autoStart; 355 mPrefs->mPassiveSyncAutoStart = autoStart;
356 if ( changed ) {
357 mPrefs->writeConfig();
358 }
345 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 359 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
346 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 360 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
347} 361}
348 362
349void KSyncManager::syncLocalFile() 363void KSyncManager::syncLocalFile()
350{ 364{
351 365
352 QString fn =mPrefs->mLastSyncedLocalFile; 366 QString fn =mPrefs->mLastSyncedLocalFile;
353 QString ext; 367 QString ext;
354 368
355 switch(mTargetApp) 369 switch(mTargetApp)
356 { 370 {
357 case (KAPI): 371 case (KAPI):
358 ext = "(*.vcf)"; 372 ext = "(*.vcf)";
359 break; 373 break;
360 case (KOPI): 374 case (KOPI):
361 ext = "(*.ics/*.vcs)"; 375 ext = "(*.ics/*.vcs)";
362 break; 376 break;
363 case (PWMPI): 377 case (PWMPI):
364 ext = "(*.pwm)"; 378 ext = "(*.pwm)";
365 break; 379 break;
366 default: 380 default:
367 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 381 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
368 break; 382 break;
369 383
370 } 384 }
371 385
372 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 386 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
373 if ( fn == "" ) 387 if ( fn == "" )
374 return; 388 return;
375 if ( syncWithFile( fn, false ) ) { 389 if ( syncWithFile( fn, false ) ) {
376 qDebug("syncLocalFile() successful "); 390 qDebug("syncLocalFile() successful ");
377 } 391 }
378 392
379} 393}
380 394
381bool KSyncManager::syncWithFile( QString fn , bool quick ) 395bool KSyncManager::syncWithFile( QString fn , bool quick )
382{ 396{
383 bool ret = false; 397 bool ret = false;
384 QFileInfo info; 398 QFileInfo info;
385 info.setFile( fn ); 399 info.setFile( fn );
386 QString mess; 400 QString mess;
387 bool loadbup = true; 401 bool loadbup = true;
388 if ( !info. exists() ) { 402 if ( !info. exists() ) {
389 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 403 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
390 int result = QMessageBox::warning( mParent, i18n("Warning!"), 404 int result = QMessageBox::warning( mParent, i18n("Warning!"),
391 mess ); 405 mess );
392 return ret; 406 return ret;