summaryrefslogtreecommitdiffabout
path: root/libkdepim
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 /libkdepim
parent90b62d1158d00f162a258541e24aaed4c967480b (diff)
downloadkdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.zip
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.gz
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.bz2
sync
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp51
-rw-r--r--libkdepim/ksyncmanager.h8
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
3 files changed, 50 insertions, 15 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d71264f..a64eb34 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -193,12 +193,13 @@ void KSyncManager::slotClearMenu( int action )
return;
mImplementation->removeSyncInfo( syncDevice );
}
void KSyncManager::slotSyncMenu( int action )
{
qDebug("KSM::syncaction %d ", action);
+ mCurrentResourceLocal = "";
if ( action == 5000 )
return;
mSyncWithDesktop = false;
if ( action == 0 ) {
// seems to be a Qt2 event handling bug
@@ -310,18 +311,21 @@ void KSyncManager::slotSyncMenu( int action )
} else {
if ( temp->getIsPhoneSync() ) {
mPhoneDevice = temp->getPhoneDevice( ) ;
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
- } else if ( temp->getIsPiSync() ) {
+ } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
+ mSpecificResources.clear();
if ( mTargetApp == KAPI ) {
mPassWordPiSync = temp->getRemotePwAB();
mActiveSyncPort = temp->getRemotePortAB();
mActiveSyncIP = temp->getRemoteIPAB();
} else if ( mTargetApp == KOPI ) {
+ if ( temp->getIsPiSyncSpec() )
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
mActiveSyncIP = temp->getRemoteIP();
} else {
mPassWordPiSync = temp->getRemotePwPWM();
mActiveSyncPort = temp->getRemotePortPWM();
@@ -500,13 +504,13 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
if ( !edit_sync_options()) {
mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
return false;
}
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
mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
if ( ! quick )
mPrefs->mLastSyncedLocalFile = fn;
}
@@ -524,12 +528,13 @@ void KSyncManager::quickSyncLocalFile()
void KSyncManager::multiSync( bool askforPrefs )
{
if (blockSave())
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!");
if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
question,
i18n("Yes"), i18n("No"),
0, 0 ) != 0 ) {
@@ -569,12 +574,13 @@ int KSyncManager::ringSync()
unsigned int i;
QTime timer;
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
QStringList syncProfileNames = mSyncProfileNames;
KSyncProfile* temp = new KSyncProfile ();
mAskForPreferences = false;
+ mCurrentResourceLocal = "";
for ( i = 0; i < syncProfileNames.count(); ++i ) {
mCurrentSyncProfile = i;
temp->setName(syncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
bool includeInRingSync = false;
@@ -646,18 +652,20 @@ int KSyncManager::ringSync()
} else {
if ( temp->getIsPhoneSync() ) {
mPhoneDevice = temp->getPhoneDevice( ) ;
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
- } else if ( temp->getIsPiSync() ) {
+ } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
+ mSpecificResources.clear();
if ( mTargetApp == KAPI ) {
mPassWordPiSync = temp->getRemotePwAB();
mActiveSyncPort = temp->getRemotePortAB();
mActiveSyncIP = temp->getRemoteIPAB();
} else if ( mTargetApp == KOPI ) {
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
mActiveSyncIP = temp->getRemoteIP();
} else {
mPassWordPiSync = temp->getRemotePwPWM();
mActiveSyncPort = temp->getRemotePortPWM();
@@ -1124,15 +1132,35 @@ void KSyncManager::syncPi()
Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
if ( ! ok ) {
mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
mPisyncFinished = true;
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() );
+ }
}
void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
{
//enum { success, errorW, errorR, quiet };
@@ -1151,13 +1179,13 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
else if ( state == KCommandSocket::errorED )
mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
else if ( state == KCommandSocket::errorUN )
mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
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();
}
mPisyncFinished = true;
return;
@@ -1188,13 +1216,13 @@ void KSyncManager::readFileFromSocket()
bool syncOK = true;
mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
if ( ! syncWithFile( fileName , true ) ) {
mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
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 ) {
mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
commandSocket->writeFile( fileName );
}
else {
@@ -1459,14 +1487,17 @@ void KServerSocket::readBackFileFromSocket()
delete mSyncActionDialog;
mSyncActionDialog = 0;
blockRC = false;
}
-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;
mFirst = false;
mFirstLine = true;
mPort = port;
mHost = host;
@@ -1487,13 +1518,13 @@ void KCommandSocket::sendFileRequest()
mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
mTimerSocket->start( 100, true );
QTextStream os( mSocket );
os.setEncoding( QTextStream::Latin1 );
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";
}
void KCommandSocket::readFile( QString fn )
{
if ( !mSocket ) {
mSocket = new QSocket( this );
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index d3734da..f4654ce 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -78,13 +78,13 @@ class KServerSocket : public QServerSocket
class KCommandSocket : public QObject
{
Q_OBJECT
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 );
void sendStop();
private slots :
void sendFileRequest();
@@ -95,12 +95,13 @@ class KCommandSocket : public QObject
private slots:
void startReadFileFromSocket();
void readFileFromSocket();
void deleteSocket();
void writeFileToSocket();
private :
+ QString mRemoteResource;
int mConnectCount;
int mConnectMax;
KProgressDialog mConnectProgress;
QWidget* tlw;
QSocket* mSocket;
QString mPassWord;
@@ -199,12 +200,15 @@ class KSyncManager : public QObject
void syncRemote( KSyncProfile* prof, bool ask = true);
bool edit_sync_options();
bool edit_pisync_options();
int ringSync();
QString getPassword( );
bool mPisyncFinished;
+ QStringList mSpecificResources;
+ QString mCurrentResourceLocal;
+ QString mCurrentResourceRemote;
bool mBlockSaveFlag;
QWidget* mParent;
KSyncInterface* mImplementation;
TargetApp mTargetApp;
QPopupMenu* mSyncMenu;
QProgressBar* bar;
@@ -219,13 +223,13 @@ private slots:
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)
{
// empty implementation, because some syncable applications do not
// have an external(sharpdtm) syncmode, like pwmanager.
return false;
}
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 292cde1..27f7932 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -589,14 +589,14 @@ void KSyncPrefsDialog::profileChanged( int item )
mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ;
mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
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] );
}
res = QStringList::split( ":",prof->getResSpecKapi());
for ( i = 0;i < res.count(); ++i ) {
mResTableKapi->setText( i, 0, res[i] );
}
@@ -749,13 +749,13 @@ void KSyncPrefsDialog::saveProfile()
prof->setFilterInCal ( mFilterInCal->currentText ());
prof->setFilterOutCal ( mFilterOutCal ->currentText ());
prof->setFilterInAB ( mFilterInAB ->currentText ());
prof->setFilterOutAB ( mFilterOutAB ->currentText ());
if ( mIsPiSpecific->isChecked() ) {
- QStringList res;
+ QStringList res = mResourcesKopi;
int i;
for ( i = 0;i < mResourcesKopi.count(); ++i ) {
res.append( mResTableKopi->text( i, 0 ));
}
prof->setResSpecKopi( res.join(":"));
}