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) (ignore 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.cpp51
-rw-r--r--libkdepim/ksyncmanager.h8
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
9 files changed, 80 insertions, 21 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 033e537..2dea619 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -3306,5 +3306,5 @@ 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
@@ -513,5 +513,5 @@ 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);
virtual void removeSyncInfo( QString syncProfile);
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 31e103d..8965d3b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1979,5 +1979,4 @@ void CalendarView::syncExternal( int mode )
{
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
-
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
@@ -5035,5 +5034,5 @@ 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)
{
@@ -5045,5 +5044,19 @@ bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
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;
}
bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 80f7ed4..f85b6a3 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -519,5 +519,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
// returns KMsgBox::yesNoCancel()
int msgCalModified();
- 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/koprefs.cpp b/korganizer/koprefs.cpp
index 1b0e5f4..31ef338 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -529,4 +529,14 @@ int KOPrefs::getCalendarID( const QString & name )
return 1;
}
+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
@@ -106,4 +106,5 @@ class KOPrefs : public KPimPrefs
QString calName( int ) const;
int getCalendarID( const QString & name );
+ int getFuzzyCalendarID( const QString & name );
protected:
void setTimeZoneIdDefault();
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d71264f..a64eb34 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -197,4 +197,5 @@ void KSyncManager::slotSyncMenu( int action )
{
qDebug("KSM::syncaction %d ", action);
+ mCurrentResourceLocal = "";
if ( action == 5000 )
return;
@@ -314,5 +315,6 @@ void KSyncManager::slotSyncMenu( int action )
mPhoneModel = temp->getPhoneModel( );
syncPhone();
- } else if ( temp->getIsPiSync() ) {
+ } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
+ mSpecificResources.clear();
if ( mTargetApp == KAPI ) {
mPassWordPiSync = temp->getRemotePwAB();
@@ -320,4 +322,6 @@ void KSyncManager::slotSyncMenu( int action )
mActiveSyncIP = temp->getRemoteIPAB();
} else if ( mTargetApp == KOPI ) {
+ if ( temp->getIsPiSyncSpec() )
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
@@ -504,5 +508,5 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
if ( result == 0 ) {
//qDebug("Now sycing ... ");
- if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
+ if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
else
@@ -528,4 +532,5 @@ void KSyncManager::multiSync( bool askforPrefs )
return;
setBlockSave(true);
+ mCurrentResourceLocal = "";
if ( askforPrefs ) {
QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
@@ -573,4 +578,5 @@ int KSyncManager::ringSync()
KSyncProfile* temp = new KSyncProfile ();
mAskForPreferences = false;
+ mCurrentResourceLocal = "";
for ( i = 0; i < syncProfileNames.count(); ++i ) {
mCurrentSyncProfile = i;
@@ -650,5 +656,6 @@ int KSyncManager::ringSync()
mPhoneModel = temp->getPhoneModel( );
syncPhone();
- } else if ( temp->getIsPiSync() ) {
+ } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
+ mSpecificResources.clear();
if ( mTargetApp == KAPI ) {
mPassWordPiSync = temp->getRemotePwAB();
@@ -656,4 +663,5 @@ int KSyncManager::ringSync()
mActiveSyncIP = temp->getRemoteIPAB();
} else if ( mTargetApp == KOPI ) {
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
@@ -1128,7 +1136,27 @@ void KSyncManager::syncPi()
return;
}
- KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
- connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
- commandSocket->readFile( syncFileName() );
+ 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)) );
+ commandSocket->readFile( syncFileName() );
+ }
}
@@ -1155,5 +1183,5 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
delete s;
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 )) );
commandSocket->sendStop();
@@ -1192,5 +1220,5 @@ void KSyncManager::readFileFromSocket()
syncOK = false;
}
- 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 )) );
if ( mWriteBackFile && syncOK ) {
@@ -1463,6 +1491,9 @@ 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;
mSocket = 0;
@@ -1491,5 +1522,5 @@ 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
@@ -82,5 +82,5 @@ class KCommandSocket : public QObject
public:
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 );
void writeFile( QString );
@@ -99,4 +99,5 @@ class KCommandSocket : public QObject
void writeFileToSocket();
private :
+ QString mRemoteResource;
int mConnectCount;
int mConnectMax;
@@ -203,4 +204,7 @@ class KSyncManager : public QObject
QString getPassword( );
bool mPisyncFinished;
+ QStringList mSpecificResources;
+ QString mCurrentResourceLocal;
+ QString mCurrentResourceRemote;
bool mBlockSaveFlag;
QWidget* mParent;
@@ -223,5 +227,5 @@ class KSyncInterface
public :
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
@@ -593,6 +593,6 @@ 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] );
}
@@ -753,5 +753,5 @@ void KSyncPrefsDialog::saveProfile()
if ( mIsPiSpecific->isChecked() ) {
- QStringList res;
+ QStringList res = mResourcesKopi;
int i;
for ( i = 0;i < mResourcesKopi.count(); ++i ) {