author | zautrix <zautrix> | 2004-10-08 10:31:33 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-08 10:31:33 (UTC) |
commit | 98987418d89d1334c0c2961ca4d6bc295d6fb021 (patch) (side-by-side diff) | |
tree | 2562272904bcd82eab7e6d185f3f7f0abfac48c3 | |
parent | 309df8e8df3a17602f948025b7951b21ec5c3fed (diff) | |
download | kdepimpi-98987418d89d1334c0c2961ca4d6bc295d6fb021.zip kdepimpi-98987418d89d1334c0c2961ca4d6bc295d6fb021.tar.gz kdepimpi-98987418d89d1334c0c2961ca4d6bc295d6fb021.tar.bz2 |
Sync fixes
-rw-r--r-- | bin/kdepim/korganizer/howtoSYNC.txt | 17 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 56 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 1 |
3 files changed, 62 insertions, 12 deletions
diff --git a/bin/kdepim/korganizer/howtoSYNC.txt b/bin/kdepim/korganizer/howtoSYNC.txt index d3046de..c4e80f5 100644 --- a/bin/kdepim/korganizer/howtoSYNC.txt +++ b/bin/kdepim/korganizer/howtoSYNC.txt @@ -94,49 +94,54 @@ e) Choose the other profile options. Detailed explanation in 2) f) Close sync dialog with OK. g) Sync. NOTE: AFTER SYNCING THERE ARE "SYNC EVENTS" CREATED (OR UPDATED, IF IT ALREADY EXITS) FOR EACH SYNC PROFILE. YOU MAY NOT DELETE OR CHANGE THESE EVENTS. ************************************************************************* 2) Sync settings in sync dialog ************************************************************************* a) Local device name: -> 1) b) b) Profile: -> 1) c) c) Include in multiple sync: In the Synchronize menu, there is a multiple sync menu entry. If you choose this menu entry, all user defined profiles with this 'Include in multiple sync' option enabled will be synced one after another. And this twice. This will take some time. After that sync, on all devices should be the same data. d) Ask for preferences before sync: - Check this to be asked for sync settings before each sync. + Check this to be asked for sync preferences settings before each sync. + If the profile kind is "Pi-Sync" you will be asked to confirm + the "Pi-Sync" specific settings (Password,IP address, port number) + as well. That makes it possible to use that profile for a + device that is connected via DHCP to the network and gets different + IP addresses when connection to the network. e) Sync preferences: Choose here your sync preferences. Details -> 4) f) Show summary after sync: Check this to get a small summary dialog after sync about number of added/changed/deleted events on local/remote. g) Write back synced data: Uncheck this to update the local calendar only. I.e. your local calendar is synced with the remote calendar but nothing on the remote calendar is changed. If you uncheck "Write back synced data", the settings under h) and i) are ignored, of course. h) --Write back (on remote) existing entries only: Check this to update the remote data only. I.e. no data from yor local calendar/addressbook is added to the remote device. You may use this option to sync against some kind of "public calendar/addressbook" without writing back your personal data. i) --Write back (calendar) entries in future only: Check this to write back only calendar entries in future. (Useful when syncing with mobile phones.) You can specify the date range in weeks with ---- Max. weeks in future. Note: The date range starts always 7 days before the actual date! @@ -246,48 +251,58 @@ b) Pi-Sync (direct Kx/Pi to Kx/Pi sync) If you want to sync with a device, where KO/Pi is installed, you can easily get the remote file via network with the build in file transfer feature "Pi-Sync": You have first to enable file transfer on the remote device: - Start KO/Pi on the remote device. - Choose Menu Synchronize-Enable Pi-Sync. - Choose a port number, where KO/Pi should listen for file sending requests. Valid port numbers are numbers between 1 and 65565. Do not specify port numbers, that are used by other applications. A port number between 9000 and 9999 is most likely not used by another application. The default port number is 9197 for KO/Pi. If you specify a port number, which is already in use, you will get an error message when closing this dialog. - Choose a password. - Click OK. Now KO/Pi will send the calendar data via the network, if some other device is sending a "please send calendar" request on the given port using the given password. If you want to be sure, nobody can access your calendar data, simply disable the file transfer feature on the remote device after the syncing is done by choosing: Menu Synchronize-Disable Pi-Sync. + Note: If you want to sync with a remote device that gets different + IPaddresses each time connected to the network + (this may be the case, if you use DHCP for connection + of the remote device to the network) simply enable + "Ask for preferences before sync". + Then you will be asked to confirm the + "Pi-Sync" specific settings + (Password,IP address, port number) + and you can easily change the IP address before each sync. + On your local device, create a new profile and choose profile kind "Pi-Sync". Fill in the needed values: - Password for remote access: The password you specified on the remote device. - Remote IP address: The IP address of the remote device. - Remote port number: The port number you specified on the remote device. Now you can syncronize your local device easily with your remote device. This works well for all platforms KO/Pi is running on, e.g. syncing a KO/Pi on Zaurus with KO/Pi on Windows is now very easy. c) Remote file Syncing with the profile kind "Remote file" is performed in three steps: i) download the remote file to your local machine to a temp file ii) sync with this temp file iii) upload the synced file to the remote device The down-/uploading if i) and iii) is done via a command line command. Please specify the download/upload command ( like scp, ftp, ...) and the file name of the temp file in the corresponding fields. diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index b3e266a..0faa24d 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -588,53 +588,83 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); if ( syncWithFile( localTempFile, true ) ) { if ( mWriteBackFile ) { int fi; if ( (fi = postCommand.find("$PWD$")) > 0 ) { QString pwd = getPassword(); postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); } mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); result = system ( postCommand ); qDebug("Writing back file result: %d ", result); if ( result != 0 ) { mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); return; } else { mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); } } } return; } +void KSyncManager::edit_pisync_options() +{ + QDialog dia( mParent, "dia", true ); + dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); + QVBoxLayout lay ( &dia ); + lay.setSpacing( 5 ); + lay.setMargin( 3 ); + QLabel lab1 ( i18n("Password for remote access:"), &dia); + lay.addWidget( &lab1 ); + QLineEdit le1 (&dia ); + lay.addWidget( &le1 ); + QLabel lab2 ( i18n("Remote IP address:"), &dia); + lay.addWidget( &lab2 ); + QLineEdit le2 (&dia ); + lay.addWidget( &le2 ); + QLabel lab3 ( i18n("Remote port number:"), &dia); + lay.addWidget( &lab3 ); + QLineEdit le3 (&dia ); + lay.addWidget( &le3 ); + QPushButton pb ( "OK", &dia); + lay.addWidget( &pb ); + connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); + le1.setText( mPassWordPiSync ); + le2.setText( mActiveSyncIP ); + le3.setText( mActiveSyncPort ); + if ( dia.exec() ) { + mPassWordPiSync = le1.text(); + mActiveSyncPort = le3.text(); + mActiveSyncIP = le2.text(); + } +} void KSyncManager::edit_sync_options() { - //mDialogManager->showSyncOptions(); - //mSyncAlgoPrefs + QDialog dia( mParent, "dia", true ); dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); QVBoxLayout lay ( &dia ); lay.setSpacing( 2 ); lay.setMargin( 3 ); lay.addWidget(&gr); QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); //QRadioButton both( i18n("Take both on conflict"), &gr ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); switch ( mSyncAlgoPrefs ) { case 0: loc.setChecked( true); break; case 1: rem.setChecked( true ); break; @@ -764,52 +794,53 @@ 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 _WIN32_ return locateLocal( "tmp", fn ); #else return (QString( "/tmp/" )+ fn ); #endif } - void KSyncManager::syncPi() { qApp->processEvents(); + if ( mAskForPreferences ) + edit_pisync_options(); bool ok; Q_UINT16 port = mActiveSyncPort.toUInt(&ok); if ( ! ok ) { mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); return; } KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); commandSocket->readFile( syncFileName() ); } void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) { qDebug("MainWindow::deleteCommandSocket %d", state); //enum { success, errorW, errorR, quiet }; if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); delete s; if ( state == KCommandSocket::errorR ) { KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); commandSocket->sendStop(); @@ -876,60 +907,60 @@ void KServerSocket::discardClient() if ( mSocket ) { delete mSocket; mSocket = 0; } //emit endConnect(); } void KServerSocket::readClient() { if ( blockRC ) return; if ( mSocket == 0 ) { qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); return; } qDebug("KServerSocket readClient()"); if ( mSocket->canReadLine() ) { QString line = mSocket->readLine(); qDebug("KServerSocket readline: %s ", line.latin1()); QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); if ( tokens[0] == "GET" ) { if ( tokens[1] == mPassWord ) //emit sendFile( mSocket ); send_file(); else { - KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); + KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); } } if ( tokens[0] == "PUT" ) { if ( tokens[1] == mPassWord ) { //emit getFile( mSocket ); blockRC = true; get_file(); } else { - KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); + KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); } } if ( tokens[0] == "STOP" ) { //emit endConnect(); end_connect(); } } } void KServerSocket::end_connect() { delete mSyncActionDialog; mSyncActionDialog = 0; } void KServerSocket::send_file() { //qDebug("MainWindow::sendFile(QSocket* s) "); if ( mSyncActionDialog ) delete mSyncActionDialog; mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); mSyncActionDialog->setCaption(i18n("Received sync request")); QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); lay->addWidget( label); @@ -1134,43 +1165,46 @@ void KCommandSocket::readFileFromSocket() if (!file.open( IO_WriteOnly ) ) { mFileString = ""; mRetVal = errorR; qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); deleteSocket(); return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts ( &file ); ts.setEncoding( QTextStream::Latin1 ); ts << mFileString; file.close(); mFileString = ""; mRetVal = successR; mSocket->close(); // if state is not idle, deleteSocket(); is called via // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); if ( mSocket->state() == QSocket::Idle ) deleteSocket(); } void KCommandSocket::deleteSocket() { + //qDebug("KCommandSocket::deleteSocket() "); if ( mTimerSocket->isActive () ) { mTimerSocket->stop(); mRetVal = errorTO; + qDebug("Connection to remote host timed out"); if ( mSocket ) { mSocket->close(); - if ( mSocket->state() == QSocket::Idle ) - deleteSocket(); - return; + //if ( mSocket->state() == QSocket::Idle ) + // deleteSocket(); + delete mSocket; + mSocket = 0; } + KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); + emit commandFinished( this, mRetVal ); + return; } //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); if ( mSocket) delete mSocket; mSocket = 0; - if ( mRetVal == errorTO) - KMessageBox::information( 0, i18n("ERROR:\nConnection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); - emit commandFinished( this, mRetVal ); } diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index 1f7c7e7..5b05383 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -152,48 +152,49 @@ class KSyncManager : public QObject public slots: void slotSyncMenu( int ); void deleteCommandSocket(KCommandSocket*s, int state); void readFileFromSocket(); void fillSyncMenu(); private: void syncPi(); KServerSocket * mServerSocket; void enableQuick(); KPimPrefs* mPrefs; QString mDefFileName; QString mCurrentSyncDevice; QString mCurrentSyncName; void quickSyncLocalFile(); bool syncWithFile( QString fn , bool quick ); void syncLocalFile(); void syncPhone(); void syncSharp(); bool syncExternalApplication(QString); int mCurrentSyncProfile ; void syncRemote( KSyncProfile* prof, bool ask = true); void edit_sync_options(); + void edit_pisync_options(); int ringSync(); QString getPassword( ); private slots: void confSync(); private: bool mBlockSaveFlag; QWidget* mParent; KSyncInterface* mImplementation; TargetApp mTargetApp; QPopupMenu* mSyncMenu; QProgressBar* bar; }; class KSyncInterface { public : virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; virtual bool syncExternal(KSyncManager* manager, QString resource) { // empty implementation, because some syncable applications do not // have an external(sharpdtm) syncmode, like pwmanager. |