summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/kaddressbook/germantranslation.txt20
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt22
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--libkdepim/ksyncmanager.cpp97
-rw-r--r--libkdepim/ksyncmanager.h6
5 files changed, 125 insertions, 22 deletions
diff --git a/bin/kdepim/kaddressbook/germantranslation.txt b/bin/kdepim/kaddressbook/germantranslation.txt
index f64bfda..4a5122f 100644
--- a/bin/kdepim/kaddressbook/germantranslation.txt
+++ b/bin/kdepim/kaddressbook/germantranslation.txt
@@ -777,17 +777,37 @@
{ "Spouse","Ehegatte" },
{ "Notes","Notizen" },
{ "Messanger","Messanger" },
{ "Assistant","Assistent" },
{ "Manager","Manager" },
{ "Secrecy","Sichtbar" },
{ "male","männlich" },
{ "female","weiblich" },
{ "Hide!","Verbergen!" },
{ "Show!","Anzeigen!" },
{ "Details","Details" },
{ "Search:","Suche:" },
+{ "Automatically sync with KDE-Desktop\nwhen receiving sync request","Synce automatisch mit KDE-Desktop\nwenn eine Sync-Anforderung kommt" },
+{ "Pi-Sync Port Error","Pi-Sync Port Fehler" },
+{ "<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?","<b>Anschalten von Pi-Sync fehlgeschlagen!</b> Fehler beim Ansprechen des Ports %1! Ist bereits eine andere Anwendung dabei diesen Port zu nutzen?" },
+{ "No valid port number:\n%1","Keine gültige Port Nummer:\n%1" },
+{ "Port number (Default: %1)\nValid range from 1 to 65535","Port Nummer (Standard: %1)\nGültiger Bereich von 1 bis 65535" },
+{ "Pi-Sync Error","Pi-Sync Fehler" },
+{ "Got send file request\nwith invalid password","Erhielt "sende Datei" Anfrage\nmit ungültigem Passwort" },
+{ "Got receive file request\nwith invalid password","Erhielt "empfange Datei" Anfrage\nmit ungültigem Passwort" },
+{ "Wrong password: Receiving remote file failed.","Falsches Passwort: Empfangen von entfernter Datei fehlgeschlagen." },
+{ "Please close error dialog on remote.","Bitte schließe Fehler-Dialog am entfernten Rechner" },
+{ "Unknown error on remote.","Unbekannter Fehler am entfernten Rechner" },
+{ "Pi-Sync: Connected!","Pi-Sync: Verbunden!" },
+{ "Receiving file from remote...","Empfange entfernte Datei..." },
+{ "Sending back synced file...","Sende synchronisierte Datei zurück..." },
+{ "Do you want to\nclear all sync info\nof all profiles?","Möchten Sie wirklich\ndie Sync-Info\nfür alle Profile\nlöschen?" },
+{ "Do you want to\nclear the sync\ninfo of profile\n%1?\n","Möchten Sie wirklich\ndie Sync-Info für Profil\n%1?\nlöschen" },
+{ "Sorry, no valid port.Syncing cancelled.","Sorry, kein gültiger Port. Syncing abgebrochen." },
+{ "Remote port number:\n(May be: 1 - 65535)","Ferne Port Nummer:\n(Darf sein: 1 - 65535)" },
+{ "Writing back file ...","Schreibe Datei zurück..." },
+{ "Sending back file ...","Sende Datei zurück..." },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" }, \ No newline at end of file
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index 34e9b7f..ff5e095 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -948,25 +948,24 @@
{ "Addressbook file is used by KA/Pi","Adressbuch Datei wird von KA/Pi genutzt" },
{ "ssh/scp","ssh/scp" },
{ "ftp","ftp" },
{ "Password for remote access: (could be the same for each)","Passwort für entfernten Zugriff: (kann dasselbe sein für alle)" },
{ "Remote IP address: (could be the same for each)","Entfernte IP Adresse: (kann dasselbe sein für alle)" },
{ "Remote port number: (should be different for each)","Entfernte Port Nummer: (Sollte für alle unterschiedlich sein)" },
{ "command for downloading remote file to local device","Kommando zum Download der entfernten Datei zum lokalen Gerät" },
{ "command for uploading local temp file to remote device","Kommando zum Upload der lokalen temp. Datei zum entfernten Gerät" },
{ "Insert device where\nphone is connected. E.g.:\n","Füge Device ein, an dem\ndas Handy angeschlossen ist. Z.B.:\n" },
{ "KDE-Pim sync config","KDE-Pim sync Konfig" },
{ "Insert kind of connection,e.g.:\n","Füge Art der Verbindung ein,z.B.:\n" },
{ "Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n","Empfohlen: Leer lassen!\n(So dass das Model\nautomatisch erkannt\nwerden kann)\nOder füge Model Name ein:\n" },
-{ "Port number (Default: %1)","Port Nummer (Default: %1)" },
{ "Password to enable\naccess from remote:","Passwort um entfernten\nZugriff zuzulassen:" },
{ "Automatically start\nat application startup","Starte automatisch\nbeim Programmstart" },
{ "Automatically sync\nwith KDE-Desktop","Automatischer Sync\nmit dem KDE-Desktop" },
{ "Enter port for Pi-Sync","Port Nummer für Pi-Sync" },
{ "Disable Pi-Sync","Schalte Pi-Sync aus" },
{ "Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!","Wollen Sie wirklich\nmit allen selektierten\nProfilen "Multi-Syncen"?\nDas Syncen dauert einige Zeit -\nalle Profile werden zweimal gesynct!" },
{ "KDE-Pim Sync","KDE-Pim Sync" },
{ "Multiple profiles","Multi-Sync Profile" },
{ "Device: ","Gerät: " },
{ "Multiple sync started.","Multi-Sync gestartet." },
{ "Nothing synced! No profiles defined for multisync!","Nichts gesynct! Keine Profile\nselektiert für Multi-Sync" },
{ "Turn filter on","Schalte Filter an" },
@@ -1497,21 +1496,40 @@
{ "Show next conflict for","Zeige nächsten Konflikt für" },
{ "All events","Alle Termine" },
{ "Allday events","Ganztagestermine" },
{ "Events with time","Termine mit Zeit" },
{ "No conflict found","Kein Konflikt gefunden" },
{ "Conflict %1 <-> %2","Konflikt %1 <-> %2" },
{ "<p><b>Q</b>: Show next date with conflicting events\n ","<p><b>Q</b>: Zeige nächstes Datum mit Terminen im Konflikt\n " },
{ "Week view mode uses row layout","Wochenansicht Modus nutzt Reihenlayout" },
{ "The event\n%1\nconflicts with event\n%2\nat date\n%3.\n","Der Termin\n%1\nist im Konflikt mit Termin\n%2\nam Datum\n%3.\n" },
{ "KO/Pi Conflict delected","KO/Pi Konflikt erkannt" },
{ "Show date","Zeige Datum" },
{ "No problem!","Null Problemo!" },
-{ "","" },
+{ "Automatically sync with KDE-Desktop\nwhen receiving sync request","Synce automatisch mit KDE-Desktop\nwenn eine Sync-Anforderung kommt" },
+{ "Pi-Sync Port Error","Pi-Sync Port Fehler" },
+{ "<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?","<b>Anschalten von Pi-Sync fehlgeschlagen!</b> Fehler beim Ansprechen des Ports %1! Ist bereits eine andere Anwendung dabei diesen Port zu nutzen?" },
+{ "No valid port number:\n%1","Keine gültige Port Nummer:\n%1" },
+{ "Port number (Default: %1)\nValid range from 1 to 65535","Port Nummer (Standard: %1)\nGültiger Bereich von 1 bis 65535" },
+{ "Pi-Sync Error","Pi-Sync Fehler" },
+{ "Got send file request\nwith invalid password","Erhielt "sende Datei" Anfrage\nmit ungültigem Passwort" },
+{ "Got receive file request\nwith invalid password","Erhielt "empfange Datei" Anfrage\nmit ungültigem Passwort" },
+{ "Wrong password: Receiving remote file failed.","Falsches Passwort: Empfangen von entfernter Datei fehlgeschlagen." },
+{ "Please close error dialog on remote.","Bitte schließe Fehler-Dialog am entfernten Rechner" },
+{ "Unknown error on remote.","Unbekannter Fehler am entfernten Rechner" },
+{ "Pi-Sync: Connected!","Pi-Sync: Verbunden!" },
+{ "Receiving file from remote...","Empfange entfernte Datei..." },
+{ "Sending back synced file...","Sende synchronisierte Datei zurück..." },
+{ "Do you want to\nclear all sync info\nof all profiles?","Möchten Sie wirklich\ndie Sync-Info\nfür alle Profile\nlöschen?" },
+{ "Do you want to\nclear the sync\ninfo of profile\n%1?\n","Möchten Sie wirklich\ndie Sync-Info für Profil\n%1?\nlöschen" },
+{ "Sorry, no valid port.Syncing cancelled.","Sorry, kein gültiger Port. Syncing abgebrochen." },
+{ "Remote port number:\n(May be: 1 - 65535)","Ferne Port Nummer:\n(Darf sein: 1 - 65535)" },
+{ "Writing back file ...","Schreibe Datei zurück..." },
+{ "Sending back file ...","Sende Datei zurück..." },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 68d1bc6..940ea91 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -439,25 +439,25 @@ void CalendarView::init()
} else {
//mainBoxLayout = new QHBoxLayout(mainBox);
//leftFrameLayout = new QVBoxLayout(leftFrame );
mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
}
mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
//QBoxLayout * leftFrameLayout;
topLayout->addWidget( mMainFrame );
#ifdef DESKTOP_VERSION
- mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this );
+ mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
topLayout->addWidget( mDateScrollBar );
connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
if ( QApplication::desktop()->width() < 800 )
mDateScrollBar->hide();
#endif
//mainBoxLayout->addWidget (mLeftFrame);
mDateNavigator = new DateNavigatorContainer( mLeftFrame,
"CalendarView::DateNavigator" );
#if 0
// FIXME
mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
"CalendarView::DateNavigator", QDate::currentDate());
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index fc0ac6b..f2ee0ab 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -344,25 +344,25 @@ void KSyncManager::slotSyncMenu( int action )
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)").arg(po), &dia );
+ 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
@@ -406,46 +406,51 @@ void KSyncManager::enableQuick( bool ask )
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;
- Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
- if ( ! ok ) {
- KMessageBox::information( 0, i18n("No valid port"));
+ Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok);
+ qDebug("%d ", port_t);
+ if ( ! ok || port_t > 65535 ) {
+ KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error"));
return;
}
+ Q_UINT16 port = port_t;
//qDebug("port %d ", port);
mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
mServerSocket->setFileName( defaultFileName() );//bbb
if ( !mServerSocket->ok() ) {
- KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
+ QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) );
delete mServerSocket;
mServerSocket = 0;
return;
}
mPrefs->mPassiveSyncAutoStart = autoStart;
if ( changed ) {
mPrefs->writeConfig();
}
connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
}
-
+void KSyncManager::displayErrorPort()
+{
+ KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
+}
void KSyncManager::syncLocalFile()
{
QString fn =mPrefs->mLastSyncedLocalFile;
QString ext;
switch(mTargetApp)
{
case (KAPI):
ext = "(*.vcf)";
break;
case (KOPI):
@@ -787,25 +792,25 @@ bool KSyncManager::edit_pisync_options()
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);
+ QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &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();
@@ -1179,26 +1184,28 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
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( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
- if ( mWriteBackFile && syncOK )
+ 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;
@@ -1283,29 +1290,29 @@ void KServerSocket::readClient()
end_connect();
}
}
if ( tokens[0] == "STOP" ) {
//emit endConnect();
end_connect();
}
}
}
void KServerSocket::displayErrorMessage()
{
if ( mErrorMessage == 1 ) {
- KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
+ KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error"));
mErrorMessage = 0;
}
else if ( mErrorMessage == 2 ) {
- KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
+ KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
mErrorMessage = 0;
}
}
void KServerSocket::error_connect( QString errmess )
{
QTextStream os( mSocket );
os.setEncoding( QTextStream::Latin1 );
os << errmess ;
mSocket->close();
if ( mSocket->state() == QSocket::Idle ) {
QTimer::singleShot( 0, this , SLOT ( discardClient()));
}
@@ -1457,129 +1464,172 @@ void KServerSocket::readBackFileFromSocket()
KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
{
mPassWord = password;
mSocket = 0;
mFirst = false;
mFirstLine = true;
mPort = port;
mHost = host;
tlw = cap;
mRetVal = quiet;
mTimerSocket = new QTimer ( this );
- connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
+ connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
+ mConnectProgress.setCaption( i18n("Pi-Sync") );
+ connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
+ mConnectCount = -1;
}
void KCommandSocket::sendFileRequest()
{
if ( tlw )
tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
- mTimerSocket->start( 300000 );
+ mConnectProgress.hide();
+ mConnectCount = 300;mConnectMax = 300;
+ mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
+ mTimerSocket->start( 100, true );
QTextStream os( mSocket );
os.setEncoding( QTextStream::Latin1 );
QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
os << "GET " << mPassWord << curDt <<"\r\n\r\n";
}
void KCommandSocket::readFile( QString fn )
{
if ( !mSocket ) {
mSocket = new QSocket( this );
connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
}
mFileString = "";
mFileName = fn;
mFirst = true;
if ( tlw )
tlw->setCaption( i18n("Trying to connect to remote...") );
- mTimerSocket->start( 20000 );
+ mConnectCount = 30;mConnectMax = 30;
+ mTimerSocket->start( 1000, true );
mSocket->connectToHost( mHost, mPort );
qDebug("KSS: Waiting for connection");
}
-
+void KCommandSocket::updateConnectDialog()
+{
+
+ if ( mConnectCount == mConnectMax ) {
+ //qDebug("MAXX %d", mConnectMax);
+ mConnectProgress.setTotalSteps ( 30 );
+ mConnectProgress.show();
+ mConnectProgress.setLabelText( i18n("Trying to connect to remote...") );
+ }
+ //qDebug("updateConnectDialog() %d", mConnectCount);
+ mConnectProgress.raise();
+ mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 );
+ --mConnectCount;
+ if ( mConnectCount > 0 )
+ mTimerSocket->start( 1000, true );
+ else
+ deleteSocket();
+
+}
void KCommandSocket::writeFile( QString fileName )
{
if ( !mSocket ) {
mSocket = new QSocket( this );
connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
}
mFileName = fileName ;
- mTimerSocket->start( 20000 );
+ mConnectCount = 30;mConnectMax = 30;
+ mTimerSocket->start( 1000, true );
mSocket->connectToHost( mHost, mPort );
}
void KCommandSocket::writeFileToSocket()
{
mTimerSocket->stop();
QFile file2( mFileName );
if (!file2.open( IO_ReadOnly ) ) {
+ mConnectProgress.hide();
+ mConnectCount = -1;
mRetVal= errorW;
mSocket->close();
if ( mSocket->state() == QSocket::Idle )
QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
return ;
}
+ mConnectProgress.setTotalSteps ( file2.size() );
+ mConnectProgress.show();
+ int count = 0;
+ mConnectProgress.setLabelText( i18n("Sending back synced file...") );
+ mConnectProgress.setProgress( count );
+ mConnectProgress.blockSignals( true );
QTextStream ts2( &file2 );
ts2.setEncoding( QTextStream::Latin1 );
QTextStream os2( mSocket );
os2.setEncoding( QTextStream::Latin1 );
os2 << "PUT " << mPassWord << "\r\n\r\n";;
while ( ! ts2.atEnd() ) {
- os2 << ts2.readLine() << "\r\n";
+ qApp->processEvents();
+ mConnectProgress.setProgress( count );
+ QString temp = ts2.readLine();
+ count += temp.length();
+ os2 << temp << "\r\n";
}
+ file2.close();
+ mConnectProgress.hide();
+ mConnectCount = -1;
os2 << "\r\n";
mRetVal= successW;
- file2.close();
mSocket->close();
if ( mSocket->state() == QSocket::Idle )
QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
+ mConnectProgress.blockSignals( false );
}
void KCommandSocket::sendStop()
{
if ( !mSocket ) {
mSocket = new QSocket( this );
connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
}
mSocket->connectToHost( mHost, mPort );
QTextStream os2( mSocket );
os2.setEncoding( QTextStream::Latin1 );
os2 << "STOP\r\n\r\n";
mSocket->close();
if ( mSocket->state() == QSocket::Idle )
QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
}
void KCommandSocket::startReadFileFromSocket()
{
if ( ! mFirst )
return;
+ mConnectProgress.setLabelText( i18n("Receiving file from remote...") );
mFirst = false;
- mTimerSocket->stop();
mFileString = "";
mTime.start();
mFirstLine = true;
QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
}
void KCommandSocket::readFileFromSocket()
{
//qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
while ( mSocket->canReadLine () ) {
mTime.restart();
QString line = mSocket->readLine ();
if ( mFirstLine ) {
mFirstLine = false;
if ( line.left( 6 ) == "ERROR_" ) {
+ mTimerSocket->stop();
+ mConnectCount = -1;
if ( line.left( 8 ) == "ERROR_PW" ) {
mRetVal = errorPW;
deleteSocket();
return ;
}
if ( line.left( 8 ) == "ERROR_CA" ) {
mRetVal = errorCA;
deleteSocket();
return ;
}
if ( line.left( 8 ) == "ERROR_FI" ) {
mRetVal = errorFI;
@@ -1596,24 +1646,27 @@ void KCommandSocket::readFileFromSocket()
return ;
}
}
mFileString += line;
//qDebug("readline: %s ", line.latin1());
}
if ( mTime.elapsed () < 3000 ) {
// wait for more
//qDebug("waitformore ");
QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
return;
}
+ mTimerSocket->stop();
+ mConnectCount = -1;
+ mConnectProgress.hide();
QString fileName = mFileName;
QFile file ( fileName );
if (!file.open( IO_WriteOnly ) ) {
mFileString = "";
mRetVal = errorR;
qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
deleteSocket();
return ;
}
// mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
QTextStream ts ( &file );
@@ -1623,33 +1676,39 @@ void KCommandSocket::readFileFromSocket()
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 () ) {
+ mConnectProgress.hide();
+
+ if ( mConnectCount >= 0 ) {
mTimerSocket->stop();
mRetVal = errorTO;
qDebug("KCS::Connection to remote host timed out");
if ( mSocket ) {
mSocket->close();
//if ( mSocket->state() == QSocket::Idle )
// deleteSocket();
delete mSocket;
mSocket = 0;
}
+ if ( mConnectCount == 0 )
KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?"));
+ else if ( tlw )
+ tlw->setCaption( i18n("Connection to remote host cancelled!") );
emit commandFinished( this, mRetVal );
return;
}
//qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
if ( mSocket)
delete mSocket;
mSocket = 0;
+ qDebug("commandFinished ");
emit commandFinished( this, mRetVal );
}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 30ec1e6..e6738b6 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -20,24 +20,25 @@
$Id$
*/
#ifndef _KSYNCMANAGER_H
#define _KSYNCMANAGER_H
#include <qobject.h>
#include <qstring.h>
#include <qsocket.h>
#include <qdatetime.h>
#include <qserversocket.h>
#include <qtextstream.h>
#include <qregexp.h>
+#include <qprogressdialog.h>
class QPopupMenu;
class KSyncProfile;
class KPimPrefs;
class QWidget;
class KSyncManager;
class KSyncInterface;
class QProgressBar;
class KServerSocket : public QServerSocket
{
@@ -77,33 +78,37 @@ class KServerSocket : public QServerSocket
class KCommandSocket : public QObject
{
Q_OBJECT
public:
enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet };
KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
void readFile( QString );
void writeFile( QString );
void sendStop();
private slots :
void sendFileRequest();
+ void updateConnectDialog();
signals:
void commandFinished( KCommandSocket*, int );
private slots:
void startReadFileFromSocket();
void readFileFromSocket();
void deleteSocket();
void writeFileToSocket();
private :
+ int mConnectCount;
+ int mConnectMax;
+ QProgressDialog mConnectProgress;
QWidget* tlw;
QSocket* mSocket;
QString mPassWord;
Q_UINT16 mPort;
QString mHost;
QString mFileName;
QTimer* mTimerSocket;
int mRetVal;
QTime mTime;
QString mFileString;
bool mFirst;
bool mFirstLine;
@@ -196,24 +201,25 @@ class KSyncManager : public QObject
int ringSync();
QString getPassword( );
bool mPisyncFinished;
bool mBlockSaveFlag;
QWidget* mParent;
KSyncInterface* mImplementation;
TargetApp mTargetApp;
QPopupMenu* mSyncMenu;
QProgressBar* bar;
bool mSyncWithDesktop;
private slots:
+ void displayErrorPort();
void confSync();
};
class KSyncInterface
{
public :
virtual void removeSyncInfo( QString syncProfile) = 0;
virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
virtual bool syncExternal(KSyncManager* manager, QString resource)