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) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp57
-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.cpp14
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkdepim/ksyncmanager.cpp18
-rw-r--r--libkdepim/ksyncmanager.h6
9 files changed, 106 insertions, 13 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8965d3b..307027a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -367,4 +367,5 @@ CalendarView::CalendarView( Calendar *calendar,
void CalendarView::init()
{
+ mMultiResourceSync = false;
flag_blockConflict = false;
flag_blockScrollBar = false;
@@ -1553,4 +1554,5 @@ Event* CalendarView::getLastSyncEvent()
lse->setCategories( i18n("SyncEvent") );
lse->setReadOnly( true );
+ lse->setCalID( 1 );
mCalendar->addEvent( lse );
}
@@ -1903,4 +1905,8 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
bar.hide();
mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
+ if ( mMultiResourceSync ) {
+ remote->removeSyncInfo( "" ); //all
+
+ } else {
eventLSync->setReadOnly( false );
eventLSync->setDtStart( mLastCalendarSync );
@@ -1911,6 +1917,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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 );
else
@@ -2436,4 +2443,30 @@ void CalendarView::mergeFile( QString fn )
updateView();
}
+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()
{
@@ -2523,4 +2556,5 @@ bool CalendarView::checkFileVersion(QString fn)
mSyncManager->mWriteBackExistingOnly = false;
mSyncManager->mShowSyncSummary = false;
+ mMultiResourceSync = false;
syncCalendar( fn, 3 );
Event * e = getLastSyncEvent();
@@ -2559,4 +2593,21 @@ bool CalendarView::saveCalendars()
return true;
}
+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 )
{
@@ -5033,5 +5084,9 @@ 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
@@ -140,4 +140,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
void checkSuspendAlarm();
void mergeFile( QString fn );
+ void mergeFileResource( QString fn ,QString res);
signals:
@@ -202,4 +203,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
public slots:
+ void multiResourceSyncStart( bool );
void displayCalendarInfo( int id );
void nextConflict( bool all, bool allday );
@@ -247,4 +249,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
*/
bool saveCalendar(QString filename);
+ bool saveCalendarResource(QString filename, QString resource);
/**
@@ -540,4 +543,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
protected:
+ bool mMultiResourceSync;
Event *mConflictingEvent;
void schedule(Scheduler::Method, Incidence *incidence = 0);
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 66bb19b..69ccde1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -375,6 +375,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) :
connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
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());
connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
@@ -2705,5 +2707,5 @@ QString MainWindow::sentSyncFile()
}
-void MainWindow::syncFileRequest()
+void MainWindow::syncFileRequest(const QString& resource)
{
while ( mSyncManager->blockSave() ) {
@@ -2717,10 +2719,10 @@ void MainWindow::syncFileRequest()
setCaption(i18n("Saving Data to temp file ..." ));
- mView->saveCalendar( sentSyncFile() );
+ mView->saveCalendarResource( sentSyncFile(), resource );
setCaption(i18n("Data saved to temp file!" ));
mSyncManager->setBlockSave( false );
}
-void MainWindow::getFile( bool success )
+void MainWindow::getFile( bool success ,const QString& resource)
{
if ( ! success ) {
@@ -2728,5 +2730,5 @@ void MainWindow::getFile( bool success )
return;
}
- mView->mergeFile( sentSyncFile() );
+ mView->mergeFileResource( sentSyncFile(), resource);
if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
mSyncManager->slotSyncMenu( 999 );
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index d8018b6..a533d8b 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -111,6 +111,6 @@ class MainWindow : public QMainWindow
void slotResetFocusLoop();
void showConfigureAgenda();
- void getFile( bool );
- void syncFileRequest();
+ void getFile( bool ,const QString &);
+ void syncFileRequest(const QString &);
protected:
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4b8b3ff..0a94914 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -80,4 +80,5 @@ public:
virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0;
virtual void setSyncEventsReadOnly() = 0;
+ virtual void setSyncEventsEnabled() = 0;
virtual void stopAllTodos() = 0;
virtual void clearUndo( Incidence * newUndo );
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 0ddfeca..45e3128 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -174,5 +174,5 @@ bool CalendarLocal::addCalendarFile( QString name, int id )
return false;
}
-void CalendarLocal::setSyncEventsReadOnly()
+void CalendarLocal::setSyncEventsEnabled()
{
Event * ev;
@@ -180,5 +180,17 @@ void CalendarLocal::setSyncEventsReadOnly()
while ( ev ) {
if ( ev->uid().left(15) == QString("last-syncEvent-") )
+ 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
@@ -50,4 +50,5 @@ class CalendarLocal : public Calendar
Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates );
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,4 +198,5 @@ void KSyncManager::slotSyncMenu( int action )
qDebug("KSM::syncaction %d ", action);
mCurrentResourceLocal = "";
+ emit multiResourceSyncStart( false );
if ( action == 5000 )
return;
@@ -442,4 +443,6 @@ void KSyncManager::enableQuick( bool ask )
connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
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 & ) ) );
}
void KSyncManager::displayErrorPort()
@@ -570,5 +573,5 @@ void KSyncManager::multiSync( bool askforPrefs )
int KSyncManager::ringSync()
{
-
+ emit multiResourceSyncStart( false );
int syncedProfiles = 0;
unsigned int i;
@@ -1141,5 +1144,8 @@ void KSyncManager::syncPi()
int startLocal = 0;
int startRemote = mSpecificResources.count()/2;
+ emit multiResourceSyncStart( true );
while ( startLocal < mSpecificResources.count()/2 ) {
+ if ( startLocal+1 >= mSpecificResources.count()/2 )
+ emit multiResourceSyncStart( false );
mPisyncFinished = false;
mCurrentResourceLocal = mSpecificResources[ startLocal ];
@@ -1220,5 +1226,5 @@ void KSyncManager::readFileFromSocket()
syncOK = false;
}
- 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 )) );
if ( mWriteBackFile && syncOK ) {
@@ -1284,4 +1290,5 @@ void KServerSocket::readClient()
return;
}
+ mResource = "";
mErrorMessage = 0;
//qDebug("KServerSocket::readClient()");
@@ -1300,4 +1307,5 @@ void KServerSocket::readClient()
else
KSyncManager::mRequestedSyncEvent = QDateTime();
+ mResource =tokens[3];
send_file();
}
@@ -1311,4 +1319,5 @@ void KServerSocket::readClient()
//emit getFile( mSocket );
blockRC = true;
+ mResource =tokens[2];
get_file();
}
@@ -1407,4 +1416,5 @@ void KServerSocket::send_file()
mSyncActionDialog->show();
mSyncActionDialog->raise();
+ emit request_file(mResource);
emit request_file();
qApp->processEvents();
@@ -1468,4 +1478,5 @@ void KServerSocket::readBackFileFromSocket()
qDebug("KSS:Error open read back file ");
piFileString = "";
+ emit file_received( false, mResource);
emit file_received( false );
blockRC = false;
@@ -1484,4 +1495,5 @@ void KServerSocket::readBackFileFromSocket()
file.close();
piFileString = "";
+ emit file_received( true, mResource );
emit file_received( true );
delete mSyncActionDialog;
@@ -1597,5 +1609,5 @@ void KCommandSocket::writeFileToSocket()
QTextStream os2( mSocket );
os2.setEncoding( QTextStream::Latin1 );
- os2 << "PUT " << mPassWord << "\r\n\r\n";;
+ os2 << "PUT " << mPassWord << mRemoteResource << "\r\n\r\n";;
int byteCount = 0;
int byteMax = file2.size()/53;
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index f4654ce..53c611d 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -54,4 +54,6 @@ class KServerSocket : public QServerSocket
void file_received( bool );
void request_file();
+ void file_received( bool, const QString &);
+ void request_file(const QString &);
void saveFile();
void endConnect();
@@ -63,4 +65,5 @@ class KServerSocket : public QServerSocket
void readBackFileFromSocket();
private :
+ QString mResource;
int mErrorMessage;
bool blockRC;
@@ -175,4 +178,7 @@ class KSyncManager : public QObject
void request_file();
void getFile( bool );
+ void getFile( bool, const QString &);
+ void request_file(const QString &);
+ void multiResourceSyncStart( bool );
public slots: