summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-25 15:49:13 (UTC)
committer zautrix <zautrix>2005-11-25 15:49:13 (UTC)
commit794a5204686ad9bfc16172b01db35f1f3b7683e5 (patch) (side-by-side diff)
tree29da2cb35a4d6a0cd6885436087fe0659b58a9f4
parent90b62d1158d00f162a258541e24aaed4c967480b (diff)
downloadkdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.zip
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.gz
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.bz2
sync
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp2
-rw-r--r--kaddressbook/kabcore.h2
-rw-r--r--korganizer/calendarview.cpp19
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/koprefs.cpp10
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--libkdepim/ksyncmanager.cpp47
-rw-r--r--libkdepim/ksyncmanager.h8
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
9 files changed, 78 insertions, 19 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 033e537..2dea619 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -3307,3 +3307,3 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
//this is a overwritten callbackmethods from the syncinterface
-bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
+bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource)
{
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 42b7709..c4a0b3b 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -514,3 +514,3 @@ class KABCore : public QWidget, public KSyncInterface
//this are the overwritten callbackmethods from the syncinterface
- virtual bool sync(KSyncManager* manager, QString filename, int mode);
+ virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
virtual bool syncExternal(KSyncManager* manager, QString resource);
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 31e103d..8965d3b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1980,3 +1980,2 @@ void CalendarView::syncExternal( int mode )
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
-
qApp->processEvents();
@@ -5036,3 +5035,3 @@ void CalendarView::keyPressEvent ( QKeyEvent *e)
-bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
+bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource)
{
@@ -5046,3 +5045,17 @@ bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
mCurrentSyncName = mSyncManager->getCurrentSyncName();
- return syncCalendar( filename, mode );
+ if ( !resource.isEmpty() ) {
+ int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
+ qDebug( "KO: Sync request for resource: %s", resource.latin1() );
+
+ if ( !exclusiveSyncResource ) {
+ qDebug( "KO: Requested sync resource not found: %s", resource.latin1() );
+ return false;
+ }
+ mCalendar->setDefaultCalendar( exclusiveSyncResource );
+ mCalendar->setDefaultCalendarEnabledOnly();
+ }
+ bool result = syncCalendar( filename, mode );
+ if ( !resource.isEmpty() )
+ restoreCalendarSettings();
+ return result;
}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 80f7ed4..f85b6a3 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -520,3 +520,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
int msgCalModified();
- virtual bool sync(KSyncManager* manager, QString filename, int mode);
+ virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource);
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 1b0e5f4..31ef338 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -530,2 +530,12 @@ int KOPrefs::getCalendarID( const QString & name )
}
+int KOPrefs::getFuzzyCalendarID( const QString & name )
+{
+ KopiCalendarFile * kkf = mCalendars.first();
+ while ( kkf ) {
+ if ( name.lower() == kkf->mName.lower())
+ return kkf->mCalNumber;
+ kkf = mCalendars.next();
+ }
+ return 0;
+}
QString KOPrefs::calName( int calNum) const
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index bac8010..70da096 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -107,2 +107,3 @@ class KOPrefs : public KPimPrefs
int getCalendarID( const QString & name );
+ int getFuzzyCalendarID( const QString & name );
protected:
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d71264f..a64eb34 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -198,2 +198,3 @@ void KSyncManager::slotSyncMenu( int action )
qDebug("KSM::syncaction %d ", action);
+ mCurrentResourceLocal = "";
if ( action == 5000 )
@@ -315,3 +316,4 @@ void KSyncManager::slotSyncMenu( int action )
syncPhone();
- } else if ( temp->getIsPiSync() ) {
+ } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
+ mSpecificResources.clear();
if ( mTargetApp == KAPI ) {
@@ -321,2 +323,4 @@ void KSyncManager::slotSyncMenu( int action )
} else if ( mTargetApp == KOPI ) {
+ if ( temp->getIsPiSyncSpec() )
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
mPassWordPiSync = temp->getRemotePw();
@@ -505,3 +509,3 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
//qDebug("Now sycing ... ");
- if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
+ if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
@@ -529,2 +533,3 @@ void KSyncManager::multiSync( bool askforPrefs )
setBlockSave(true);
+ mCurrentResourceLocal = "";
if ( askforPrefs ) {
@@ -574,2 +579,3 @@ int KSyncManager::ringSync()
mAskForPreferences = false;
+ mCurrentResourceLocal = "";
for ( i = 0; i < syncProfileNames.count(); ++i ) {
@@ -651,3 +657,4 @@ int KSyncManager::ringSync()
syncPhone();
- } else if ( temp->getIsPiSync() ) {
+ } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
+ mSpecificResources.clear();
if ( mTargetApp == KAPI ) {
@@ -657,2 +664,3 @@ int KSyncManager::ringSync()
} else if ( mTargetApp == KOPI ) {
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
mPassWordPiSync = temp->getRemotePw();
@@ -1129,3 +1137,22 @@ void KSyncManager::syncPi()
}
- KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
+ mCurrentResourceLocal = "";
+ mCurrentResourceRemote = "";
+ if ( mSpecificResources.count() ) {
+ int startLocal = 0;
+ int startRemote = mSpecificResources.count()/2;
+ while ( startLocal < mSpecificResources.count()/2 ) {
+ mPisyncFinished = false;
+ mCurrentResourceLocal = mSpecificResources[ startLocal ];
+ mCurrentResourceRemote = mSpecificResources[ startRemote ];
+ KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
+ connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
+ commandSocket->readFile( syncFileName() );
+ while ( !mPisyncFinished ) {
+ //qDebug("waiting ");
+ qApp->processEvents();
+ }
+ ++startLocal;
+ }
+ } else {
+ KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
@@ -1133,2 +1160,3 @@ void KSyncManager::syncPi()
}
+}
@@ -1156,3 +1184,3 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
if ( state == KCommandSocket::errorR ) {
- KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
+ KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
@@ -1193,3 +1221,3 @@ void KSyncManager::readFileFromSocket()
}
- KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
+ KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
@@ -1464,4 +1492,7 @@ void KServerSocket::readBackFileFromSocket()
-KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
+KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
{
+ mRemoteResource = remres;
+ if ( mRemoteResource.isEmpty() )
+ mRemoteResource = "ALL";
mPassWord = password;
@@ -1492,3 +1523,3 @@ void KCommandSocket::sendFileRequest()
QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
- os << "GET " << mPassWord << curDt <<"\r\n\r\n";
+ os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n";
}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index d3734da..f4654ce 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -83,3 +83,3 @@ class KCommandSocket : public QObject
enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet };
- KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
+ KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
void readFile( QString );
@@ -100,2 +100,3 @@ class KCommandSocket : public QObject
private :
+ QString mRemoteResource;
int mConnectCount;
@@ -204,2 +205,5 @@ class KSyncManager : public QObject
bool mPisyncFinished;
+ QStringList mSpecificResources;
+ QString mCurrentResourceLocal;
+ QString mCurrentResourceRemote;
bool mBlockSaveFlag;
@@ -224,3 +228,3 @@ class KSyncInterface
virtual void removeSyncInfo( QString syncProfile) = 0;
- virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
+ virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
virtual bool syncExternal(KSyncManager* manager, QString resource)
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 292cde1..27f7932 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -594,4 +594,4 @@ void KSyncPrefsDialog::profileChanged( int item )
QStringList res = QStringList::split( ":",prof->getResSpecKopi());
- int i;
- for ( i = 0;i < res.count(); ++i ) {
+ int i= res.count()/2;
+ for ( ;i < res.count(); ++i ) {
mResTableKopi->setText( i, 0, res[i] );
@@ -754,3 +754,3 @@ void KSyncPrefsDialog::saveProfile()
- QStringList res;
+ QStringList res = mResourcesKopi;
int i;