summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-25 17:41:25 (UTC)
committer zautrix <zautrix>2005-11-25 17:41:25 (UTC)
commit279e183c0325cd9565605f60af0215bb9bfdc825 (patch) (side-by-side diff)
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
@@ -368,2 +368,3 @@ void CalendarView::init()
{
+ mMultiResourceSync = false;
flag_blockConflict = false;
@@ -1554,2 +1555,3 @@ Event* CalendarView::getLastSyncEvent()
lse->setReadOnly( true );
+ lse->setCalID( 1 );
mCalendar->addEvent( lse );
@@ -1904,12 +1906,17 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
- eventLSync->setReadOnly( false );
- eventLSync->setDtStart( mLastCalendarSync );
- eventRSync->setDtStart( mLastCalendarSync );
- eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
- eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
- eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
- eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
- eventLSync->setReadOnly( true );
+ if ( mMultiResourceSync ) {
+ remote->removeSyncInfo( "" ); //all
+
+ } else {
+ eventLSync->setReadOnly( false );
+ eventLSync->setDtStart( mLastCalendarSync );
+ eventRSync->setDtStart( mLastCalendarSync );
+ eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
+ eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
+ eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
+ eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
+ eventLSync->setReadOnly( true );
+ }
qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
- if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
+ if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal...
remote->addEvent( eventRSync );
@@ -2437,2 +2444,28 @@ void CalendarView::mergeFile( QString fn )
}
+void CalendarView::mergeFileResource( QString fn ,QString resource )
+{
+
+ if ( resource == "ALL" ) {
+ mergeFile( fn );
+ return;
+ }
+
+ int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
+ if ( !exclusiveResource ) {
+ qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() );
+ return;
+ }
+ clearAllViews();
+ mCalendar->setCalendarRemove( exclusiveResource );
+ int def = mCalendar->defaultCalendar();
+ mCalendar->setDefaultCalendar(exclusiveResource);
+ if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) {
+ qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() );
+ }
+ mCalendar->setDefaultCalendar( def );
+ mCalendar->reInitAlarmSettings();
+ setSyncEventsReadOnly();
+ updateUnmanagedViews();
+ updateView();
+}
void CalendarView::showOpenError()
@@ -2524,2 +2557,3 @@ bool CalendarView::checkFileVersion(QString fn)
mSyncManager->mShowSyncSummary = false;
+ mMultiResourceSync = false;
syncCalendar( fn, 3 );
@@ -2560,2 +2594,19 @@ bool CalendarView::saveCalendars()
}
+bool CalendarView::saveCalendarResource(QString filename, QString resource)
+{
+ if ( resource == "ALL" )
+ return saveCalendar( filename );
+ int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
+ if ( !exclusiveResource ) {
+ qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() );
+ return false;
+ }
+ mCalendar->setDefaultCalendar( exclusiveResource );
+ mCalendar->setDefaultCalendarEnabledOnly();
+ mCalendar->setSyncEventsEnabled();
+ bool res = saveCalendar( filename );
+ restoreCalendarSettings();
+ return res;
+
+}
bool CalendarView::saveCalendar( QString filename )
@@ -5034,3 +5085,7 @@ void CalendarView::keyPressEvent ( QKeyEvent *e)
+void CalendarView::multiResourceSyncStart( bool start )
+{
+ mMultiResourceSync = start;
+}
bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource)
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index f85b6a3..60b1276 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -141,2 +141,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
void mergeFile( QString fn );
+ void mergeFileResource( QString fn ,QString res);
@@ -203,2 +204,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
public slots:
+ void multiResourceSyncStart( bool );
void displayCalendarInfo( int id );
@@ -248,2 +250,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
bool saveCalendar(QString filename);
+ bool saveCalendarResource(QString filename, QString resource);
@@ -541,2 +544,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
protected:
+ bool mMultiResourceSync;
Event *mConflictingEvent;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 66bb19b..69ccde1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -376,4 +376,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) :
connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
- connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
- connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
+ connect(mSyncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) );
+ connect(mSyncManager , SIGNAL( getFile( bool, const QString &)), this, SLOT(getFile( bool,const QString & ) ) );
+ connect(mSyncManager , SIGNAL( multiResourceSyncStart( bool )), mView, SLOT( multiResourceSyncStart( bool ) ) );
+
mSyncManager->setDefaultFileName( sentSyncFile());
@@ -2706,3 +2708,3 @@ QString MainWindow::sentSyncFile()
-void MainWindow::syncFileRequest()
+void MainWindow::syncFileRequest(const QString& resource)
{
@@ -2718,3 +2720,3 @@ void MainWindow::syncFileRequest()
setCaption(i18n("Saving Data to temp file ..." ));
- mView->saveCalendar( sentSyncFile() );
+ mView->saveCalendarResource( sentSyncFile(), resource );
setCaption(i18n("Data saved to temp file!" ));
@@ -2723,3 +2725,3 @@ void MainWindow::syncFileRequest()
}
-void MainWindow::getFile( bool success )
+void MainWindow::getFile( bool success ,const QString& resource)
{
@@ -2729,3 +2731,3 @@ void MainWindow::getFile( bool success )
}
- mView->mergeFile( sentSyncFile() );
+ mView->mergeFileResource( sentSyncFile(), resource);
if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index d8018b6..a533d8b 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -112,4 +112,4 @@ class MainWindow : public QMainWindow
void showConfigureAgenda();
- void getFile( bool );
- void syncFileRequest();
+ void getFile( bool ,const QString &);
+ void syncFileRequest(const QString &);
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4b8b3ff..0a94914 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -81,2 +81,3 @@ public:
virtual void setSyncEventsReadOnly() = 0;
+ virtual void setSyncEventsEnabled() = 0;
virtual void stopAllTodos() = 0;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 0ddfeca..45e3128 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -175,3 +175,3 @@ bool CalendarLocal::addCalendarFile( QString name, int id )
}
-void CalendarLocal::setSyncEventsReadOnly()
+void CalendarLocal::setSyncEventsEnabled()
{
@@ -181,3 +181,15 @@ void CalendarLocal::setSyncEventsReadOnly()
if ( ev->uid().left(15) == QString("last-syncEvent-") )
- ev->setReadOnly( true );
+ ev->setCalEnabled( true );
+ ev = mEventList.next();
+ }
+}
+void CalendarLocal::setSyncEventsReadOnly()
+{
+ Event * ev;
+ ev = mEventList.first();
+ while ( ev ) {
+ if ( ev->uid().left(15) == QString("last-syncEvent-") ) {
+ ev->setReadOnly( true );
+ ev->setCalID( 1 );
+ }
ev = mEventList.next();
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index ca0bd98..eb7bf34 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -51,2 +51,3 @@ class CalendarLocal : public Calendar
void setSyncEventsReadOnly();
+ void setSyncEventsEnabled();
void stopAllTodos();
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index a64eb34..719d80b 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -198,3 +198,4 @@ void KSyncManager::slotSyncMenu( int action )
qDebug("KSM::syncaction %d ", action);
- mCurrentResourceLocal = "";
+ mCurrentResourceLocal = "";
+ emit multiResourceSyncStart( false );
if ( action == 5000 )
@@ -443,2 +444,4 @@ void KSyncManager::enableQuick( bool ask )
connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
+ connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) );
+ connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) );
}
@@ -571,3 +574,3 @@ int KSyncManager::ringSync()
{
-
+ emit multiResourceSyncStart( false );
int syncedProfiles = 0;
@@ -1142,3 +1145,6 @@ void KSyncManager::syncPi()
int startRemote = mSpecificResources.count()/2;
+ emit multiResourceSyncStart( true );
while ( startLocal < mSpecificResources.count()/2 ) {
+ if ( startLocal+1 >= mSpecificResources.count()/2 )
+ emit multiResourceSyncStart( false );
mPisyncFinished = false;
@@ -1221,3 +1227,3 @@ void KSyncManager::readFileFromSocket()
}
- KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
+ KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
@@ -1285,2 +1291,3 @@ void KServerSocket::readClient()
}
+ mResource = "";
mErrorMessage = 0;
@@ -1301,2 +1308,3 @@ void KServerSocket::readClient()
KSyncManager::mRequestedSyncEvent = QDateTime();
+ mResource =tokens[3];
send_file();
@@ -1312,2 +1320,3 @@ void KServerSocket::readClient()
blockRC = true;
+ mResource =tokens[2];
get_file();
@@ -1408,2 +1417,3 @@ void KServerSocket::send_file()
mSyncActionDialog->raise();
+ emit request_file(mResource);
emit request_file();
@@ -1469,3 +1479,4 @@ void KServerSocket::readBackFileFromSocket()
piFileString = "";
- emit file_received( false );
+ emit file_received( false, mResource);
+ emit file_received( false);
blockRC = false;
@@ -1485,3 +1496,4 @@ void KServerSocket::readBackFileFromSocket()
piFileString = "";
- emit file_received( true );
+ emit file_received( true, mResource );
+ emit file_received( true);
delete mSyncActionDialog;
@@ -1598,3 +1610,3 @@ void KCommandSocket::writeFileToSocket()
os2.setEncoding( QTextStream::Latin1 );
- os2 << "PUT " << mPassWord << "\r\n\r\n";;
+ os2 << "PUT " << mPassWord << mRemoteResource << "\r\n\r\n";;
int byteCount = 0;
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index f4654ce..53c611d 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -55,2 +55,4 @@ class KServerSocket : public QServerSocket
void request_file();
+ void file_received( bool, const QString &);
+ void request_file(const QString &);
void saveFile();
@@ -64,2 +66,3 @@ class KServerSocket : public QServerSocket
private :
+ QString mResource;
int mErrorMessage;
@@ -176,2 +179,5 @@ class KSyncManager : public QObject
void getFile( bool );
+ void getFile( bool, const QString &);
+ void request_file(const QString &);
+ void multiResourceSyncStart( bool );