summaryrefslogtreecommitdiffabout
path: root/korganizer/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp98
1 files changed, 28 insertions, 70 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 );