summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/kpimprefs.cpp9
-rw-r--r--libkdepim/kpimprefs.h3
-rw-r--r--libkdepim/ksyncmanager.cpp72
-rw-r--r--libkdepim/ksyncmanager.h3
4 files changed, 56 insertions, 31 deletions
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
index 0a2f5f1..c21ebaa 100644
--- a/libkdepim/kpimprefs.cpp
+++ b/libkdepim/kpimprefs.cpp
@@ -38,9 +38,16 @@ $Id$
38KPimPrefs::KPimPrefs( const QString &name ) : 38KPimPrefs::KPimPrefs( const QString &name ) :
39 KPrefs( name ) 39 KPrefs( name )
40{ 40{
41 config()->setGroup("General"); 41#ifdef _WIN32_
42 QString hdp= locateLocal("data","korganizer")+"\\\\";
43#else
44 QString hdp= locateLocal("data","korganizer")+"/";
45#endif
46 config()->setGroup("SyncOptions");
42 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); 47 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
43 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); 48 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
49 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
50 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
44} 51}
45 52
46KPimPrefs::~KPimPrefs() 53KPimPrefs::~KPimPrefs()
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index fde8093..9346f7d 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -57,7 +57,8 @@ class KPimPrefs : public KPrefs
57 QStringList mCustomCategories; 57 QStringList mCustomCategories;
58 QString mPassiveSyncPort; 58 QString mPassiveSyncPort;
59 QString mPassiveSyncPw; 59 QString mPassiveSyncPw;
60 60 int mRingSyncAlgoPrefs;
61 QString mLastSyncedLocalFile;
61 62
62 63
63 protected: 64 protected:
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index fad9a76..568c2a9 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -76,7 +76,7 @@ KSyncManager::~KSyncManager()
76 delete bar; 76 delete bar;
77} 77}
78 78
79//LR ok 79
80void KSyncManager::fillSyncMenu() 80void KSyncManager::fillSyncMenu()
81{ 81{
82 if ( mSyncMenu->count() ) 82 if ( mSyncMenu->count() )
@@ -101,11 +101,14 @@ void KSyncManager::fillSyncMenu()
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 KSyncProfile* temp = new KSyncProfile (); 105 KSyncProfile* temp = new KSyncProfile ();
105 temp->setName( prof[0] ); 106 temp->setName( prof[0] );
106 temp->writeConfig(&config); 107 temp->writeConfig(&config);
107 temp->setName( prof[1] ); 108 temp->setName( prof[1] );
108 temp->writeConfig(&config); 109 temp->writeConfig(&config);
110 temp->setName( prof[2] );
111 temp->writeConfig(&config);
109 config.setGroup("General"); 112 config.setGroup("General");
110 config.writeEntry("SyncProfileNames",prof); 113 config.writeEntry("SyncProfileNames",prof);
111 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 114 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
@@ -126,8 +129,9 @@ void KSyncManager::fillSyncMenu()
126 mSyncMenu->removeItem( 1000 ); 129 mSyncMenu->removeItem( 1000 );
127 } 130 }
128 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 131 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
129 mSyncMenu->setItemEnabled( 1000, false ); 132 mSyncMenu->removeItem( 1000 );
130 } 133 }
134 mSyncMenu->removeItem( 1002 );
131} 135}
132 136
133void KSyncManager::slotSyncMenu( int action ) 137void KSyncManager::slotSyncMenu( int action )
@@ -195,15 +199,15 @@ void KSyncManager::slotSyncMenu( int action )
195 { 199 {
196 case (KAPI): 200 case (KAPI):
197 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 201 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
198 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 202 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
199 break; 203 break;
200 case (KOPI): 204 case (KOPI):
201 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 205 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
202 mLastSyncedLocalFile = temp->getRemoteFileName(); 206 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
203 break; 207 break;
204 case (PWMPI): 208 case (PWMPI):
205 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 209 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
206 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 210 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
207 break; 211 break;
208 default: 212 default:
209 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 213 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
@@ -239,6 +243,7 @@ void KSyncManager::slotSyncMenu( int action )
239 delete temp; 243 delete temp;
240 setBlockSave(false); 244 setBlockSave(false);
241} 245}
246
242void KSyncManager::enableQuick() 247void KSyncManager::enableQuick()
243{ 248{
244 QDialog dia ( 0, "input-dialog", true ); 249 QDialog dia ( 0, "input-dialog", true );
@@ -285,7 +290,6 @@ void KSyncManager::enableQuick()
285 mServerSocket = 0; 290 mServerSocket = 0;
286 return; 291 return;
287 } 292 }
288 //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
289 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 293 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
290 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 294 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
291} 295}
@@ -293,7 +297,7 @@ void KSyncManager::enableQuick()
293void KSyncManager::syncLocalFile() 297void KSyncManager::syncLocalFile()
294{ 298{
295 299
296 QString fn =mLastSyncedLocalFile; 300 QString fn =mPrefs->mLastSyncedLocalFile;
297 QString ext; 301 QString ext;
298 302
299 switch(mTargetApp) 303 switch(mTargetApp)
@@ -321,6 +325,7 @@ void KSyncManager::syncLocalFile()
321 } 325 }
322 326
323} 327}
328
324bool KSyncManager::syncWithFile( QString fn , bool quick ) 329bool KSyncManager::syncWithFile( QString fn , bool quick )
325{ 330{
326 bool ret = false; 331 bool ret = false;
@@ -353,25 +358,27 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
353 else 358 else
354 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 359 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
355 if ( ! quick ) 360 if ( ! quick )
356 mLastSyncedLocalFile = fn; 361 mPrefs->mLastSyncedLocalFile = fn;
357 } 362 }
358 return ret; 363 return ret;
359} 364}
365
360void KSyncManager::quickSyncLocalFile() 366void KSyncManager::quickSyncLocalFile()
361{ 367{
362 368
363 if ( syncWithFile( mLastSyncedLocalFile, false ) ) { 369 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) {
364 qDebug("quick syncLocalFile() successful "); 370 qDebug("quick syncLocalFile() successful ");
365 371
366 } 372 }
367} 373}
374
368void KSyncManager::multiSync( bool askforPrefs ) 375void KSyncManager::multiSync( bool askforPrefs )
369{ 376{
370 if (blockSave()) 377 if (blockSave())
371 return; 378 return;
372 setBlockSave(true); 379 setBlockSave(true);
373 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 380 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
374 if ( QMessageBox::information( mParent, i18n("Sync"), 381 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
375 question, 382 question,
376 i18n("Yes"), i18n("No"), 383 i18n("Yes"), i18n("No"),
377 0, 0 ) != 0 ) { 384 0, 0 ) != 0 ) {
@@ -380,7 +387,7 @@ void KSyncManager::multiSync( bool askforPrefs )
380 return; 387 return;
381 } 388 }
382 mCurrentSyncDevice = i18n("Multiple profiles") ; 389 mCurrentSyncDevice = i18n("Multiple profiles") ;
383 mSyncAlgoPrefs = mRingSyncAlgoPrefs; 390 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
384 if ( askforPrefs ) { 391 if ( askforPrefs ) {
385 edit_sync_options(); 392 edit_sync_options();
386 mRingSyncAlgoPrefs = mSyncAlgoPrefs; 393 mRingSyncAlgoPrefs = mSyncAlgoPrefs;
@@ -394,11 +401,12 @@ void KSyncManager::multiSync( bool askforPrefs )
394 if ( num ) 401 if ( num )
395 emit save(); 402 emit save();
396 if ( num ) 403 if ( num )
397 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 404 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
398 else 405 else
399 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 406 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
400 return; 407 return;
401} 408}
409
402int KSyncManager::ringSync() 410int KSyncManager::ringSync()
403{ 411{
404 int syncedProfiles = 0; 412 int syncedProfiles = 0;
@@ -452,15 +460,15 @@ int KSyncManager::ringSync()
452 { 460 {
453 case (KAPI): 461 case (KAPI):
454 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 462 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
455 mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 463 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
456 break; 464 break;
457 case (KOPI): 465 case (KOPI):
458 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 466 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
459 mLastSyncedLocalFile = temp->getRemoteFileName(); 467 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
460 break; 468 break;
461 case (PWMPI): 469 case (PWMPI):
462 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 470 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
463 mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 471 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
464 break; 472 break;
465 default: 473 default:
466 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 474 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
@@ -472,6 +480,21 @@ int KSyncManager::ringSync()
472 mPhoneConnection = temp->getPhoneConnection( ); 480 mPhoneConnection = temp->getPhoneConnection( );
473 mPhoneModel = temp->getPhoneModel( ); 481 mPhoneModel = temp->getPhoneModel( );
474 syncPhone(); 482 syncPhone();
483 } else if ( temp->getIsPiSync() ) {
484 if ( mTargetApp == KAPI ) {
485 mPassWordPiSync = temp->getRemotePwAB();
486 mActiveSyncPort = temp->getRemotePortAB();
487 mActiveSyncIP = temp->getRemoteIPAB();
488 } else if ( mTargetApp == KOPI ) {
489 mPassWordPiSync = temp->getRemotePw();
490 mActiveSyncPort = temp->getRemotePort();
491 mActiveSyncIP = temp->getRemoteIP();
492 } else {
493 mPassWordPiSync = temp->getRemotePwPWM();
494 mActiveSyncPort = temp->getRemotePortPWM();
495 mActiveSyncIP = temp->getRemoteIPPWM();
496 }
497 syncPi();
475 } else 498 } else
476 syncRemote( temp, false ); 499 syncRemote( temp, false );
477 500
@@ -558,19 +581,14 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
558 QMessageBox::information( mParent, i18n("Sync - ERROR"), 581 QMessageBox::information( mParent, i18n("Sync - ERROR"),
559 question, 582 question,
560 i18n("Okay!")) ; 583 i18n("Okay!")) ;
561 mParent->topLevelWidget()->setCaption (""); 584 mParent->topLevelWidget()->setCaption ("KDE-Pim");
562 return; 585 return;
563 } 586 }
564 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 587 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
565 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 588 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
566 589
567
568
569 if ( syncWithFile( localTempFile, true ) ) { 590 if ( syncWithFile( localTempFile, true ) ) {
570// Event* e = mView->getLastSyncEvent(); 591
571// e->setReadOnly( false );
572// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
573// e->setReadOnly( true );
574 if ( mWriteBackFile ) { 592 if ( mWriteBackFile ) {
575 int fi; 593 int fi;
576 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 594 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
@@ -644,6 +662,7 @@ void KSyncManager::edit_sync_options()
644 662
645 663
646} 664}
665
647QString KSyncManager::getPassword( ) 666QString KSyncManager::getPassword( )
648{ 667{
649 QString retfile = ""; 668 QString retfile = "";
@@ -685,11 +704,12 @@ void KSyncManager::confSync()
685 sp->exec(); 704 sp->exec();
686 mSyncProfileNames = sp->getSyncProfileNames(); 705 mSyncProfileNames = sp->getSyncProfileNames();
687 mLocalMachineName = sp->getLocalMachineName (); 706 mLocalMachineName = sp->getLocalMachineName ();
688 fillSyncMenu(); 707 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
689} 708}
690 709
691void KSyncManager::syncSharp() 710void KSyncManager::syncSharp()
692{ 711{
712
693 if ( ! syncExternalApplication("sharp") ) 713 if ( ! syncExternalApplication("sharp") )
694 qDebug("ERROR sync sharp ");; 714 qDebug("ERROR sync sharp ");;
695} 715}
@@ -712,10 +732,8 @@ bool KSyncManager::syncExternalApplication(QString resource)
712 732
713void KSyncManager::syncPhone() 733void KSyncManager::syncPhone()
714{ 734{
715 emit save();
716 735
717 qDebug("pending syncPhone(); "); 736 syncExternalApplication("phone");
718 //mView->syncPhone();
719 737
720} 738}
721 739
@@ -767,6 +785,7 @@ QString KSyncManager::syncFileName()
767#endif 785#endif
768} 786}
769 787
788
770void KSyncManager::syncPi() 789void KSyncManager::syncPi()
771{ 790{
772 qApp->processEvents(); 791 qApp->processEvents();
@@ -1153,4 +1172,3 @@ void KCommandSocket::deleteSocket()
1153 mSocket = 0; 1172 mSocket = 0;
1154 emit commandFinished( this, mRetVal ); 1173 emit commandFinished( this, mRetVal );
1155} 1174}
1156
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 25892d8..7027894 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -117,6 +117,7 @@ class KSyncManager : public QObject
117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 117 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
118 ~KSyncManager() ; 118 ~KSyncManager() ;
119 119
120 void multiSync( bool askforPrefs );
120 bool blockSave() { return mBlockSaveFlag; } 121 bool blockSave() { return mBlockSaveFlag; }
121 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 122 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
122 void setDefaultFileName( QString s) { mDefFileName = s ;} 123 void setDefaultFileName( QString s) { mDefFileName = s ;}
@@ -147,7 +148,6 @@ class KSyncManager : public QObject
147 QString mPhoneDevice; 148 QString mPhoneDevice;
148 QString mPhoneConnection; 149 QString mPhoneConnection;
149 QString mPhoneModel; 150 QString mPhoneModel;
150 QString mLastSyncedLocalFile; // save!
151 QString mPassWordPiSync; 151 QString mPassWordPiSync;
152 QString mActiveSyncPort; 152 QString mActiveSyncPort;
153 QString mActiveSyncIP ; 153 QString mActiveSyncIP ;
@@ -178,7 +178,6 @@ class KSyncManager : public QObject
178 void syncPhone(); 178 void syncPhone();
179 void syncSharp(); 179 void syncSharp();
180 bool syncExternalApplication(QString); 180 bool syncExternalApplication(QString);
181 void multiSync( bool askforPrefs );
182 int mCurrentSyncProfile ; 181 int mCurrentSyncProfile ;
183 void syncRemote( KSyncProfile* prof, bool ask = true); 182 void syncRemote( KSyncProfile* prof, bool ask = true);
184 void edit_sync_options(); 183 void edit_sync_options();