summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
authorzautrix <zautrix>2004-10-08 10:31:33 (UTC)
committer zautrix <zautrix>2004-10-08 10:31:33 (UTC)
commit98987418d89d1334c0c2961ca4d6bc295d6fb021 (patch) (side-by-side diff)
tree2562272904bcd82eab7e6d185f3f7f0abfac48c3 /libkdepim/ksyncmanager.cpp
parent309df8e8df3a17602f948025b7951b21ec5c3fed (diff)
downloadkdepimpi-98987418d89d1334c0c2961ca4d6bc295d6fb021.zip
kdepimpi-98987418d89d1334c0c2961ca4d6bc295d6fb021.tar.gz
kdepimpi-98987418d89d1334c0c2961ca4d6bc295d6fb021.tar.bz2
Sync fixes
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp58
1 files changed, 46 insertions, 12 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index b3e266a..0faa24d 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -600,29 +600,59 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
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 );
@@ -776,28 +806,29 @@ QString KSyncManager::syncFileName()
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() );
}
@@ -888,36 +919,36 @@ void KServerSocket::readClient()
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;
@@ -1146,31 +1177,34 @@ void KCommandSocket::readFileFromSocket()
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 );
}