-rw-r--r-- | libkdepim/ksyncmanager.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 1f5f4c7..9177f63 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -180,390 +180,395 @@ void KSyncManager::slotClearMenu( int action ) | |||
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 | } |
185 | void KSyncManager::slotSyncMenu( int action ) | 185 | void KSyncManager::slotSyncMenu( int action ) |
186 | { | 186 | { |
187 | qDebug("KSM::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); |
236 | if (silent) { | 236 | if (silent) { |
237 | mAskForPreferences = false; | 237 | mAskForPreferences = false; |
238 | mShowSyncSummary = false; | 238 | mShowSyncSummary = false; |
239 | mWriteBackFile = true; | 239 | mWriteBackFile = true; |
240 | mSyncAlgoPrefs = 2;// take newest | 240 | mSyncAlgoPrefs = 2;// take newest |
241 | } | 241 | } |
242 | else { | 242 | else { |
243 | mAskForPreferences = temp->getAskForPreferences(); | 243 | mAskForPreferences = temp->getAskForPreferences(); |
244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
245 | mWriteBackFile = temp->getWriteBackFile(); | 245 | mWriteBackFile = temp->getWriteBackFile(); |
246 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 246 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
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("KSM::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 | ||
333 | void KSyncManager::enableQuick( bool ask ) | 333 | void 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); |
344 | int po = 9197+mTargetApp; | 344 | int po = 9197+mTargetApp; |
345 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 345 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
346 | lay.addWidget( &label); | 346 | lay.addWidget( &label); |
347 | lay.addWidget( &lab); | 347 | lay.addWidget( &lab); |
348 | 348 | ||
349 | QLineEdit lepw ( &dia ); | 349 | QLineEdit lepw ( &dia ); |
350 | lepw.setText( mPrefs->mPassiveSyncPw ); | 350 | lepw.setText( mPrefs->mPassiveSyncPw ); |
351 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 351 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
352 | lay.addWidget( &label2); | 352 | lay.addWidget( &label2); |
353 | lay.addWidget( &lepw); | 353 | lay.addWidget( &lepw); |
354 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 354 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
355 | lay.addWidget( &autostart); | 355 | lay.addWidget( &autostart); |
356 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 356 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
357 | #ifdef DESKTOP_VERSION | 357 | #ifdef DESKTOP_VERSION |
358 | #ifdef _WIN32_ | 358 | #ifdef _WIN32_ |
359 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 359 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
360 | syncdesktop.hide();// not implemented! | 360 | syncdesktop.hide();// not implemented! |
361 | #else | 361 | #else |
362 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 362 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
363 | #endif | 363 | #endif |
364 | lay.addWidget( &syncdesktop); | 364 | lay.addWidget( &syncdesktop); |
365 | #else | 365 | #else |
366 | mPrefs->mPassiveSyncWithDesktop = false; | 366 | mPrefs->mPassiveSyncWithDesktop = false; |
367 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 367 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
368 | syncdesktop.hide(); | 368 | syncdesktop.hide(); |
369 | #endif | 369 | #endif |
370 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 370 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
371 | 371 | ||
372 | dia.setFixedSize( 230,120 ); | ||
373 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | ||
374 | QPushButton pb ( "OK", &dia); | 372 | QPushButton pb ( "OK", &dia); |
375 | lay.addWidget( &pb ); | 373 | lay.addWidget( &pb ); |
376 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 374 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
375 | dia.resize( 230,120 ); | ||
376 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | ||
377 | dia.show(); | 377 | dia.show(); |
378 | #ifndef DESKTOP_VERSION | ||
379 | int dw = QApplication::desktop()->width(); | ||
380 | int dh = QApplication::desktop()->height(); | ||
381 | dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); | ||
382 | #endif | ||
378 | if ( ! dia.exec() ) | 383 | if ( ! dia.exec() ) |
379 | return; | 384 | return; |
380 | dia.hide(); | 385 | dia.hide(); |
381 | qApp->processEvents(); | 386 | qApp->processEvents(); |
382 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 387 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
383 | changed = true; | 388 | changed = true; |
384 | mPrefs->mPassiveSyncPw = lepw.text(); | 389 | mPrefs->mPassiveSyncPw = lepw.text(); |
385 | } | 390 | } |
386 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 391 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
387 | mPrefs->mPassiveSyncPort = lab.text(); | 392 | mPrefs->mPassiveSyncPort = lab.text(); |
388 | changed = true; | 393 | changed = true; |
389 | } | 394 | } |
390 | autoStart = autostart.isChecked(); | 395 | autoStart = autostart.isChecked(); |
391 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 396 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
392 | changed = true; | 397 | changed = true; |
393 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 398 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
394 | } | 399 | } |
395 | } | 400 | } |
396 | else | 401 | else |
397 | autoStart = mPrefs->mPassiveSyncAutoStart; | 402 | autoStart = mPrefs->mPassiveSyncAutoStart; |
398 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 403 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
399 | changed = true; | 404 | changed = true; |
400 | bool ok; | 405 | bool ok; |
401 | mPrefs->mPassiveSyncAutoStart = false; | 406 | mPrefs->mPassiveSyncAutoStart = false; |
402 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 407 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
403 | if ( ! ok ) { | 408 | if ( ! ok ) { |
404 | KMessageBox::information( 0, i18n("No valid port")); | 409 | KMessageBox::information( 0, i18n("No valid port")); |
405 | return; | 410 | return; |
406 | } | 411 | } |
407 | //qDebug("port %d ", port); | 412 | //qDebug("port %d ", port); |
408 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 413 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
409 | mServerSocket->setFileName( defaultFileName() );//bbb | 414 | mServerSocket->setFileName( defaultFileName() );//bbb |
410 | //qDebug("connected "); | 415 | //qDebug("connected "); |
411 | if ( !mServerSocket->ok() ) { | 416 | if ( !mServerSocket->ok() ) { |
412 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 417 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
413 | delete mServerSocket; | 418 | delete mServerSocket; |
414 | mServerSocket = 0; | 419 | mServerSocket = 0; |
415 | return; | 420 | return; |
416 | } | 421 | } |
417 | mPrefs->mPassiveSyncAutoStart = autoStart; | 422 | mPrefs->mPassiveSyncAutoStart = autoStart; |
418 | if ( changed ) { | 423 | if ( changed ) { |
419 | mPrefs->writeConfig(); | 424 | mPrefs->writeConfig(); |
420 | } | 425 | } |
421 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 426 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
422 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 427 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
423 | } | 428 | } |
424 | 429 | ||
425 | void KSyncManager::syncLocalFile() | 430 | void KSyncManager::syncLocalFile() |
426 | { | 431 | { |
427 | 432 | ||
428 | QString fn =mPrefs->mLastSyncedLocalFile; | 433 | QString fn =mPrefs->mLastSyncedLocalFile; |
429 | QString ext; | 434 | QString ext; |
430 | 435 | ||
431 | switch(mTargetApp) | 436 | switch(mTargetApp) |
432 | { | 437 | { |
433 | case (KAPI): | 438 | case (KAPI): |
434 | ext = "(*.vcf)"; | 439 | ext = "(*.vcf)"; |
435 | break; | 440 | break; |
436 | case (KOPI): | 441 | case (KOPI): |
437 | ext = "(*.ics/*.vcs)"; | 442 | ext = "(*.ics/*.vcs)"; |
438 | break; | 443 | break; |
439 | case (PWMPI): | 444 | case (PWMPI): |
440 | ext = "(*.pwm)"; | 445 | ext = "(*.pwm)"; |
441 | break; | 446 | break; |
442 | default: | 447 | default: |
443 | qDebug("KSM::syncLocalFile: invalid apptype selected"); | 448 | qDebug("KSM::syncLocalFile: invalid apptype selected"); |
444 | break; | 449 | break; |
445 | 450 | ||
446 | } | 451 | } |
447 | 452 | ||
448 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 453 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
449 | if ( fn == "" ) | 454 | if ( fn == "" ) |
450 | return; | 455 | return; |
451 | if ( syncWithFile( fn, false ) ) { | 456 | if ( syncWithFile( fn, false ) ) { |
452 | qDebug("KSM::syncLocalFile() successful "); | 457 | qDebug("KSM::syncLocalFile() successful "); |
453 | } | 458 | } |
454 | 459 | ||
455 | } | 460 | } |
456 | 461 | ||
457 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 462 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
458 | { | 463 | { |
459 | bool ret = false; | 464 | bool ret = false; |
460 | QFileInfo info; | 465 | QFileInfo info; |
461 | info.setFile( fn ); | 466 | info.setFile( fn ); |
462 | QString mess; | 467 | QString mess; |
463 | if ( !info. exists() ) { | 468 | if ( !info. exists() ) { |
464 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 469 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
465 | QMessageBox::warning( mParent, i18n("Warning!"), | 470 | QMessageBox::warning( mParent, i18n("Warning!"), |
466 | mess ); | 471 | mess ); |
467 | return ret; | 472 | return ret; |
468 | } | 473 | } |
469 | int result = 0; | 474 | int result = 0; |
470 | if ( !quick ) { | 475 | if ( !quick ) { |
471 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 476 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
472 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 477 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
473 | mess, | 478 | mess, |
474 | i18n("Sync"), i18n("Cancel"), 0, | 479 | i18n("Sync"), i18n("Cancel"), 0, |
475 | 0, 1 ); | 480 | 0, 1 ); |
476 | if ( result ) | 481 | if ( result ) |
477 | return false; | 482 | return false; |
478 | } | 483 | } |
479 | if ( mAskForPreferences ) | 484 | if ( mAskForPreferences ) |
480 | if ( !edit_sync_options()) { | 485 | if ( !edit_sync_options()) { |
481 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 486 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
482 | return false; | 487 | return false; |
483 | } | 488 | } |
484 | if ( result == 0 ) { | 489 | if ( result == 0 ) { |
485 | //qDebug("Now sycing ... "); | 490 | //qDebug("Now sycing ... "); |
486 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 491 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
487 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 492 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
488 | else | 493 | else |
489 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 494 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
490 | if ( ! quick ) | 495 | if ( ! quick ) |
491 | mPrefs->mLastSyncedLocalFile = fn; | 496 | mPrefs->mLastSyncedLocalFile = fn; |
492 | } | 497 | } |
493 | return ret; | 498 | return ret; |
494 | } | 499 | } |
495 | 500 | ||
496 | void KSyncManager::quickSyncLocalFile() | 501 | void KSyncManager::quickSyncLocalFile() |
497 | { | 502 | { |
498 | 503 | ||
499 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 504 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
500 | qDebug("KSM::quick syncLocalFile() successful "); | 505 | qDebug("KSM::quick syncLocalFile() successful "); |
501 | 506 | ||
502 | } | 507 | } |
503 | } | 508 | } |
504 | 509 | ||
505 | void KSyncManager::multiSync( bool askforPrefs ) | 510 | void KSyncManager::multiSync( bool askforPrefs ) |
506 | { | 511 | { |
507 | if (blockSave()) | 512 | if (blockSave()) |
508 | return; | 513 | return; |
509 | setBlockSave(true); | 514 | setBlockSave(true); |
510 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 515 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
511 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 516 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
512 | question, | 517 | question, |
513 | i18n("Yes"), i18n("No"), | 518 | i18n("Yes"), i18n("No"), |
514 | 0, 0 ) != 0 ) { | 519 | 0, 0 ) != 0 ) { |
515 | setBlockSave(false); | 520 | setBlockSave(false); |
516 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 521 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
517 | return; | 522 | return; |
518 | } | 523 | } |
519 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 524 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
520 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 525 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
521 | if ( askforPrefs ) { | 526 | if ( askforPrefs ) { |
522 | if ( !edit_sync_options()) { | 527 | if ( !edit_sync_options()) { |
523 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 528 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
524 | return; | 529 | return; |
525 | } | 530 | } |
526 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 531 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
527 | } | 532 | } |
528 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 533 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
529 | qApp->processEvents(); | 534 | qApp->processEvents(); |
530 | int num = ringSync() ; | 535 | int num = ringSync() ; |
531 | if ( num > 1 ) | 536 | if ( num > 1 ) |
532 | ringSync(); | 537 | ringSync(); |
533 | setBlockSave(false); | 538 | setBlockSave(false); |
534 | if ( num ) | 539 | if ( num ) |
535 | emit save(); | 540 | emit save(); |
536 | if ( num ) | 541 | if ( num ) |
537 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 542 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
538 | else | 543 | else |
539 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 544 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
540 | return; | 545 | return; |
541 | } | 546 | } |
542 | 547 | ||
543 | int KSyncManager::ringSync() | 548 | int KSyncManager::ringSync() |
544 | { | 549 | { |
545 | 550 | ||
546 | int syncedProfiles = 0; | 551 | int syncedProfiles = 0; |
547 | unsigned int i; | 552 | unsigned int i; |
548 | QTime timer; | 553 | QTime timer; |
549 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 554 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
550 | QStringList syncProfileNames = mSyncProfileNames; | 555 | QStringList syncProfileNames = mSyncProfileNames; |
551 | KSyncProfile* temp = new KSyncProfile (); | 556 | KSyncProfile* temp = new KSyncProfile (); |
552 | mAskForPreferences = false; | 557 | mAskForPreferences = false; |
553 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 558 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
554 | mCurrentSyncProfile = i; | 559 | mCurrentSyncProfile = i; |
555 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 560 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
556 | temp->readConfig(&config); | 561 | temp->readConfig(&config); |
557 | 562 | ||
558 | bool includeInRingSync = false; | 563 | bool includeInRingSync = false; |
559 | switch(mTargetApp) | 564 | switch(mTargetApp) |
560 | { | 565 | { |
561 | case (KAPI): | 566 | case (KAPI): |
562 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 567 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
563 | break; | 568 | break; |
564 | case (KOPI): | 569 | case (KOPI): |
565 | includeInRingSync = temp->getIncludeInRingSync(); | 570 | includeInRingSync = temp->getIncludeInRingSync(); |
566 | break; | 571 | break; |
567 | case (PWMPI): | 572 | case (PWMPI): |
568 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 573 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
569 | break; | 574 | break; |