summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-25 17:41:25 (UTC)
committer zautrix <zautrix>2005-11-25 17:41:25 (UTC)
commit279e183c0325cd9565605f60af0215bb9bfdc825 (patch) (unidiff)
tree43ab776cd108874819e7c6e73070a7d989a9078f
parent794a5204686ad9bfc16172b01db35f1f3b7683e5 (diff)
downloadkdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.zip
kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.gz
kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.bz2
sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp73
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/mainwindow.cpp14
-rw-r--r--korganizer/mainwindow.h4
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp16
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkdepim/ksyncmanager.cpp24
-rw-r--r--libkdepim/ksyncmanager.h6
9 files changed, 118 insertions, 25 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8965d3b..307027a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -363,12 +363,13 @@ CalendarView::CalendarView( Calendar *calendar,
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 mMultiResourceSync = false;
369 flag_blockConflict = false; 370 flag_blockConflict = false;
370 flag_blockScrollBar = false; 371 flag_blockScrollBar = false;
371 flag_checkFileFirsttime = true; 372 flag_checkFileFirsttime = true;
372 flag_clearallviewsEventDisplay = false; 373 flag_clearallviewsEventDisplay = false;
373 flag_clearallviewsupdateView = false; 374 flag_clearallviewsupdateView = false;
374 mNextAlarmDateTime = QDateTime::currentDateTime(); 375 mNextAlarmDateTime = QDateTime::currentDateTime();
@@ -1549,12 +1550,13 @@ Event* CalendarView::getLastSyncEvent()
1549 sum = "E: "; 1550 sum = "E: ";
1550 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1551 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1551 lse->setDtStart( mLastCalendarSync ); 1552 lse->setDtStart( mLastCalendarSync );
1552 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1553 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1553 lse->setCategories( i18n("SyncEvent") ); 1554 lse->setCategories( i18n("SyncEvent") );
1554 lse->setReadOnly( true ); 1555 lse->setReadOnly( true );
1556 lse->setCalID( 1 );
1555 mCalendar->addEvent( lse ); 1557 mCalendar->addEvent( lse );
1556 } 1558 }
1557 1559
1558 return lse; 1560 return lse;
1559 1561
1560} 1562}
@@ -1899,22 +1901,27 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1899 } 1901 }
1900 inR = er.next(); 1902 inR = er.next();
1901 } 1903 }
1902 } 1904 }
1903 bar.hide(); 1905 bar.hide();
1904 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1906 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1905 eventLSync->setReadOnly( false ); 1907 if ( mMultiResourceSync ) {
1906 eventLSync->setDtStart( mLastCalendarSync ); 1908 remote->removeSyncInfo( "" ); //all
1907 eventRSync->setDtStart( mLastCalendarSync ); 1909
1908 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1910 } else {
1909 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1911 eventLSync->setReadOnly( false );
1910 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1912 eventLSync->setDtStart( mLastCalendarSync );
1911 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1913 eventRSync->setDtStart( mLastCalendarSync );
1912 eventLSync->setReadOnly( true ); 1914 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1915 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1916 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1917 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1918 eventLSync->setReadOnly( true );
1919 }
1913 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1920 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1914 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1921 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal...
1915 remote->addEvent( eventRSync ); 1922 remote->addEvent( eventRSync );
1916 else 1923 else
1917 delete eventRSync; 1924 delete eventRSync;
1918 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1925 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1919 QString mes; 1926 QString mes;
1920 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1927 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
@@ -2432,12 +2439,38 @@ void CalendarView::mergeFile( QString fn )
2432 mCalendar->mergeCalendarFile( fn ); 2439 mCalendar->mergeCalendarFile( fn );
2433 mCalendar->reInitAlarmSettings(); 2440 mCalendar->reInitAlarmSettings();
2434 setSyncEventsReadOnly(); 2441 setSyncEventsReadOnly();
2435 updateUnmanagedViews(); 2442 updateUnmanagedViews();
2436 updateView(); 2443 updateView();
2437} 2444}
2445void CalendarView::mergeFileResource( QString fn ,QString resource )
2446{
2447
2448 if ( resource == "ALL" ) {
2449 mergeFile( fn );
2450 return;
2451 }
2452
2453 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
2454 if ( !exclusiveResource ) {
2455 qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() );
2456 return;
2457 }
2458 clearAllViews();
2459 mCalendar->setCalendarRemove( exclusiveResource );
2460 int def = mCalendar->defaultCalendar();
2461 mCalendar->setDefaultCalendar(exclusiveResource);
2462 if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) {
2463 qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() );
2464 }
2465 mCalendar->setDefaultCalendar( def );
2466 mCalendar->reInitAlarmSettings();
2467 setSyncEventsReadOnly();
2468 updateUnmanagedViews();
2469 updateView();
2470}
2438void CalendarView::showOpenError() 2471void CalendarView::showOpenError()
2439{ 2472{
2440 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2473 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2441} 2474}
2442void CalendarView::setLoadedFileVersion(QDateTime dt) 2475void CalendarView::setLoadedFileVersion(QDateTime dt)
2443{ 2476{
@@ -2519,12 +2552,13 @@ bool CalendarView::checkFileVersion(QString fn)
2519 setSyncDevice("deleteaftersync" ); 2552 setSyncDevice("deleteaftersync" );
2520 mSyncManager->mAskForPreferences = true; 2553 mSyncManager->mAskForPreferences = true;
2521 mSyncManager->mSyncAlgoPrefs = 3; 2554 mSyncManager->mSyncAlgoPrefs = 3;
2522 mSyncManager->mWriteBackFile = false; 2555 mSyncManager->mWriteBackFile = false;
2523 mSyncManager->mWriteBackExistingOnly = false; 2556 mSyncManager->mWriteBackExistingOnly = false;
2524 mSyncManager->mShowSyncSummary = false; 2557 mSyncManager->mShowSyncSummary = false;
2558 mMultiResourceSync = false;
2525 syncCalendar( fn, 3 ); 2559 syncCalendar( fn, 3 );
2526 Event * e = getLastSyncEvent(); 2560 Event * e = getLastSyncEvent();
2527 if ( e ) 2561 if ( e )
2528 mCalendar->deleteEvent( e ); 2562 mCalendar->deleteEvent( e );
2529 return true; 2563 return true;
2530} 2564}
@@ -2555,12 +2589,29 @@ bool CalendarView::saveCalendars()
2555 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; 2589 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2556 KMessageBox::error(this, saveError, i18n("Error saving data")); 2590 KMessageBox::error(this, saveError, i18n("Error saving data"));
2557 return false; 2591 return false;
2558 } 2592 }
2559 return true; 2593 return true;
2560} 2594}
2595bool CalendarView::saveCalendarResource(QString filename, QString resource)
2596{
2597 if ( resource == "ALL" )
2598 return saveCalendar( filename );
2599 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
2600 if ( !exclusiveResource ) {
2601 qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() );
2602 return false;
2603 }
2604 mCalendar->setDefaultCalendar( exclusiveResource );
2605 mCalendar->setDefaultCalendarEnabledOnly();
2606 mCalendar->setSyncEventsEnabled();
2607 bool res = saveCalendar( filename );
2608 restoreCalendarSettings();
2609 return res;
2610
2611}
2561bool CalendarView::saveCalendar( QString filename ) 2612bool CalendarView::saveCalendar( QString filename )
2562{ 2613{
2563 2614
2564 // Store back all unsaved data into calendar object 2615 // Store back all unsaved data into calendar object
2565 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2616 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2566 if ( mViewManager->currentView() ) 2617 if ( mViewManager->currentView() )
@@ -5029,13 +5080,17 @@ void CalendarView::slotCalendarChanged()
5029void CalendarView::keyPressEvent ( QKeyEvent *e) 5080void CalendarView::keyPressEvent ( QKeyEvent *e)
5030{ 5081{
5031 //qDebug("CalendarView::keyPressEvent "); 5082 //qDebug("CalendarView::keyPressEvent ");
5032 e->ignore(); 5083 e->ignore();
5033} 5084}
5034 5085
5086void CalendarView::multiResourceSyncStart( bool start )
5087{
5088 mMultiResourceSync = start;
5035 5089
5090}
5036bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) 5091bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource)
5037{ 5092{
5038 5093
5039 if ( manager != mSyncManager) 5094 if ( manager != mSyncManager)
5040 qDebug("KO: Internal error-1. SyncManager mismatch "); 5095 qDebug("KO: Internal error-1. SyncManager mismatch ");
5041 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 5096 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index f85b6a3..60b1276 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -136,12 +136,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
136 void addView(KOrg::BaseView *); 136 void addView(KOrg::BaseView *);
137 void showView(KOrg::BaseView *); 137 void showView(KOrg::BaseView *);
138 KOEventViewerDialog* getEventViewerDialog(); 138 KOEventViewerDialog* getEventViewerDialog();
139 Incidence *currentSelection(); 139 Incidence *currentSelection();
140 void checkSuspendAlarm(); 140 void checkSuspendAlarm();
141 void mergeFile( QString fn ); 141 void mergeFile( QString fn );
142 void mergeFileResource( QString fn ,QString res);
142 143
143 signals: 144 signals:
144 void save (); 145 void save ();
145 void saveStopTimer (); 146 void saveStopTimer ();
146 void tempDisableBR(bool); 147 void tempDisableBR(bool);
147 /** This todo has been modified */ 148 /** This todo has been modified */
@@ -198,12 +199,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
198 void calendarViewExpanded( bool ); 199 void calendarViewExpanded( bool );
199 void updateSearchDialog(); 200 void updateSearchDialog();
200 void filtersUpdated(); 201 void filtersUpdated();
201 202
202 203
203 public slots: 204 public slots:
205 void multiResourceSyncStart( bool );
204 void displayCalendarInfo( int id ); 206 void displayCalendarInfo( int id );
205 void nextConflict( bool all, bool allday ); 207 void nextConflict( bool all, bool allday );
206 void conflictAll(); 208 void conflictAll();
207 void conflictAllday(); 209 void conflictAllday();
208 void conflictNotAll(); 210 void conflictNotAll();
209 void setCalReadOnly( int id, bool readO ); 211 void setCalReadOnly( int id, bool readO );
@@ -243,12 +245,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
243 245
244 /** 246 /**
245 Save calendar data to file. Return true if calendar could be 247 Save calendar data to file. Return true if calendar could be
246 successfully saved. 248 successfully saved.
247 */ 249 */
248 bool saveCalendar(QString filename); 250 bool saveCalendar(QString filename);
251 bool saveCalendarResource(QString filename, QString resource);
249 252
250 /** 253 /**
251 Close calendar. Clear calendar data and reset views to display an empty 254 Close calendar. Clear calendar data and reset views to display an empty
252 calendar. 255 calendar.
253 */ 256 */
254 void closeCalendar(); 257 void closeCalendar();
@@ -536,12 +539,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
536 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 539 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
537 //Attendee* getYourAttendee(Event *event); 540 //Attendee* getYourAttendee(Event *event);
538 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 541 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
539 void setScrollBarStep(int val ); 542 void setScrollBarStep(int val );
540 543
541 protected: 544 protected:
545 bool mMultiResourceSync;
542 Event *mConflictingEvent; 546 Event *mConflictingEvent;
543 void schedule(Scheduler::Method, Incidence *incidence = 0); 547 void schedule(Scheduler::Method, Incidence *incidence = 0);
544 548
545 // returns KMsgBox::OKCandel() 549 // returns KMsgBox::OKCandel()
546 int msgItemDelete(const QString name); 550 int msgItemDelete(const QString name);
547 void showEventEditor(); 551 void showEventEditor();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 66bb19b..69ccde1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -371,14 +371,16 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) :
371 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 371 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
372 //fillSyncMenu(); 372 //fillSyncMenu();
373 373
374 374
375 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 375 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
376 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 376 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
377 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 377 connect(mSyncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) );
378 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 378 connect(mSyncManager , SIGNAL( getFile( bool, const QString &)), this, SLOT(getFile( bool,const QString & ) ) );
379 connect(mSyncManager , SIGNAL( multiResourceSyncStart( bool )), mView, SLOT( multiResourceSyncStart( bool ) ) );
380
379 mSyncManager->setDefaultFileName( sentSyncFile()); 381 mSyncManager->setDefaultFileName( sentSyncFile());
380 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 382 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
381 mSyncManager->fillSyncMenu(); 383 mSyncManager->fillSyncMenu();
382 384
383 385
384 386
@@ -2701,36 +2703,36 @@ QString MainWindow::sentSyncFile()
2701 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); 2703 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) );
2702#else 2704#else
2703 return QString( "/tmp/copysynccal.ics" ); 2705 return QString( "/tmp/copysynccal.ics" );
2704#endif 2706#endif
2705} 2707}
2706 2708
2707void MainWindow::syncFileRequest() 2709void MainWindow::syncFileRequest(const QString& resource)
2708{ 2710{
2709 while ( mSyncManager->blockSave() ) { 2711 while ( mSyncManager->blockSave() ) {
2710 qApp->processEvents(); 2712 qApp->processEvents();
2711 } 2713 }
2712 mSyncManager->setBlockSave(true); 2714 mSyncManager->setBlockSave(true);
2713 2715
2714 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2716 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2715 mSyncManager->slotSyncMenu( 999 ); 2717 mSyncManager->slotSyncMenu( 999 );
2716 } 2718 }
2717 2719
2718 setCaption(i18n("Saving Data to temp file ..." )); 2720 setCaption(i18n("Saving Data to temp file ..." ));
2719 mView->saveCalendar( sentSyncFile() ); 2721 mView->saveCalendarResource( sentSyncFile(), resource );
2720 setCaption(i18n("Data saved to temp file!" )); 2722 setCaption(i18n("Data saved to temp file!" ));
2721 mSyncManager->setBlockSave( false ); 2723 mSyncManager->setBlockSave( false );
2722 2724
2723} 2725}
2724void MainWindow::getFile( bool success ) 2726void MainWindow::getFile( bool success ,const QString& resource)
2725{ 2727{
2726 if ( ! success ) { 2728 if ( ! success ) {
2727 setCaption( i18n("Error receiving file. Nothing changed!") ); 2729 setCaption( i18n("Error receiving file. Nothing changed!") );
2728 return; 2730 return;
2729 } 2731 }
2730 mView->mergeFile( sentSyncFile() ); 2732 mView->mergeFileResource( sentSyncFile(), resource);
2731 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2733 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2732 mSyncManager->slotSyncMenu( 999 ); 2734 mSyncManager->slotSyncMenu( 999 );
2733 } 2735 }
2734 setCaption( i18n("Pi-Sync successful!") ); 2736 setCaption( i18n("Pi-Sync successful!") );
2735} 2737}
2736void MainWindow::printListView() 2738void MainWindow::printListView()
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index d8018b6..a533d8b 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -107,14 +107,14 @@ class MainWindow : public QMainWindow
107 signals: 107 signals:
108 void selectWeek ( int ); 108 void selectWeek ( int );
109 private slots: 109 private slots:
110 void slotResetFocus(); 110 void slotResetFocus();
111 void slotResetFocusLoop(); 111 void slotResetFocusLoop();
112 void showConfigureAgenda(); 112 void showConfigureAgenda();
113 void getFile( bool ); 113 void getFile( bool ,const QString &);
114 void syncFileRequest(); 114 void syncFileRequest(const QString &);
115 115
116 protected: 116 protected:
117 int mFocusLoop; 117 int mFocusLoop;
118 void hideEvent ( QHideEvent * ); 118 void hideEvent ( QHideEvent * );
119 QString sentSyncFile(); 119 QString sentSyncFile();
120 void displayText( QString, QString); 120 void displayText( QString, QString);
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4b8b3ff..0a94914 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -76,12 +76,13 @@ public:
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0; 77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0; 78 virtual bool addCalendarFile( QString name, int id ) = 0;
79 virtual bool mergeCalendarFile( QString name ) = 0; 79 virtual bool mergeCalendarFile( QString name ) = 0;
80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; 80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0;
81 virtual void setSyncEventsReadOnly() = 0; 81 virtual void setSyncEventsReadOnly() = 0;
82 virtual void setSyncEventsEnabled() = 0;
82 virtual void stopAllTodos() = 0; 83 virtual void stopAllTodos() = 0;
83 virtual void clearUndo( Incidence * newUndo ); 84 virtual void clearUndo( Incidence * newUndo );
84 85
85 /** 86 /**
86 Sync changes in memory to persistant storage. 87 Sync changes in memory to persistant storage.
87 */ 88 */
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 0ddfeca..45e3128 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -170,19 +170,31 @@ bool CalendarLocal::addCalendarFile( QString name, int id )
170 if ( calendar.load( name ) ) { 170 if ( calendar.load( name ) ) {
171 addCalendar( &calendar ); 171 addCalendar( &calendar );
172 return true; 172 return true;
173 } 173 }
174 return false; 174 return false;
175} 175}
176void CalendarLocal::setSyncEventsReadOnly() 176void CalendarLocal::setSyncEventsEnabled()
177{ 177{
178 Event * ev; 178 Event * ev;
179 ev = mEventList.first(); 179 ev = mEventList.first();
180 while ( ev ) { 180 while ( ev ) {
181 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 181 if ( ev->uid().left(15) == QString("last-syncEvent-") )
182 ev->setReadOnly( true ); 182 ev->setCalEnabled( true );
183 ev = mEventList.next();
184 }
185}
186void CalendarLocal::setSyncEventsReadOnly()
187{
188 Event * ev;
189 ev = mEventList.first();
190 while ( ev ) {
191 if ( ev->uid().left(15) == QString("last-syncEvent-") ) {
192 ev->setReadOnly( true );
193 ev->setCalID( 1 );
194 }
183 ev = mEventList.next(); 195 ev = mEventList.next();
184 } 196 }
185} 197}
186void CalendarLocal::addCalendar( Calendar* cal ) 198void CalendarLocal::addCalendar( Calendar* cal )
187{ 199{
188 cal->setDontDeleteIncidencesOnClose(); 200 cal->setDontDeleteIncidencesOnClose();
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index ca0bd98..eb7bf34 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -46,12 +46,13 @@ class CalendarLocal : public Calendar
46 void addCalendar( Calendar* ); 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id ); 47 bool addCalendarFile( QString name, int id );
48 bool mergeCalendarFile( QString name ); 48 bool mergeCalendarFile( QString name );
49 bool mergeCalendar( Calendar* cal ); 49 bool mergeCalendar( Calendar* cal );
50 Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); 50 Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates );
51 void setSyncEventsReadOnly(); 51 void setSyncEventsReadOnly();
52 void setSyncEventsEnabled();
52 void stopAllTodos(); 53 void stopAllTodos();
53 /** 54 /**
54 Loads a calendar on disk in vCalendar or iCalendar format into the current 55 Loads a calendar on disk in vCalendar or iCalendar format into the current
55 calendar. Any information already present is lost. 56 calendar. Any information already present is lost.
56 @return true, if successfull, false on error. 57 @return true, if successfull, false on error.
57 @param fileName the name of the calendar on disk. 58 @param fileName the name of the calendar on disk.
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index a64eb34..719d80b 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -193,13 +193,14 @@ void KSyncManager::slotClearMenu( int action )
193 return; 193 return;
194 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
195} 195}
196void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
197{ 197{
198 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = ""; 199 mCurrentResourceLocal = "";
200 emit multiResourceSyncStart( false );
200 if ( action == 5000 ) 201 if ( action == 5000 )
201 return; 202 return;
202 mSyncWithDesktop = false; 203 mSyncWithDesktop = false;
203 if ( action == 0 ) { 204 if ( action == 0 ) {
204 205
205 // seems to be a Qt2 event handling bug 206 // seems to be a Qt2 event handling bug
@@ -438,12 +439,14 @@ void KSyncManager::enableQuick( bool ask )
438 mPrefs->mPassiveSyncAutoStart = autoStart; 439 mPrefs->mPassiveSyncAutoStart = autoStart;
439 if ( changed ) { 440 if ( changed ) {
440 mPrefs->writeConfig(); 441 mPrefs->writeConfig();
441 } 442 }
442 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 443 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
443 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 444 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
445 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) );
446 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) );
444} 447}
445void KSyncManager::displayErrorPort() 448void KSyncManager::displayErrorPort()
446{ 449{
447 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 450 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
448} 451}
449void KSyncManager::syncLocalFile() 452void KSyncManager::syncLocalFile()
@@ -566,13 +569,13 @@ void KSyncManager::multiSync( bool askforPrefs )
566 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 569 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
567 return; 570 return;
568} 571}
569 572
570int KSyncManager::ringSync() 573int KSyncManager::ringSync()
571{ 574{
572 575 emit multiResourceSyncStart( false );
573 int syncedProfiles = 0; 576 int syncedProfiles = 0;
574 unsigned int i; 577 unsigned int i;
575 QTime timer; 578 QTime timer;
576 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 579 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
577 QStringList syncProfileNames = mSyncProfileNames; 580 QStringList syncProfileNames = mSyncProfileNames;
578 KSyncProfile* temp = new KSyncProfile (); 581 KSyncProfile* temp = new KSyncProfile ();
@@ -1137,13 +1140,16 @@ void KSyncManager::syncPi()
1137 } 1140 }
1138 mCurrentResourceLocal = ""; 1141 mCurrentResourceLocal = "";
1139 mCurrentResourceRemote = ""; 1142 mCurrentResourceRemote = "";
1140 if ( mSpecificResources.count() ) { 1143 if ( mSpecificResources.count() ) {
1141 int startLocal = 0; 1144 int startLocal = 0;
1142 int startRemote = mSpecificResources.count()/2; 1145 int startRemote = mSpecificResources.count()/2;
1146 emit multiResourceSyncStart( true );
1143 while ( startLocal < mSpecificResources.count()/2 ) { 1147 while ( startLocal < mSpecificResources.count()/2 ) {
1148 if ( startLocal+1 >= mSpecificResources.count()/2 )
1149 emit multiResourceSyncStart( false );
1144 mPisyncFinished = false; 1150 mPisyncFinished = false;
1145 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1151 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1146 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1152 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1147 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1153 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1148 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1154 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1149 commandSocket->readFile( syncFileName() ); 1155 commandSocket->readFile( syncFileName() );
@@ -1216,13 +1222,13 @@ void KSyncManager::readFileFromSocket()
1216 bool syncOK = true; 1222 bool syncOK = true;
1217 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1223 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1218 if ( ! syncWithFile( fileName , true ) ) { 1224 if ( ! syncWithFile( fileName , true ) ) {
1219 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1225 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1220 syncOK = false; 1226 syncOK = false;
1221 } 1227 }
1222 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1228 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1223 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1229 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1224 if ( mWriteBackFile && syncOK ) { 1230 if ( mWriteBackFile && syncOK ) {
1225 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1231 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1226 commandSocket->writeFile( fileName ); 1232 commandSocket->writeFile( fileName );
1227 } 1233 }
1228 else { 1234 else {
@@ -1280,12 +1286,13 @@ void KServerSocket::readClient()
1280 } 1286 }
1281 if ( mErrorMessage ) { 1287 if ( mErrorMessage ) {
1282 mErrorMessage = 999; 1288 mErrorMessage = 999;
1283 error_connect("ERROR_ED\r\n\r\n"); 1289 error_connect("ERROR_ED\r\n\r\n");
1284 return; 1290 return;
1285 } 1291 }
1292 mResource = "";
1286 mErrorMessage = 0; 1293 mErrorMessage = 0;
1287 //qDebug("KServerSocket::readClient()"); 1294 //qDebug("KServerSocket::readClient()");
1288 if ( mSocket->canReadLine() ) { 1295 if ( mSocket->canReadLine() ) {
1289 QString line = mSocket->readLine(); 1296 QString line = mSocket->readLine();
1290 //qDebug("KServerSocket readline: %s ", line.latin1()); 1297 //qDebug("KServerSocket readline: %s ", line.latin1());
1291 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1298 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
@@ -1296,23 +1303,25 @@ void KServerSocket::readClient()
1296 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1303 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1297 if ( ok ) { 1304 if ( ok ) {
1298 KSyncManager::mRequestedSyncEvent = dt; 1305 KSyncManager::mRequestedSyncEvent = dt;
1299 } 1306 }
1300 else 1307 else
1301 KSyncManager::mRequestedSyncEvent = QDateTime(); 1308 KSyncManager::mRequestedSyncEvent = QDateTime();
1309 mResource =tokens[3];
1302 send_file(); 1310 send_file();
1303 } 1311 }
1304 else { 1312 else {
1305 mErrorMessage = 1; 1313 mErrorMessage = 1;
1306 error_connect("ERROR_PW\r\n\r\n"); 1314 error_connect("ERROR_PW\r\n\r\n");
1307 } 1315 }
1308 } 1316 }
1309 if ( tokens[0] == "PUT" ) { 1317 if ( tokens[0] == "PUT" ) {
1310 if ( tokens[1] == mPassWord ) { 1318 if ( tokens[1] == mPassWord ) {
1311 //emit getFile( mSocket ); 1319 //emit getFile( mSocket );
1312 blockRC = true; 1320 blockRC = true;
1321 mResource =tokens[2];
1313 get_file(); 1322 get_file();
1314 } 1323 }
1315 else { 1324 else {
1316 mErrorMessage = 2; 1325 mErrorMessage = 2;
1317 error_connect("ERROR_PW\r\n\r\n"); 1326 error_connect("ERROR_PW\r\n\r\n");
1318 end_connect(); 1327 end_connect();
@@ -1403,12 +1412,13 @@ void KServerSocket::send_file()
1403 mSyncActionDialog->setFixedSize( 230, 120); 1412 mSyncActionDialog->setFixedSize( 230, 120);
1404 } 1413 }
1405 } else 1414 } else
1406 mSyncActionDialog->setFixedSize( 230, 120); 1415 mSyncActionDialog->setFixedSize( 230, 120);
1407 mSyncActionDialog->show(); 1416 mSyncActionDialog->show();
1408 mSyncActionDialog->raise(); 1417 mSyncActionDialog->raise();
1418 emit request_file(mResource);
1409 emit request_file(); 1419 emit request_file();
1410 qApp->processEvents(); 1420 qApp->processEvents();
1411 QString fileName = mFileName; 1421 QString fileName = mFileName;
1412 QFile file( fileName ); 1422 QFile file( fileName );
1413 if (!file.open( IO_ReadOnly ) ) { 1423 if (!file.open( IO_ReadOnly ) ) {
1414 mErrorMessage = 0; 1424 mErrorMessage = 0;
@@ -1464,13 +1474,14 @@ void KServerSocket::readBackFileFromSocket()
1464 QFile file ( fileName ); 1474 QFile file ( fileName );
1465 if (!file.open( IO_WriteOnly ) ) { 1475 if (!file.open( IO_WriteOnly ) ) {
1466 delete mSyncActionDialog; 1476 delete mSyncActionDialog;
1467 mSyncActionDialog = 0; 1477 mSyncActionDialog = 0;
1468 qDebug("KSS:Error open read back file "); 1478 qDebug("KSS:Error open read back file ");
1469 piFileString = ""; 1479 piFileString = "";
1470 emit file_received( false ); 1480 emit file_received( false, mResource);
1481 emit file_received( false);
1471 blockRC = false; 1482 blockRC = false;
1472 return ; 1483 return ;
1473 1484
1474 } 1485 }
1475 1486
1476 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1487 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
@@ -1480,13 +1491,14 @@ void KServerSocket::readBackFileFromSocket()
1480 ts << piFileString; 1491 ts << piFileString;
1481 mSocket->close(); 1492 mSocket->close();
1482 if ( mSocket->state() == QSocket::Idle ) 1493 if ( mSocket->state() == QSocket::Idle )
1483 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1494 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1484 file.close(); 1495 file.close();
1485 piFileString = ""; 1496 piFileString = "";
1486 emit file_received( true ); 1497 emit file_received( true, mResource );
1498 emit file_received( true);
1487 delete mSyncActionDialog; 1499 delete mSyncActionDialog;
1488 mSyncActionDialog = 0; 1500 mSyncActionDialog = 0;
1489 blockRC = false; 1501 blockRC = false;
1490 1502
1491} 1503}
1492 1504
@@ -1593,13 +1605,13 @@ void KCommandSocket::writeFileToSocket()
1593 mConnectProgress.setProgress( count ); 1605 mConnectProgress.setProgress( count );
1594 mConnectProgress.blockSignals( true ); 1606 mConnectProgress.blockSignals( true );
1595 QTextStream ts2( &file2 ); 1607 QTextStream ts2( &file2 );
1596 ts2.setEncoding( QTextStream::Latin1 ); 1608 ts2.setEncoding( QTextStream::Latin1 );
1597 QTextStream os2( mSocket ); 1609 QTextStream os2( mSocket );
1598 os2.setEncoding( QTextStream::Latin1 ); 1610 os2.setEncoding( QTextStream::Latin1 );
1599 os2 << "PUT " << mPassWord << "\r\n\r\n";; 1611 os2 << "PUT " << mPassWord << mRemoteResource << "\r\n\r\n";;
1600 int byteCount = 0; 1612 int byteCount = 0;
1601 int byteMax = file2.size()/53; 1613 int byteMax = file2.size()/53;
1602 while ( ! ts2.atEnd() ) { 1614 while ( ! ts2.atEnd() ) {
1603 qApp->processEvents(); 1615 qApp->processEvents();
1604 if ( byteCount > byteMax ) { 1616 if ( byteCount > byteMax ) {
1605 byteCount = 0; 1617 byteCount = 0;
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index f4654ce..53c611d 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -50,21 +50,24 @@ class KServerSocket : public QServerSocket
50 50
51 void newConnection ( int socket ) ; 51 void newConnection ( int socket ) ;
52 void setFileName( QString fn ) {mFileName = fn;}; 52 void setFileName( QString fn ) {mFileName = fn;};
53 signals: 53 signals:
54 void file_received( bool ); 54 void file_received( bool );
55 void request_file(); 55 void request_file();
56 void file_received( bool, const QString &);
57 void request_file(const QString &);
56 void saveFile(); 58 void saveFile();
57 void endConnect(); 59 void endConnect();
58 private slots: 60 private slots:
59 void discardClient(); 61 void discardClient();
60 void deleteSocket(); 62 void deleteSocket();
61 void readClient(); 63 void readClient();
62 void displayErrorMessage(); 64 void displayErrorMessage();
63 void readBackFileFromSocket(); 65 void readBackFileFromSocket();
64 private : 66 private :
67 QString mResource;
65 int mErrorMessage; 68 int mErrorMessage;
66 bool blockRC; 69 bool blockRC;
67 void send_file(); 70 void send_file();
68 void get_file(); 71 void get_file();
69 void end_connect(); 72 void end_connect();
70 void error_connect( QString ); 73 void error_connect( QString );
@@ -171,12 +174,15 @@ class KSyncManager : public QObject
171 static QDateTime mRequestedSyncEvent; 174 static QDateTime mRequestedSyncEvent;
172 175
173 signals: 176 signals:
174 void save(); 177 void save();
175 void request_file(); 178 void request_file();
176 void getFile( bool ); 179 void getFile( bool );
180 void getFile( bool, const QString &);
181 void request_file(const QString &);
182 void multiResourceSyncStart( bool );
177 183
178 public slots: 184 public slots:
179 void slotSyncMenu( int ); 185 void slotSyncMenu( int );
180 void slotClearMenu( int action ); 186 void slotClearMenu( int action );
181 void deleteCommandSocket(KCommandSocket*s, int state); 187 void deleteCommandSocket(KCommandSocket*s, int state);
182 void readFileFromSocket(); 188 void readFileFromSocket();