author | zautrix <zautrix> | 2004-10-20 08:47:06 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-20 08:47:06 (UTC) |
commit | 40eaafc9e008dc004b6ebc65fae8d89c8883ee8b (patch) (unidiff) | |
tree | b2d60584f52ef66aa5347f2534d323a4609280c5 | |
parent | 268e69a533c5db110600758366644c9827957364 (diff) | |
download | kdepimpi-40eaafc9e008dc004b6ebc65fae8d89c8883ee8b.zip kdepimpi-40eaafc9e008dc004b6ebc65fae8d89c8883ee8b.tar.gz kdepimpi-40eaafc9e008dc004b6ebc65fae8d89c8883ee8b.tar.bz2 |
config save bugfix
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 22 |
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 | |||
@@ -148,325 +148,339 @@ void KSyncManager::fillSyncMenu() | |||
148 | } | 148 | } |
149 | 149 | ||
150 | void KSyncManager::slotSyncMenu( int action ) | 150 | void KSyncManager::slotSyncMenu( int action ) |
151 | { | 151 | { |
152 | qDebug("syncaction %d ", action); | 152 | qDebug("syncaction %d ", action); |
153 | if ( action == 0 ) { | 153 | if ( action == 0 ) { |
154 | 154 | ||
155 | // seems to be a Qt2 event handling bug | 155 | // seems to be a Qt2 event handling bug |
156 | // syncmenu.clear causes a segfault at first time | 156 | // syncmenu.clear causes a segfault at first time |
157 | // when we call it after the main event loop, it is ok | 157 | // when we call it after the main event loop, it is ok |
158 | // same behaviour when calling OM/Pi via QCOP for the first time | 158 | // same behaviour when calling OM/Pi via QCOP for the first time |
159 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 159 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
160 | //confSync(); | 160 | //confSync(); |
161 | 161 | ||
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | if ( action == 1 ) { | 164 | if ( action == 1 ) { |
165 | multiSync( true ); | 165 | multiSync( true ); |
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | if ( action == 2 ) { | 168 | if ( action == 2 ) { |
169 | enableQuick(); | 169 | enableQuick(); |
170 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 170 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
171 | return; | 171 | return; |
172 | } | 172 | } |
173 | if ( action == 3 ) { | 173 | if ( action == 3 ) { |
174 | delete mServerSocket; | 174 | delete mServerSocket; |
175 | mServerSocket = 0; | 175 | mServerSocket = 0; |
176 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 176 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
177 | return; | 177 | return; |
178 | } | 178 | } |
179 | 179 | ||
180 | if (blockSave()) | 180 | if (blockSave()) |
181 | return; | 181 | return; |
182 | 182 | ||
183 | setBlockSave(true); | 183 | setBlockSave(true); |
184 | 184 | ||
185 | mCurrentSyncProfile = action - 1000 ; | 185 | mCurrentSyncProfile = action - 1000 ; |
186 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 186 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
187 | mCurrentSyncName = mLocalMachineName ; | 187 | mCurrentSyncName = mLocalMachineName ; |
188 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 188 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
189 | KSyncProfile* temp = new KSyncProfile (); | 189 | KSyncProfile* temp = new KSyncProfile (); |
190 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 190 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
191 | temp->readConfig(&config); | 191 | temp->readConfig(&config); |
192 | mAskForPreferences = temp->getAskForPreferences(); | 192 | mAskForPreferences = temp->getAskForPreferences(); |
193 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 193 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
194 | mWriteBackFile = temp->getWriteBackFile(); | 194 | mWriteBackFile = temp->getWriteBackFile(); |
195 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 195 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
196 | mIsKapiFile = temp->getIsKapiFile(); | 196 | mIsKapiFile = temp->getIsKapiFile(); |
197 | mWriteBackInFuture = 0; | 197 | mWriteBackInFuture = 0; |
198 | if ( temp->getWriteBackFuture() ) | 198 | if ( temp->getWriteBackFuture() ) |
199 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 199 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
200 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 200 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
201 | if ( action == 1000 ) { | 201 | if ( action == 1000 ) { |
202 | #ifdef DESKTOP_VERSION | 202 | #ifdef DESKTOP_VERSION |
203 | syncKDE(); | 203 | syncKDE(); |
204 | #else | 204 | #else |
205 | syncSharp(); | 205 | syncSharp(); |
206 | #endif | 206 | #endif |
207 | 207 | ||
208 | } else if ( action == 1001 ) { | 208 | } else if ( action == 1001 ) { |
209 | syncLocalFile(); | 209 | syncLocalFile(); |
210 | 210 | ||
211 | } else if ( action == 1002 ) { | 211 | } else if ( action == 1002 ) { |
212 | mWriteBackFile = false; | 212 | mWriteBackFile = false; |
213 | mAskForPreferences = false; | 213 | mAskForPreferences = false; |
214 | mShowSyncSummary = false; | 214 | mShowSyncSummary = false; |
215 | mSyncAlgoPrefs = 3; | 215 | mSyncAlgoPrefs = 3; |
216 | quickSyncLocalFile(); | 216 | quickSyncLocalFile(); |
217 | 217 | ||
218 | } else if ( action >= 1003 ) { | 218 | } else if ( action >= 1003 ) { |
219 | if ( temp->getIsLocalFileSync() ) { | 219 | if ( temp->getIsLocalFileSync() ) { |
220 | switch(mTargetApp) | 220 | switch(mTargetApp) |
221 | { | 221 | { |
222 | case (KAPI): | 222 | case (KAPI): |
223 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 223 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
224 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 224 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
225 | break; | 225 | break; |
226 | case (KOPI): | 226 | case (KOPI): |
227 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 227 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
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 | ||
273 | void KSyncManager::enableQuick( bool ask ) | 273 | void 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 | ||
349 | void KSyncManager::syncLocalFile() | 363 | void 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 | ||
381 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 395 | bool 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; |
393 | } | 407 | } |
394 | int result = 0; | 408 | int result = 0; |
395 | if ( !quick ) { | 409 | if ( !quick ) { |
396 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 410 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
397 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 411 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
398 | mess, | 412 | mess, |
399 | i18n("Sync"), i18n("Cancel"), 0, | 413 | i18n("Sync"), i18n("Cancel"), 0, |
400 | 0, 1 ); | 414 | 0, 1 ); |
401 | if ( result ) | 415 | if ( result ) |
402 | return false; | 416 | return false; |
403 | } | 417 | } |
404 | if ( mAskForPreferences ) | 418 | if ( mAskForPreferences ) |
405 | edit_sync_options(); | 419 | edit_sync_options(); |
406 | if ( result == 0 ) { | 420 | if ( result == 0 ) { |
407 | //qDebug("Now sycing ... "); | 421 | //qDebug("Now sycing ... "); |
408 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 422 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
409 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 423 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
410 | else | 424 | else |
411 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 425 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
412 | if ( ! quick ) | 426 | if ( ! quick ) |
413 | mPrefs->mLastSyncedLocalFile = fn; | 427 | mPrefs->mLastSyncedLocalFile = fn; |
414 | } | 428 | } |
415 | return ret; | 429 | return ret; |
416 | } | 430 | } |
417 | 431 | ||
418 | void KSyncManager::quickSyncLocalFile() | 432 | void KSyncManager::quickSyncLocalFile() |
419 | { | 433 | { |
420 | 434 | ||
421 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 435 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
422 | qDebug("quick syncLocalFile() successful "); | 436 | qDebug("quick syncLocalFile() successful "); |
423 | 437 | ||
424 | } | 438 | } |
425 | } | 439 | } |
426 | 440 | ||
427 | void KSyncManager::multiSync( bool askforPrefs ) | 441 | void KSyncManager::multiSync( bool askforPrefs ) |
428 | { | 442 | { |
429 | if (blockSave()) | 443 | if (blockSave()) |
430 | return; | 444 | return; |
431 | setBlockSave(true); | 445 | setBlockSave(true); |
432 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 446 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
433 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 447 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
434 | question, | 448 | question, |
435 | i18n("Yes"), i18n("No"), | 449 | i18n("Yes"), i18n("No"), |
436 | 0, 0 ) != 0 ) { | 450 | 0, 0 ) != 0 ) { |
437 | setBlockSave(false); | 451 | setBlockSave(false); |
438 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 452 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
439 | return; | 453 | return; |
440 | } | 454 | } |
441 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 455 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
442 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 456 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
443 | if ( askforPrefs ) { | 457 | if ( askforPrefs ) { |
444 | edit_sync_options(); | 458 | edit_sync_options(); |
445 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 459 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
446 | } | 460 | } |
447 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 461 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
448 | qApp->processEvents(); | 462 | qApp->processEvents(); |
449 | int num = ringSync() ; | 463 | int num = ringSync() ; |
450 | if ( num > 1 ) | 464 | if ( num > 1 ) |
451 | ringSync(); | 465 | ringSync(); |
452 | setBlockSave(false); | 466 | setBlockSave(false); |
453 | if ( num ) | 467 | if ( num ) |
454 | emit save(); | 468 | emit save(); |
455 | if ( num ) | 469 | if ( num ) |
456 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 470 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
457 | else | 471 | else |
458 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 472 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
459 | return; | 473 | return; |
460 | } | 474 | } |
461 | 475 | ||
462 | int KSyncManager::ringSync() | 476 | int KSyncManager::ringSync() |
463 | { | 477 | { |
464 | int syncedProfiles = 0; | 478 | int syncedProfiles = 0; |
465 | unsigned int i; | 479 | unsigned int i; |
466 | QTime timer; | 480 | QTime timer; |
467 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 481 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
468 | QStringList syncProfileNames = mSyncProfileNames; | 482 | QStringList syncProfileNames = mSyncProfileNames; |
469 | KSyncProfile* temp = new KSyncProfile (); | 483 | KSyncProfile* temp = new KSyncProfile (); |
470 | mAskForPreferences = false; | 484 | mAskForPreferences = false; |
471 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 485 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
472 | mCurrentSyncProfile = i; | 486 | mCurrentSyncProfile = i; |