summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-25 18:35:16 (UTC)
committer zautrix <zautrix>2005-11-25 18:35:16 (UTC)
commit231e6f8215bbc4f7e301965f8f3c650e44586ec9 (patch) (side-by-side diff)
tree4c221ec7ac9909b5f0d192c68558739b4dcc1f48
parent279e183c0325cd9565605f60af0215bb9bfdc825 (diff)
downloadkdepimpi-231e6f8215bbc4f7e301965f8f3c650e44586ec9.zip
kdepimpi-231e6f8215bbc4f7e301965f8f3c650e44586ec9.tar.gz
kdepimpi-231e6f8215bbc4f7e301965f8f3c650e44586ec9.tar.bz2
sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp27
-rw-r--r--libkdepim/ksyncprefsdialog.cpp16
-rw-r--r--libkdepim/ksyncprofile.cpp2
3 files changed, 29 insertions, 16 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 719d80b..61a9899 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -230,193 +230,193 @@ void KSyncManager::slotSyncMenu( int action )
if (blockSave())
return;
setBlockSave(true);
bool silent = false;
if ( action == 999 ) {
//special mode for silent syncing
action = 1000;
silent = true;
}
mCurrentSyncProfile = action - 1000 ;
mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
mCurrentSyncName = mLocalMachineName ;
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
KSyncProfile* temp = new KSyncProfile ();
temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
if (silent) {
mAskForPreferences = false;
mShowSyncSummary = false;
mWriteBackFile = true;
mSyncAlgoPrefs = 2;// take newest
}
else {
mAskForPreferences = temp->getAskForPreferences();
mShowSyncSummary = temp->getShowSummaryAfterSync();
mWriteBackFile = temp->getWriteBackFile();
mSyncAlgoPrefs = temp->getSyncPrefs();
}
mWriteBackExistingOnly = temp->getWriteBackExisting();
mIsKapiFile = temp->getIsKapiFile();
mWriteBackInFuture = 0;
if ( temp->getWriteBackFuture() ) {
mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
mWriteBackInPast = temp->getWriteBackPastWeeks( );
}
mFilterInCal = temp->getFilterInCal();
mFilterOutCal = temp->getFilterOutCal();
mFilterInAB = temp->getFilterInAB();
mFilterOutAB = temp->getFilterOutAB();
if ( action == 1000 ) {
mIsKapiFile = false;
#ifdef DESKTOP_VERSION
syncKDE();
#else
syncSharp();
#endif
} else if ( action == 1001 ) {
syncLocalFile();
} else if ( action == 1002 ) {
mWriteBackFile = false;
mAskForPreferences = false;
mShowSyncSummary = false;
mSyncAlgoPrefs = 3;
quickSyncLocalFile();
} else if ( action >= 1003 ) {
if ( temp->getIsLocalFileSync() ) {
switch(mTargetApp)
{
case (KAPI):
if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
break;
case (KOPI):
if ( syncWithFile( temp->getRemoteFileName( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
break;
case (PWMPI):
if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
break;
default:
qDebug("KSM::slotSyncMenu: invalid apptype selected");
break;
}
} else {
if ( temp->getIsPhoneSync() ) {
mPhoneDevice = temp->getPhoneDevice( ) ;
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
} 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() );
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
mActiveSyncIP = temp->getRemoteIP();
} else {
mPassWordPiSync = temp->getRemotePwPWM();
mActiveSyncPort = temp->getRemotePortPWM();
mActiveSyncIP = temp->getRemoteIPPWM();
}
syncPi();
while ( !mPisyncFinished ) {
//qDebug("waiting ");
qApp->processEvents();
}
} else
syncRemote( temp );
}
}
delete temp;
setBlockSave(false);
}
void KSyncManager::enableQuick( bool ask )
{
bool autoStart;
bool changed = false;
if ( ask ) {
QDialog dia ( 0, "input-dialog", true );
QLineEdit lab ( &dia );
QVBoxLayout lay( &dia );
lab.setText( mPrefs->mPassiveSyncPort );
lay.setMargin(7);
lay.setSpacing(7);
int po = 9197+mTargetApp;
QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
lay.addWidget( &label);
lay.addWidget( &lab);
QLineEdit lepw ( &dia );
lepw.setText( mPrefs->mPassiveSyncPw );
QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
lay.addWidget( &label2);
lay.addWidget( &lepw);
QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
lay.addWidget( &autostart);
autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
#ifdef DESKTOP_VERSION
#ifdef _WIN32_
QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
syncdesktop.hide();// not implemented!
#else
QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
#endif
lay.addWidget( &syncdesktop);
#else
mPrefs->mPassiveSyncWithDesktop = false;
QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
syncdesktop.hide();
#endif
syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
QPushButton pb ( "OK", &dia);
lay.addWidget( &pb );
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
dia.resize( 230,120 );
dia.setCaption( i18n("Enter port for Pi-Sync") );
dia.show();
#ifndef DESKTOP_VERSION
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
#endif
if ( ! dia.exec() )
return;
dia.hide();
qApp->processEvents();
if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
changed = true;
mPrefs->mPassiveSyncPw = lepw.text();
}
if ( mPrefs->mPassiveSyncPort != lab.text() ) {
mPrefs->mPassiveSyncPort = lab.text();
changed = true;
}
autoStart = autostart.isChecked();
if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
changed = true;
mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
}
}
else
autoStart = mPrefs->mPassiveSyncAutoStart;
if ( autoStart != mPrefs->mPassiveSyncAutoStart )
changed = true;
bool ok;
mPrefs->mPassiveSyncAutoStart = false;
@@ -572,193 +572,193 @@ void KSyncManager::multiSync( bool askforPrefs )
int KSyncManager::ringSync()
{
emit multiResourceSyncStart( false );
int syncedProfiles = 0;
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;
switch(mTargetApp)
{
case (KAPI):
includeInRingSync = temp->getIncludeInRingSyncAB();
break;
case (KOPI):
includeInRingSync = temp->getIncludeInRingSync();
break;
case (PWMPI):
includeInRingSync = temp->getIncludeInRingSyncPWM();
break;
default:
qDebug("KSM::ringSync: invalid apptype selected");
break;
}
if ( includeInRingSync && ( i < 1 || i > 2 )) {
mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
++syncedProfiles;
mSyncWithDesktop = false;
// mAskForPreferences = temp->getAskForPreferences();
mWriteBackFile = temp->getWriteBackFile();
mWriteBackExistingOnly = temp->getWriteBackExisting();
mIsKapiFile = temp->getIsKapiFile();
mWriteBackInFuture = 0;
if ( temp->getWriteBackFuture() ) {
mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
mWriteBackInPast = temp->getWriteBackPastWeeks( );
}
mFilterInCal = temp->getFilterInCal();
mFilterOutCal = temp->getFilterOutCal();
mFilterInAB = temp->getFilterInAB();
mFilterOutAB = temp->getFilterOutAB();
mShowSyncSummary = false;
mCurrentSyncDevice = syncProfileNames[i] ;
mCurrentSyncName = mLocalMachineName;
if ( i == 0 ) {
mIsKapiFile = false;
#ifdef DESKTOP_VERSION
syncKDE();
#else
syncSharp();
#endif
} else {
if ( temp->getIsLocalFileSync() ) {
switch(mTargetApp)
{
case (KAPI):
if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
break;
case (KOPI):
if ( syncWithFile( temp->getRemoteFileName( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
break;
case (PWMPI):
if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
break;
default:
qDebug("KSM: invalid apptype selected");
break;
}
} else {
if ( temp->getIsPhoneSync() ) {
mPhoneDevice = temp->getPhoneDevice( ) ;
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
} 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() );
+ mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
mPassWordPiSync = temp->getRemotePw();
mActiveSyncPort = temp->getRemotePort();
mActiveSyncIP = temp->getRemoteIP();
} else {
mPassWordPiSync = temp->getRemotePwPWM();
mActiveSyncPort = temp->getRemotePortPWM();
mActiveSyncIP = temp->getRemoteIPPWM();
}
syncPi();
while ( !mPisyncFinished ) {
//qDebug("waiting ");
qApp->processEvents();
}
timer.start();
while ( timer.elapsed () < 2000 ) {
qApp->processEvents();
}
} else
syncRemote( temp, false );
}
}
timer.start();
mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
while ( timer.elapsed () < 2000 ) {
qApp->processEvents();
#ifndef _WIN32_
sleep (1);
#endif
}
}
}
delete temp;
return syncedProfiles;
}
void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
{
QString question;
if ( ask ) {
question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
if ( QMessageBox::information( mParent, i18n("Sync"),
question,
i18n("Yes"), i18n("No"),
0, 0 ) != 0 )
return;
}
QString preCommand;
QString localTempFile;
QString postCommand;
switch(mTargetApp)
{
case (KAPI):
preCommand = prof->getPreSyncCommandAB();
postCommand = prof->getPostSyncCommandAB();
localTempFile = prof->getLocalTempFileAB();
break;
case (KOPI):
preCommand = prof->getPreSyncCommand();
postCommand = prof->getPostSyncCommand();
localTempFile = prof->getLocalTempFile();
break;
case (PWMPI):
preCommand = prof->getPreSyncCommandPWM();
postCommand = prof->getPostSyncCommandPWM();
localTempFile = prof->getLocalTempFilePWM();
break;
default:
qDebug("KSM::syncRemote: invalid apptype selected");
break;
}
int fi;
if ( (fi = preCommand.find("$PWD$")) > 0 ) {
QString pwd = getPassword();
preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
}
int maxlen = 30;
if ( QApplication::desktop()->width() > 320 )
maxlen += 25;
mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
int fileSize = 0;
int result = system ( preCommand );
// 0 : okay
// 256: no such file or dir
//
qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
if ( result != 0 ) {
unsigned int len = maxlen;
while ( len < preCommand.length() ) {
@@ -1048,207 +1048,216 @@ bool KSyncManager::syncExternalApplication(QString resource)
mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
return false;
}
qDebug("KSM::Sync extern %s", resource.latin1());
bool syncOK = mImplementation->syncExternal(this, resource);
return syncOK;
}
void KSyncManager::syncPhone()
{
syncExternalApplication("phone");
}
void KSyncManager::showProgressBar(int percentage, QString caption, int total)
{
if (!bar->isVisible())
{
int w = 300;
if ( QApplication::desktop()->width() < 320 )
w = 220;
int h = bar->sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
bar->setCaption (caption);
bar->setTotalSteps ( total ) ;
bar->show();
}
bar->raise();
bar->setProgress( percentage );
qApp->processEvents();
}
void KSyncManager::hideProgressBar()
{
bar->hide();
qApp->processEvents();
}
bool KSyncManager::isProgressBarCanceled()
{
return !bar->isVisible();
}
QString KSyncManager::syncFileName()
{
QString fn = "tempfile";
switch(mTargetApp)
{
case (KAPI):
fn = "tempsyncab.vcf";
break;
case (KOPI):
fn = "tempsynccal.ics";
break;
case (PWMPI):
fn = "tempsyncpw.pwm";
break;
default:
break;
}
#ifdef DESKTOP_VERSION
return locateLocal( "tmp", fn );
#else
return (QString( "/tmp/" )+ fn );
#endif
}
void KSyncManager::syncPi()
{
mIsKapiFile = true;
mPisyncFinished = false;
qApp->processEvents();
if ( mAskForPreferences )
if ( !edit_pisync_options()) {
mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
mPisyncFinished = true;
return;
}
bool ok;
Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
if ( ! ok ) {
mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
mPisyncFinished = true;
return;
}
mCurrentResourceLocal = "";
mCurrentResourceRemote = "";
if ( mSpecificResources.count() ) {
+ int lastSyncRes = mSpecificResources.count()/2;
+ int ccc = mSpecificResources.count()-1;
+ while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) {
+ --ccc;
+ --lastSyncRes;
+ }
int startLocal = 0;
int startRemote = mSpecificResources.count()/2;
emit multiResourceSyncStart( true );
while ( startLocal < mSpecificResources.count()/2 ) {
- if ( startLocal+1 >= mSpecificResources.count()/2 )
+ if ( startLocal+1 >= lastSyncRes )
emit multiResourceSyncStart( false );
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();
+ if ( !mCurrentResourceRemote.isEmpty() ) {
+ qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
+ 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 };
if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
if ( state == KCommandSocket::errorPW )
mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
else if ( state == KCommandSocket::errorCA )
mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
else if ( state == KCommandSocket::errorFI )
mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
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());
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
commandSocket->sendStop();
}
mPisyncFinished = true;
return;
} else if ( state == KCommandSocket::errorW ) {
mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
mPisyncFinished = true;
} else if ( state == KCommandSocket::successR ) {
QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
} else if ( state == KCommandSocket::successW ) {
mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
mPisyncFinished = true;
} else if ( state == KCommandSocket::quiet ){
qDebug("KSS: quiet ");
mPisyncFinished = true;
} else {
qDebug("KSS: Error: unknown state: %d ", state);
mPisyncFinished = true;
}
delete s;
}
void KSyncManager::readFileFromSocket()
{
QString fileName = syncFileName();
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( mCurrentResourceRemote,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 {
commandSocket->sendStop();
if ( syncOK )
mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
mPisyncFinished = true;
}
}
KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
{
mPassWord = pw;
mSocket = 0;
mSyncActionDialog = 0;
blockRC = false;
mErrorMessage = 0;
}
void KServerSocket::newConnection ( int socket )
{
// qDebug("KServerSocket:New connection %d ", socket);
if ( mSocket ) {
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 27f7932..744a914 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -498,200 +498,202 @@ void KSyncPrefsDialog::textChanged( const QString & s )
KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
prof->setName( s );
mSyncProfileNames[mProfileBox-> currentItem ()] = s;
}
void KSyncPrefsDialog::profileChanged( int item )
{
//qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
KSyncProfile* prof;
saveProfile();
readFilter();
readResources();
currentSelection = item;
prof = mSyncProfiles.at(item) ;
mRemotePw->setText(prof->getRemotePw());
mRemoteIP->setText(prof->getRemoteIP());
mRemotePort->setText(prof->getRemotePort());
mRemotePwAB->setText(prof->getRemotePwAB());
mRemoteIPAB->setText(prof->getRemoteIPAB());
mRemotePortAB->setText(prof->getRemotePortAB());
mRemotePwPWM->setText(prof->getRemotePwPWM());
mRemoteIPPWM->setText(prof->getRemoteIPPWM());
mRemotePortPWM->setText(prof->getRemotePortPWM());
mRemotePrecommand->setText(prof->getPreSyncCommand());
mRemotePostcommand->setText(prof->getPostSyncCommand());
mLocalTempFile->setText(prof->getLocalTempFile());
mRemoteFile->setText(prof->getRemoteFileName()) ;
mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
mLocalTempFileAB->setText(prof->getLocalTempFileAB());
mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
if ( mWriteContactToSIM )
mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
mPhoneDevice->setText(prof->getPhoneDevice());
mPhoneConnection->setText(prof->getPhoneConnection());
mPhoneModel->setText(prof->getPhoneModel());
mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
mAskForPreferences->setChecked( prof->getAskForPreferences());
mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
mWriteBackFile->setChecked( prof->getWriteBackFile());
mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
mWriteBackFuture->setChecked( prof->getWriteBackFuture());
mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() );
mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 );
mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 );
mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 );
mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 );
switch ( prof->getSyncPrefs() ) {
case 0:
loc->setChecked( true);
break;
case 1:
rem->setChecked( true );
break;
case 2:
newest->setChecked( true);
break;
case 3:
ask->setChecked( true);
break;
case 4:
f_loc->setChecked( true);
break;
case 5:
f_rem->setChecked( true);
break;
case 6:
//both->setChecked( true);
break;
default:
break;
}
mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
mIsPhone->setChecked(prof->getIsPhoneSync()) ;
mIsPi->setChecked(prof->getIsPiSync()) ;
mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ;
mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
- QStringList res = QStringList::split( ":",prof->getResSpecKopi());
- int i= res.count()/2;
- for ( ;i < res.count(); ++i ) {
- mResTableKopi->setText( i, 0, res[i] );
+ QStringList res = QStringList::split( ":",prof->getResSpecKopi(), true );
+ int add = res.count()/2;
+ int i;
+ for ( i = 0;i < add ; ++i ) {
+ mResTableKopi->setText( i, 0, res[i+add] );
}
- res = QStringList::split( ":",prof->getResSpecKapi());
- for ( i = 0;i < res.count(); ++i ) {
- mResTableKapi->setText( i, 0, res[i] );
+ res = QStringList::split( ":",prof->getResSpecKapi(), true);
+ add = res.count()/2;
+ for ( i = 0;i < add; ++i ) {
+ mResTableKapi->setText( i, 0, res[i+add] );
}
mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec());
proGr->setEnabled( item > 2 );
if ( item < 3 ) {
localFileWidget->hide();
remoteFileWidget->hide();
phoneWidget->hide();
piWidget->hide();
} else
kindChanged( prof->getIsLocalFileSync() );
}
void KSyncPrefsDialog::fillSSH()
{
mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
mLocalTempFile->setText("/tmp/mycalendar.ics" );
mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
mLocalTempFileAB->setText("/tmp/std.vcf" );
mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
}
void KSyncPrefsDialog::fillFTP()
{
mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
mLocalTempFile->setText("/tmp/mycalendar.ics" );
mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
mLocalTempFileAB->setText("/tmp/std.vcf" );
mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
}
void KSyncPrefsDialog::kindChanged( bool b )
{
if ( mIsLocal->isChecked () ) {
mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() );
} else {
mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() );
}
if ( mIsLocal->isChecked () )
localFileWidget->show();
else
localFileWidget->hide();
if ( mIsNotLocal->isChecked () )
remoteFileWidget->show();
else
remoteFileWidget->hide();
if ( mIsPhone->isChecked () ) {
phoneWidget->show();
}
else {
phoneWidget->hide();
}
if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) {
piWidget->show();
if (mIsPiSpecific->isChecked () ) {
mTableBox->show();
}
else {
mTableBox->hide();
}
}
else {
piWidget->hide();
}
}
void KSyncPrefsDialog::deleteProfile()
{
//qDebug("KSyncPrefsDialog::deleteProfile() ");
if ( currentSelection >= 0 ) {
if ( currentSelection < 3 ) {
KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
return;
}
KSyncProfile* temp = mSyncProfiles.at(currentSelection);
mSyncProfiles.remove( temp );
mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
insertProfiles();
}
}
void KSyncPrefsDialog::saveProfile()
diff --git a/libkdepim/ksyncprofile.cpp b/libkdepim/ksyncprofile.cpp
index d6620c8..b0d3efc 100644
--- a/libkdepim/ksyncprofile.cpp
+++ b/libkdepim/ksyncprofile.cpp
@@ -49,192 +49,194 @@ KSyncProfile* KSyncProfile::clone()
myClone->setRemotePwAB(mRemotePwAB);
myClone->setRemoteIPAB(mRemoteIPAB);
myClone->setRemotePortAB(mRemotePortAB);
myClone->setRemotePwPWM(mRemotePwPWM);
myClone->setRemoteIPPWM(mRemoteIPPWM);
myClone->setRemotePortPWM (mRemotePortPWM);
myClone->setPreSyncCommand( mPreSyncCommand );
myClone->setPostSyncCommand( mPostSyncCommand );
myClone->setLocalTempFile( mLocalTempFile);
myClone->setRemoteFileName( mRemoteFileName );
myClone->setPreSyncCommandAB( mPreSyncCommandAB );
myClone->setPostSyncCommandAB( mPostSyncCommandAB );
myClone->setLocalTempFileAB( mLocalTempFileAB);
myClone->setRemoteFileNameAB( mRemoteFileNameAB );
myClone->setPreSyncCommandPWM( mPreSyncCommandPWM );
myClone->setPostSyncCommandPWM( mPostSyncCommandPWM );
myClone->setLocalTempFilePWM( mLocalTempFilePWM);
myClone->setRemoteFileNamePWM( mRemoteFileNamePWM );
myClone->setShowSummaryAfterSync( mShowSummaryAfterSync );
myClone->setAskForPreferences( mAskForPreferences);
myClone->setWriteBackExisting(mWriteBackExisting );
myClone->setWriteBackFile( mWriteBackFile);
myClone->setWriteBackFuture( mWriteBackFuture );
myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks );
myClone->setWriteBackPastWeeks( mWriteBackPastWeeks );
myClone->setIncludeInRingSync( mIncludeInRingSync );
myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB );
myClone->setIncludeInRingSyncPWM( mIncludeInRingSyncPWM );
myClone->setSyncPrefs( mSyncPrefs);
myClone->setIsLocalFileSync( mIsLocalFileSync );
myClone->setIsPhoneSync( mIsPhoneSync );
myClone->setIsKapiFile( mIsKapiFile );
myClone->setIsPiSync( mIsPiSync );
myClone->setWriteContactToSIM( mWriteContactToSIM );
myClone->setName( "noName" );
myClone->setFilterInCal ( mFilterInCal );
myClone->setFilterOutCal ( mFilterOutCal );
myClone->setFilterInAB ( mFilterInAB );
myClone->setFilterOutAB ( mFilterOutAB );
//myClone->setIdentifier( "noID" );
return myClone;
}
void KSyncProfile::setDefault()
{
mPreSyncCommand = i18n("command for downloading remote file to local device");
mPostSyncCommand = i18n("command for uploading local temp file to remote device");
mLocalTempFile = "/tmp/mycalendar.ics";
mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics";
mPreSyncCommandAB = i18n("command for downloading remote file to local device");
mPostSyncCommandAB = i18n("command for uploading local temp file to remote device");
mLocalTempFileAB = "/tmp/std.vcf";
mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf";
mPreSyncCommandPWM = i18n("command for downloading remote file to local device");
mPostSyncCommandPWM = i18n("command for uploading local temp file to remote device");
mLocalTempFilePWM = "/tmp/passwords.pwm";
mRemoteFileNamePWM = "/home/polo/kdepim/apps/pwmanager/localfile.pwm";
mRemotePw = "abc";
mRemoteIP = "192.168.0.99";
mRemotePort = "9197";
mRemotePwAB = "abc";
mRemoteIPAB = "192.168.0.99";
mRemotePortAB = "9198";
mRemotePwPWM = "abc";
mRemoteIPPWM = "192.168.0.99";
mRemotePortPWM = "9199";
mShowSummaryAfterSync = true;
mAskForPreferences = true;
mWriteBackExisting = false;
mWriteBackFuture = false;
mWriteBackFutureWeeks = 12;
mWriteBackPastWeeks = 2;
mWriteBackFile = true;
mIncludeInRingSync = false;
mIncludeInRingSyncAB = false;
mIncludeInRingSyncPWM = false;
mSyncPrefs = SYNC_PREF_ASK;
mIsLocalFileSync = true;
mName = "noName";
mIsPhoneSync = false;
mIsPiSync = false;
mIsPiSyncSpec = false;
mIsKapiFile = false;
mWriteContactToSIM = false;
mPhoneDevice = "/dev/ircomm";
mPhoneConnection = "irda";
mPhoneModel = "6310i";
mFilterInCal = "no filter";
mFilterOutCal = "no filter";
mFilterInAB = "no filter";
mFilterOutAB = "no filter";
+ mResSpecKopi = "";
+ mResSpecKapi = "";
}
void KSyncProfile::readConfig(KConfig *config )
{
if (config)
{
config->setGroup( mName );
mName = config->readEntry( "Name", mName );
mRemotePw = config->readEntry( "RemotePw",mRemotePw );
mRemoteIP = config->readEntry( "RemoteIP",mRemoteIP );
mRemotePort = config->readEntry( "RemotePort", mRemotePort );
mRemotePwAB = config->readEntry( "RemotePwAB", mRemotePwAB );
mRemoteIPAB = config->readEntry( "RemoteIPAB", mRemoteIPAB );
mRemotePortAB = config->readEntry( "RemotePortAB", mRemotePortAB );
mRemotePwPWM = config->readEntry( "RemotePwPWM", mRemotePwPWM );
mRemoteIPPWM = config->readEntry( "RemoteIPPWM", mRemoteIPPWM );
mRemotePortPWM = config->readEntry( "RemotePortPWM", mRemotePortPWM );
mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand );
mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand );
mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile );
mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName );
mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB );
mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB );
mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB );
mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB );
mPreSyncCommandPWM = config->readEntry( "PreSyncCommandPWM",mPreSyncCommandPWM );
mPostSyncCommandPWM = config->readEntry( "PostSyncCommandPWM", mPostSyncCommandPWM );
mLocalTempFilePWM = config->readEntry( "LocalTempFilePWM", mLocalTempFilePWM );
mRemoteFileNamePWM = config->readEntry( "RemoteFileNamePWM", mRemoteFileNamePWM );
mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice );
mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection );
mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel );
mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync );
mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB );
mIncludeInRingSyncPWM = config->readBoolEntry( "IncludeInRingSyncPWM",mIncludeInRingSyncPWM );
mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync );
mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences );
mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting );
mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture );
mWriteBackFile = config->readBoolEntry( "WriteBackFile",mWriteBackFile );
mWriteContactToSIM = config->readBoolEntry( "WriteContactToSIM",mWriteContactToSIM );
mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs );
mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks );
mWriteBackPastWeeks = config->readNumEntry( "WriteBackPastWeeks", mWriteBackPastWeeks );
mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync );
mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync );
mIsPiSync= config->readBoolEntry( "IsPiSync", mIsPiSync );
mIsPiSyncSpec= config->readBoolEntry( "IsPiSyncSpec", mIsPiSyncSpec );
mIsKapiFile = config->readBoolEntry( "IsKapiFile", mIsKapiFile );
mFilterInCal = config->readEntry( "FilterInCal", mFilterInCal );
mFilterOutCal = config->readEntry( "FilterOutCal", mFilterOutCal );
mFilterInAB = config->readEntry( "FilterInAB", mFilterInAB );
mFilterOutAB = config->readEntry( "FilterOutAB", mFilterOutAB );
mResSpecKopi = config->readEntry( "ResSpecKopi", mResSpecKopi );
mResSpecKapi = config->readEntry( "ResSpecKapi", mResSpecKapi );
}
else
{
setDefault();
}
}
void KSyncProfile::deleteConfig(KConfig *config )
{
config->deleteGroup( mName );
}
void KSyncProfile::writeConfig( KConfig * config )
{
config->setGroup(mName);
config->writeEntry( "RemotePw", mRemotePw);
config->writeEntry( "RemoteIP", mRemoteIP);
config->writeEntry( "RemotePort", mRemotePort);
config->writeEntry( "RemotePwAB", mRemotePwAB);
config->writeEntry( "RemoteIPAB", mRemoteIPAB);
config->writeEntry( "RemotePortAB", mRemotePortAB);
config->writeEntry( "RemotePwPWM", mRemotePwPWM);
config->writeEntry( "RemoteIPPWM", mRemoteIPPWM);
config->writeEntry( "RemotePortPWM", mRemotePortPWM);
config->writeEntry( "Name", mName );
config->writeEntry( "PreSyncCommand",mPreSyncCommand );
config->writeEntry( "PostSyncCommand", mPostSyncCommand );
config->writeEntry( "LocalTempFile", mLocalTempFile );