summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
authorzautrix <zautrix>2004-10-09 02:17:06 (UTC)
committer zautrix <zautrix>2004-10-09 02:17:06 (UTC)
commitc2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d (patch) (unidiff)
treeb83f7cfe5d4bb681b756fe95446e5e3fc193bc36 /libkdepim/ksyncmanager.cpp
parent07fdef2c2ea1153d39d7114b3d5bd4abc4f4c861 (diff)
downloadkdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.zip
kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.gz
kdepimpi-c2165f4e14bc2f7ab2ef19f5c35497dde5e87a0d.tar.bz2
import ir fixes
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 08b1a3d..80fb147 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -98,368 +98,372 @@ void KSyncManager::fillSyncMenu()
98 QStringList prof = config.readListEntry("SyncProfileNames"); 98 QStringList prof = config.readListEntry("SyncProfileNames");
99 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 99 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
100 if ( prof.count() < 2 ) { 100 if ( prof.count() < 2 ) {
101 prof.clear(); 101 prof.clear();
102 prof << i18n("Sharp_DTM"); 102 prof << i18n("Sharp_DTM");
103 prof << i18n("Local_file"); 103 prof << i18n("Local_file");
104 prof << i18n("Last_file"); 104 prof << i18n("Last_file");
105 KSyncProfile* temp = new KSyncProfile (); 105 KSyncProfile* temp = new KSyncProfile ();
106 temp->setName( prof[0] ); 106 temp->setName( prof[0] );
107 temp->writeConfig(&config); 107 temp->writeConfig(&config);
108 temp->setName( prof[1] ); 108 temp->setName( prof[1] );
109 temp->writeConfig(&config); 109 temp->writeConfig(&config);
110 temp->setName( prof[2] ); 110 temp->setName( prof[2] );
111 temp->writeConfig(&config); 111 temp->writeConfig(&config);
112 config.setGroup("General"); 112 config.setGroup("General");
113 config.writeEntry("SyncProfileNames",prof); 113 config.writeEntry("SyncProfileNames",prof);
114 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 114 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
115 config.sync(); 115 config.sync();
116 delete temp; 116 delete temp;
117 } 117 }
118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 118 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
119 mSyncProfileNames = prof; 119 mSyncProfileNames = prof;
120 unsigned int i; 120 unsigned int i;
121 for ( i = 0; i < prof.count(); ++i ) { 121 for ( i = 0; i < prof.count(); ++i ) {
122 mSyncMenu->insertItem( prof[i], 1000+i ); 122 mSyncMenu->insertItem( prof[i], 1000+i );
123 if ( i == 2 ) 123 if ( i == 2 )
124 mSyncMenu->insertSeparator(); 124 mSyncMenu->insertSeparator();
125 } 125 }
126 QDir app_dir; 126 QDir app_dir;
127 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 127 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
128 if ( mTargetApp == PWMPI) { 128 if ( mTargetApp == PWMPI) {
129 mSyncMenu->removeItem( 1000 ); 129 mSyncMenu->removeItem( 1000 );
130 } 130 }
131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
132 mSyncMenu->removeItem( 1000 ); 132 mSyncMenu->removeItem( 1000 );
133 } 133 }
134 mSyncMenu->removeItem( 1002 ); 134 mSyncMenu->removeItem( 1002 );
135} 135}
136 136
137void KSyncManager::slotSyncMenu( int action ) 137void KSyncManager::slotSyncMenu( int action )
138{ 138{
139 //qDebug("syncaction %d ", action); 139 //qDebug("syncaction %d ", action);
140 if ( action == 0 ) { 140 if ( action == 0 ) {
141 141
142 // seems to be a Qt2 event handling bug 142 // seems to be a Qt2 event handling bug
143 // syncmenu.clear causes a segfault at first time 143 // syncmenu.clear causes a segfault at first time
144 // when we call it after the main event loop, it is ok 144 // when we call it after the main event loop, it is ok
145 // same behaviour when calling OM/Pi via QCOP for the first time 145 // same behaviour when calling OM/Pi via QCOP for the first time
146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 146 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
147 //confSync(); 147 //confSync();
148 148
149 return; 149 return;
150 } 150 }
151 if ( action == 1 ) { 151 if ( action == 1 ) {
152 multiSync( true ); 152 multiSync( true );
153 return; 153 return;
154 } 154 }
155 if ( action == 2 ) { 155 if ( action == 2 ) {
156 enableQuick(); 156 enableQuick();
157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 157 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
158 return; 158 return;
159 } 159 }
160 if ( action == 3 ) { 160 if ( action == 3 ) {
161 delete mServerSocket; 161 delete mServerSocket;
162 mServerSocket = 0; 162 mServerSocket = 0;
163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 163 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
164 return; 164 return;
165 } 165 }
166 166
167 if (blockSave()) 167 if (blockSave())
168 return; 168 return;
169 169
170 setBlockSave(true); 170 setBlockSave(true);
171 171
172 mCurrentSyncProfile = action - 1000 ; 172 mCurrentSyncProfile = action - 1000 ;
173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 173 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
174 mCurrentSyncName = mLocalMachineName ; 174 mCurrentSyncName = mLocalMachineName ;
175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
176 KSyncProfile* temp = new KSyncProfile (); 176 KSyncProfile* temp = new KSyncProfile ();
177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 177 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
178 temp->readConfig(&config); 178 temp->readConfig(&config);
179 mAskForPreferences = temp->getAskForPreferences(); 179 mAskForPreferences = temp->getAskForPreferences();
180 mSyncAlgoPrefs = temp->getSyncPrefs(); 180 mSyncAlgoPrefs = temp->getSyncPrefs();
181 mWriteBackFile = temp->getWriteBackFile(); 181 mWriteBackFile = temp->getWriteBackFile();
182 mWriteBackExistingOnly = temp->getWriteBackExisting(); 182 mWriteBackExistingOnly = temp->getWriteBackExisting();
183 mWriteBackInFuture = 0; 183 mWriteBackInFuture = 0;
184 if ( temp->getWriteBackFuture() ) 184 if ( temp->getWriteBackFuture() )
185 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 185 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
186 mShowSyncSummary = temp->getShowSummaryAfterSync(); 186 mShowSyncSummary = temp->getShowSummaryAfterSync();
187 if ( action == 1000 ) { 187 if ( action == 1000 ) {
188 syncSharp(); 188 syncSharp();
189 189
190 } else if ( action == 1001 ) { 190 } else if ( action == 1001 ) {
191 syncLocalFile(); 191 syncLocalFile();
192 192
193 } else if ( action == 1002 ) { 193 } else if ( action == 1002 ) {
194 mWriteBackFile = false;
195 mAskForPreferences = false;
196 mShowSyncSummary = false;
197 mSyncAlgoPrefs = 3;
194 quickSyncLocalFile(); 198 quickSyncLocalFile();
195 199
196 } else if ( action >= 1003 ) { 200 } else if ( action >= 1003 ) {
197 if ( temp->getIsLocalFileSync() ) { 201 if ( temp->getIsLocalFileSync() ) {
198 switch(mTargetApp) 202 switch(mTargetApp)
199 { 203 {
200 case (KAPI): 204 case (KAPI):
201 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
202 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
203 break; 207 break;
204 case (KOPI): 208 case (KOPI):
205 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 209 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
207 break; 211 break;
208 case (PWMPI): 212 case (PWMPI):
209 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 213 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 214 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
211 break; 215 break;
212 default: 216 default:
213 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 217 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
214 break; 218 break;
215 219
216 } 220 }
217 } else { 221 } else {
218 if ( temp->getIsPhoneSync() ) { 222 if ( temp->getIsPhoneSync() ) {
219 mPhoneDevice = temp->getPhoneDevice( ) ; 223 mPhoneDevice = temp->getPhoneDevice( ) ;
220 mPhoneConnection = temp->getPhoneConnection( ); 224 mPhoneConnection = temp->getPhoneConnection( );
221 mPhoneModel = temp->getPhoneModel( ); 225 mPhoneModel = temp->getPhoneModel( );
222 syncPhone(); 226 syncPhone();
223 } else if ( temp->getIsPiSync() ) { 227 } else if ( temp->getIsPiSync() ) {
224 if ( mTargetApp == KAPI ) { 228 if ( mTargetApp == KAPI ) {
225 mPassWordPiSync = temp->getRemotePwAB(); 229 mPassWordPiSync = temp->getRemotePwAB();
226 mActiveSyncPort = temp->getRemotePortAB(); 230 mActiveSyncPort = temp->getRemotePortAB();
227 mActiveSyncIP = temp->getRemoteIPAB(); 231 mActiveSyncIP = temp->getRemoteIPAB();
228 } else if ( mTargetApp == KOPI ) { 232 } else if ( mTargetApp == KOPI ) {
229 mPassWordPiSync = temp->getRemotePw(); 233 mPassWordPiSync = temp->getRemotePw();
230 mActiveSyncPort = temp->getRemotePort(); 234 mActiveSyncPort = temp->getRemotePort();
231 mActiveSyncIP = temp->getRemoteIP(); 235 mActiveSyncIP = temp->getRemoteIP();
232 } else { 236 } else {
233 mPassWordPiSync = temp->getRemotePwPWM(); 237 mPassWordPiSync = temp->getRemotePwPWM();
234 mActiveSyncPort = temp->getRemotePortPWM(); 238 mActiveSyncPort = temp->getRemotePortPWM();
235 mActiveSyncIP = temp->getRemoteIPPWM(); 239 mActiveSyncIP = temp->getRemoteIPPWM();
236 } 240 }
237 syncPi(); 241 syncPi();
238 } else 242 } else
239 syncRemote( temp ); 243 syncRemote( temp );
240 244
241 } 245 }
242 } 246 }
243 delete temp; 247 delete temp;
244 setBlockSave(false); 248 setBlockSave(false);
245} 249}
246 250
247void KSyncManager::enableQuick() 251void KSyncManager::enableQuick()
248{ 252{
249 QDialog dia ( 0, "input-dialog", true ); 253 QDialog dia ( 0, "input-dialog", true );
250 QLineEdit lab ( &dia ); 254 QLineEdit lab ( &dia );
251 QVBoxLayout lay( &dia ); 255 QVBoxLayout lay( &dia );
252 lab.setText( mPrefs->mPassiveSyncPort ); 256 lab.setText( mPrefs->mPassiveSyncPort );
253 lay.setMargin(7); 257 lay.setMargin(7);
254 lay.setSpacing(7); 258 lay.setSpacing(7);
255 int po = 9197+mTargetApp; 259 int po = 9197+mTargetApp;
256 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 260 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
257 lay.addWidget( &label); 261 lay.addWidget( &label);
258 lay.addWidget( &lab); 262 lay.addWidget( &lab);
259 263
260 QLineEdit lepw ( &dia ); 264 QLineEdit lepw ( &dia );
261 lepw.setText( mPrefs->mPassiveSyncPw ); 265 lepw.setText( mPrefs->mPassiveSyncPw );
262 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 266 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
263 lay.addWidget( &label2); 267 lay.addWidget( &label2);
264 lay.addWidget( &lepw); 268 lay.addWidget( &lepw);
265 dia.setFixedSize( 230,80 ); 269 dia.setFixedSize( 230,80 );
266 dia.setCaption( i18n("Enter port for Pi-Sync") ); 270 dia.setCaption( i18n("Enter port for Pi-Sync") );
267 QPushButton pb ( "OK", &dia); 271 QPushButton pb ( "OK", &dia);
268 lay.addWidget( &pb ); 272 lay.addWidget( &pb );
269 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 273 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
270 dia.show(); 274 dia.show();
271 if ( ! dia.exec() ) 275 if ( ! dia.exec() )
272 return; 276 return;
273 dia.hide(); 277 dia.hide();
274 qApp->processEvents(); 278 qApp->processEvents();
275 mPrefs->mPassiveSyncPw = lepw.text(); 279 mPrefs->mPassiveSyncPw = lepw.text();
276 mPrefs->mPassiveSyncPort = lab.text(); 280 mPrefs->mPassiveSyncPort = lab.text();
277 bool ok; 281 bool ok;
278 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 282 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
279 if ( ! ok ) { 283 if ( ! ok ) {
280 KMessageBox::information( 0, i18n("No valid port")); 284 KMessageBox::information( 0, i18n("No valid port"));
281 return; 285 return;
282 } 286 }
283 //qDebug("port %d ", port); 287 //qDebug("port %d ", port);
284 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 288 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
285 mServerSocket->setFileName( defaultFileName() ); 289 mServerSocket->setFileName( defaultFileName() );
286 //qDebug("connected "); 290 //qDebug("connected ");
287 if ( !mServerSocket->ok() ) { 291 if ( !mServerSocket->ok() ) {
288 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 292 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
289 delete mServerSocket; 293 delete mServerSocket;
290 mServerSocket = 0; 294 mServerSocket = 0;
291 return; 295 return;
292 } 296 }
293 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 297 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
294 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 298 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
295} 299}
296 300
297void KSyncManager::syncLocalFile() 301void KSyncManager::syncLocalFile()
298{ 302{
299 303
300 QString fn =mPrefs->mLastSyncedLocalFile; 304 QString fn =mPrefs->mLastSyncedLocalFile;
301 QString ext; 305 QString ext;
302 306
303 switch(mTargetApp) 307 switch(mTargetApp)
304 { 308 {
305 case (KAPI): 309 case (KAPI):
306 ext = "(*.vcf)"; 310 ext = "(*.vcf)";
307 break; 311 break;
308 case (KOPI): 312 case (KOPI):
309 ext = "(*.ics/*.vcs)"; 313 ext = "(*.ics/*.vcs)";
310 break; 314 break;
311 case (PWMPI): 315 case (PWMPI):
312 ext = "(*.pwm)"; 316 ext = "(*.pwm)";
313 break; 317 break;
314 default: 318 default:
315 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 319 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
316 break; 320 break;
317 321
318 } 322 }
319 323
320 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 324 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
321 if ( fn == "" ) 325 if ( fn == "" )
322 return; 326 return;
323 if ( syncWithFile( fn, false ) ) { 327 if ( syncWithFile( fn, false ) ) {
324 qDebug("syncLocalFile() successful "); 328 qDebug("syncLocalFile() successful ");
325 } 329 }
326 330
327} 331}
328 332
329bool KSyncManager::syncWithFile( QString fn , bool quick ) 333bool KSyncManager::syncWithFile( QString fn , bool quick )
330{ 334{
331 bool ret = false; 335 bool ret = false;
332 QFileInfo info; 336 QFileInfo info;
333 info.setFile( fn ); 337 info.setFile( fn );
334 QString mess; 338 QString mess;
335 bool loadbup = true; 339 bool loadbup = true;
336 if ( !info. exists() ) { 340 if ( !info. exists() ) {
337 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 341 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
338 int result = QMessageBox::warning( mParent, i18n("Warning!"), 342 int result = QMessageBox::warning( mParent, i18n("Warning!"),
339 mess ); 343 mess );
340 return ret; 344 return ret;
341 } 345 }
342 int result = 0; 346 int result = 0;
343 if ( !quick ) { 347 if ( !quick ) {
344 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 348 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
345 result = QMessageBox::warning( mParent, i18n("Warning!"), 349 result = QMessageBox::warning( mParent, i18n("Warning!"),
346 mess, 350 mess,
347 i18n("Sync"), i18n("Cancel"), 0, 351 i18n("Sync"), i18n("Cancel"), 0,
348 0, 1 ); 352 0, 1 );
349 if ( result ) 353 if ( result )
350 return false; 354 return false;
351 } 355 }
352 if ( mAskForPreferences ) 356 if ( mAskForPreferences )
353 edit_sync_options(); 357 edit_sync_options();
354 if ( result == 0 ) { 358 if ( result == 0 ) {
355 //qDebug("Now sycing ... "); 359 //qDebug("Now sycing ... ");
356 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 360 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
357 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 361 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
358 else 362 else
359 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 363 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
360 if ( ! quick ) 364 if ( ! quick )
361 mPrefs->mLastSyncedLocalFile = fn; 365 mPrefs->mLastSyncedLocalFile = fn;
362 } 366 }
363 return ret; 367 return ret;
364} 368}
365 369
366void KSyncManager::quickSyncLocalFile() 370void KSyncManager::quickSyncLocalFile()
367{ 371{
368 372
369 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { 373 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
370 qDebug("quick syncLocalFile() successful "); 374 qDebug("quick syncLocalFile() successful ");
371 375
372 } 376 }
373} 377}
374 378
375void KSyncManager::multiSync( bool askforPrefs ) 379void KSyncManager::multiSync( bool askforPrefs )
376{ 380{
377 if (blockSave()) 381 if (blockSave())
378 return; 382 return;
379 setBlockSave(true); 383 setBlockSave(true);
380 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 384 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
381 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 385 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
382 question, 386 question,
383 i18n("Yes"), i18n("No"), 387 i18n("Yes"), i18n("No"),
384 0, 0 ) != 0 ) { 388 0, 0 ) != 0 ) {
385 setBlockSave(false); 389 setBlockSave(false);
386 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 390 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
387 return; 391 return;
388 } 392 }
389 mCurrentSyncDevice = i18n("Multiple profiles") ; 393 mCurrentSyncDevice = i18n("Multiple profiles") ;
390 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 394 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
391 if ( askforPrefs ) { 395 if ( askforPrefs ) {
392 edit_sync_options(); 396 edit_sync_options();
393 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 397 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
394 } 398 }
395 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 399 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
396 qApp->processEvents(); 400 qApp->processEvents();
397 int num = ringSync() ; 401 int num = ringSync() ;
398 if ( num > 1 ) 402 if ( num > 1 )
399 ringSync(); 403 ringSync();
400 setBlockSave(false); 404 setBlockSave(false);
401 if ( num ) 405 if ( num )
402 emit save(); 406 emit save();
403 if ( num ) 407 if ( num )
404 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 408 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
405 else 409 else
406 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 410 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
407 return; 411 return;
408} 412}
409 413
410int KSyncManager::ringSync() 414int KSyncManager::ringSync()
411{ 415{
412 int syncedProfiles = 0; 416 int syncedProfiles = 0;
413 unsigned int i; 417 unsigned int i;
414 QTime timer; 418 QTime timer;
415 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 419 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
416 QStringList syncProfileNames = mSyncProfileNames; 420 QStringList syncProfileNames = mSyncProfileNames;
417 KSyncProfile* temp = new KSyncProfile (); 421 KSyncProfile* temp = new KSyncProfile ();
418 mAskForPreferences = false; 422 mAskForPreferences = false;
419 for ( i = 0; i < syncProfileNames.count(); ++i ) { 423 for ( i = 0; i < syncProfileNames.count(); ++i ) {
420 mCurrentSyncProfile = i; 424 mCurrentSyncProfile = i;
421 temp->setName(syncProfileNames[mCurrentSyncProfile]); 425 temp->setName(syncProfileNames[mCurrentSyncProfile]);
422 temp->readConfig(&config); 426 temp->readConfig(&config);
423 427
424 bool includeInRingSync; 428 bool includeInRingSync;
425 switch(mTargetApp) 429 switch(mTargetApp)
426 { 430 {
427 case (KAPI): 431 case (KAPI):
428 includeInRingSync = temp->getIncludeInRingSyncAB(); 432 includeInRingSync = temp->getIncludeInRingSyncAB();
429 break; 433 break;
430 case (KOPI): 434 case (KOPI):
431 includeInRingSync = temp->getIncludeInRingSync(); 435 includeInRingSync = temp->getIncludeInRingSync();
432 break; 436 break;
433 case (PWMPI): 437 case (PWMPI):
434 includeInRingSync = temp->getIncludeInRingSyncPWM(); 438 includeInRingSync = temp->getIncludeInRingSyncPWM();
435 break; 439 break;
436 default: 440 default:
437 qDebug("KSyncManager::ringSync: invalid apptype selected"); 441 qDebug("KSyncManager::ringSync: invalid apptype selected");
438 break; 442 break;
439 443
440 } 444 }
441 445
442 446
443 if ( includeInRingSync && ( i < 1 || i > 2 )) { 447 if ( includeInRingSync && ( i < 1 || i > 2 )) {
444 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 448 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
445 ++syncedProfiles; 449 ++syncedProfiles;
446 // mAskForPreferences = temp->getAskForPreferences(); 450 // mAskForPreferences = temp->getAskForPreferences();
447 mWriteBackFile = temp->getWriteBackFile(); 451 mWriteBackFile = temp->getWriteBackFile();
448 mWriteBackExistingOnly = temp->getWriteBackExisting(); 452 mWriteBackExistingOnly = temp->getWriteBackExisting();
449 mWriteBackInFuture = 0; 453 mWriteBackInFuture = 0;
450 if ( temp->getWriteBackFuture() ) 454 if ( temp->getWriteBackFuture() )
451 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 455 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
452 mShowSyncSummary = false; 456 mShowSyncSummary = false;
453 mCurrentSyncDevice = syncProfileNames[i] ; 457 mCurrentSyncDevice = syncProfileNames[i] ;
454 mCurrentSyncName = mLocalMachineName; 458 mCurrentSyncName = mLocalMachineName;
455 if ( i == 0 ) { 459 if ( i == 0 ) {
456 syncSharp(); 460 syncSharp();
457 } else { 461 } else {
458 if ( temp->getIsLocalFileSync() ) { 462 if ( temp->getIsLocalFileSync() ) {
459 switch(mTargetApp) 463 switch(mTargetApp)
460 { 464 {
461 case (KAPI): 465 case (KAPI):
462 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 466 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
463 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
464 break; 468 break;
465 case (KOPI): 469 case (KOPI):