summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp98
-rw-r--r--korganizer/mainwindow.h2
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
3 files changed, 33 insertions, 73 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index bce2a54..fe7e6d3 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -871,11 +871,8 @@ void MainWindow::fillSyncMenu()
} else {
syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
}
syncMenu->insertSeparator();
- syncMenu->insertItem( i18n("New Pi-Sync!"), 4 );
- syncMenu->insertItem( i18n("Quick Pi-Sync!"), 5 );
- syncMenu->insertSeparator();
syncMenu->insertItem( i18n("Multiple sync"), 1 );
syncMenu->insertSeparator();
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
config.setGroup("General");
@@ -951,9 +948,14 @@ int MainWindow::ringSync()
KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
syncPhone();
- } else
+ } else if ( temp->getIsPiSync() ) {
+ mPassWordPiSync = temp->getRemotePw();
+ KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
+ KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
+ syncPi();
+ } else
syncRemote( temp, false );
}
}
@@ -1035,16 +1037,8 @@ void MainWindow::slotSyncMenu( int action )
mServerSocket = 0;
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
return;
}
- if ( action == 4 ) {
- performQuick();
- return;
- }
- if ( action == 5 ) {
- performQuickQuick();
- return;
- }
if (mBlockSaveFlag)
return;
mBlockSaveFlag = true;
@@ -1081,9 +1075,14 @@ void MainWindow::slotSyncMenu( int action )
KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
syncPhone();
- } else
+ } else if ( temp->getIsPiSync() ) {
+ mPassWordPiSync = temp->getRemotePw();
+ KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
+ KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
+ syncPi();
+ } else
syncRemote( temp );
}
}
@@ -1954,49 +1953,10 @@ void MainWindow::getFile( bool success )
}
-void MainWindow::performQuick()
+void MainWindow::syncPi()
{
-
- setCaption( i18n("Please input connection settings") );
- QString retfile = "";
- QDialog dia ( this, "input-dialog", true );
- QLineEdit lab ( &dia );
- QVBoxLayout lay( &dia );
- QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia );
- lay.addWidget( &label);
- lab.setText( KOPrefs::instance()->mActiveSyncIP );
- lay.setMargin(7);
- lay.setSpacing(7);
- lay.addWidget( &lab);
- QLabel label2 ( i18n("Port number (Default: 9197)"), &dia );
- lay.addWidget( &label2);
- QLineEdit lab2 ( &dia );
- lab2.setText( KOPrefs::instance()->mActiveSyncPort );
- lay.addWidget( &lab2);
-
- QLineEdit lepw ( &dia );
- lepw.setText( mPassWordPiSync );
- QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia );
- lay.addWidget( &label3);
- lay.addWidget( &lepw);
-
- dia.setFixedSize( 230,200 );
- dia.setCaption( i18n("Enter port for Pi-Sync ") );
- QPushButton pb ( "OK", &dia);
- lay.addWidget( &pb );
- connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
- dia.show();
- int res = dia.exec();
- if ( !res ) {
- setCaption( i18n("Syncing cancelled!") );
- return;
- }
- mPassWordPiSync = lepw.text();
- dia.hide();
- KOPrefs::instance()->mActiveSyncPort = lab2.text();
- KOPrefs::instance()->mActiveSyncIP = lab.text();
qApp->processEvents();
performQuickQuick();
}
@@ -2376,9 +2336,9 @@ KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject
};
void KServerSocket::newConnection ( int socket )
{
- qDebug("KServerSocket:New connection %d ", socket);
+ // qDebug("KServerSocket:New connection %d ", socket);
if ( mSocket ) {
qDebug("KServerSocket::newConnection Socket deleted! ");
delete mSocket;
mSocket = 0;
@@ -2390,11 +2350,10 @@ void KServerSocket::newConnection ( int socket )
}
void KServerSocket::discardClient()
{
- qDebug(" KServerSocket::discardClient()");
+ //qDebug(" KServerSocket::discardClient()");
if ( mSocket ) {
- qDebug("delete ");
delete mSocket;
mSocket = 0;
}
//emit endConnect();
@@ -2404,12 +2363,11 @@ void KServerSocket::readClient()
if ( mSocket == 0 ) {
qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
return;
}
- qDebug("KServerSocket readClient()");
+ //qDebug("KServerSocket readClient()");
if ( mSocket->canReadLine() ) {
QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
- qDebug("KServerSocket socket->canReadLine()");
if ( tokens[0] == "GET" ) {
if ( tokens[1] == mPassWord )
//emit sendFile( mSocket );
send_file();
@@ -2439,9 +2397,9 @@ void KServerSocket::end_connect()
mSyncActionDialog = 0;
}
void KServerSocket::send_file()
{
- qDebug("MainWindow::sendFile(QSocket* s) ");
+ //qDebug("MainWindow::sendFile(QSocket* s) ");
if ( mSyncActionDialog )
delete mSyncActionDialog;
mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
mSyncActionDialog->setCaption(i18n("Received sync request"));
@@ -2477,10 +2435,9 @@ void KServerSocket::send_file()
os << ts.readLine() << "\n";
}
//os << ts.read();
file.close();
- mSyncActionDialog->setCaption( i18n("Waiting to get back synced file") );
- qDebug("file sent ");
+ mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
mSocket->close();
if ( mSocket->state() == QSocket::Idle )
QTimer::singleShot( 10, this , SLOT ( discardClient()));
}
@@ -2495,20 +2452,20 @@ void KServerSocket::get_file()
void KServerSocket::readBackFileFromSocket()
{
- qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
+ //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
while ( mSocket->canReadLine () ) {
piTime.restart();
QString line = mSocket->readLine ();
piFileString += line;
- qDebug("readline: %s ", line.latin1());
+ //qDebug("readline: %s ", line.latin1());
mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
}
if ( piTime.elapsed () < 3000 ) {
// wait for more
- qDebug("waitformore ");
+ //qDebug("waitformore ");
QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
return;
}
QString fileName = mFileName;
@@ -2525,9 +2482,8 @@ void KServerSocket::readBackFileFromSocket()
// mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
QTextStream ts ( &file );
ts.setCodec( QTextCodec::codecForName("utf8") );
- qDebug("finish ");
mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
ts << piFileString;
mSocket->close();
if ( mSocket->state() == QSocket::Idle )
@@ -2580,16 +2536,18 @@ void KCommandSocket::writeFile( QString fileName )
if ( !mSocket ) {
mSocket = new QSocket( this );
connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
}
+ mSocket->connectToHost( mHost, mPort );
QTextStream ts2( &file2 );
ts2.setCodec( QTextCodec::codecForName("utf8") );
QTextStream os2( mSocket );
os2.setCodec( QTextCodec::codecForName("utf8") );
os2 << "PUT " << mPassWord << "\r\n";;
while ( ! ts2.atEnd() ) {
os2 << ts2.readLine() << "\n";
}
+ mRetVal= true;
mSocket->close();
if ( mSocket->state() == QSocket::Idle )
QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
file2.close();
@@ -2600,8 +2558,9 @@ void KCommandSocket::sendStop()
if ( !mSocket ) {
mSocket = new QSocket( this );
connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
}
+ mSocket->connectToHost( mHost, mPort );
QTextStream os2( mSocket );
os2.setCodec( QTextCodec::codecForName("utf8") );
os2 << "STOP\r\n";
mRetVal= true;
@@ -2622,18 +2581,18 @@ void KCommandSocket::startReadFileFromSocket()
}
void KCommandSocket::readFileFromSocket()
{
- qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
+ //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
while ( mSocket->canReadLine () ) {
mTime.restart();
QString line = mSocket->readLine ();
mFileString += line;
- qDebug("readline: %s ", line.latin1());
+ //qDebug("readline: %s ", line.latin1());
}
if ( mTime.elapsed () < 3000 ) {
// wait for more
- qDebug("waitformore ");
+ //qDebug("waitformore ");
QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
return;
}
QString fileName = mFileName;
@@ -2648,9 +2607,8 @@ void KCommandSocket::readFileFromSocket()
}
// mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
QTextStream ts ( &file );
ts.setCodec( QTextCodec::codecForName("utf8") );
- qDebug("finish ");
ts << mFileString;
file.close();
mFileString = "";
mRetVal = true;
@@ -2667,9 +2625,9 @@ void KCommandSocket::deleteSocket()
mTimerSocket->stop();
KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
mRetVal = false;
}
- qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
+ //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
if ( mSocket)
delete mSocket;
mSocket = 0;
emit commandFinished( this, mRetVal );
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 5a67765..f8b2334 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -146,8 +146,9 @@ class MainWindow : public QMainWindow
void syncSSH();
void confSync();
void syncSharp();
void syncPhone();
+ void syncPi();
void syncLocalFile();
bool syncWithFile( QString, bool );
void quickSyncLocalFile();
@@ -174,9 +175,8 @@ class MainWindow : public QMainWindow
bool mClosed;
void saveOnClose();
int mCurrentSyncProfile;
void enableQuick();
- void performQuick();
void performQuickQuick();
void syncRemote( KSyncProfile* , bool ask = true);
bool mFlagKeyPressed;
bool mBlockAtStartup;
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index f05c846..0caa27e 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -189,9 +189,9 @@ void KSyncPrefsDialog::setupSyncAlgTab()
gr = proGr;
topLayout->addMultiCellWidget(gr, iii,iii,0,1);
++iii;
mIsLocal = new QRadioButton ( i18n("Local file"), gr );
- mIsPi = new QRadioButton ( i18n("Quick Pi-Sync"), gr );
+ mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr );
connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
@@ -455,9 +455,10 @@ void KSyncPrefsDialog::profileChanged( int item )
break;
}
mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
mIsPhone->setChecked(prof->getIsPhoneSync()) ;
- mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() );
+ mIsPi->setChecked(prof->getIsPiSync()) ;
+ mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() );
proGr->setEnabled( item > 2 );
if ( item < 3 ) {
localFileWidget->hide();
remoteFileWidget->hide();
@@ -576,8 +577,9 @@ void KSyncPrefsDialog::saveProfile()
int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
prof->setSyncPrefs( syncprefs);
prof->setIsLocalFileSync( mIsLocal->isChecked() );
prof->setIsPhoneSync( mIsPhone->isChecked() );
+ prof->setIsPiSync( mIsPi->isChecked() );
prof->setWriteBackFuture(mWriteBackFuture->isChecked());
prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());