summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp94
-rw-r--r--libkdepim/ksyncmanager.h7
2 files changed, 74 insertions, 27 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d8ca3ba..47d00a4 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1072,7 +1072,17 @@ void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
//enum { success, errorW, errorR, quiet };
- if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ) {
+
+
+
+ if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
+ state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN ) {
if ( state == KCommandSocket::errorPW )
mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
- else
+ else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
+ else if ( state == KCommandSocket::errorCA )
+ mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
+ else if ( state == KCommandSocket::errorFI )
+ mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
+ else if ( state == KCommandSocket::errorUN )
+ mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
delete s;
@@ -1134,2 +1144,3 @@ KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject
blockRC = false;
+ mErrorMessage = 0;
}
@@ -1152,3 +1163,7 @@ void KServerSocket::discardClient()
{
- //qDebug(" KServerSocket::discardClient()");
+ QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
+}
+void KServerSocket::deleteSocket()
+{
+ qDebug("KSS::deleteSocket");
if ( mSocket ) {
@@ -1157,3 +1172,4 @@ void KServerSocket::discardClient()
}
- //emit endConnect();
+ if ( mErrorMessage )
+ QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
}
@@ -1167,2 +1183,8 @@ void KServerSocket::readClient()
}
+ if ( mErrorMessage ) {
+ mErrorMessage = 999;
+ error_connect("ERROR_UN\r\n\r\n");
+ return;
+ }
+ mErrorMessage = 0;
//qDebug("KServerSocket::readClient()");
@@ -1185,5 +1207,4 @@ void KServerSocket::readClient()
else {
- error_connect();
- KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
- //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
+ mErrorMessage = 1;
+ error_connect("ERROR_PW\r\n\r\n");
}
@@ -1197,6 +1218,5 @@ void KServerSocket::readClient()
else {
- error_connect();
+ mErrorMessage = 2;
+ error_connect("ERROR_PW\r\n\r\n");
end_connect();
- KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
- //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
}
@@ -1209,3 +1229,11 @@ void KServerSocket::readClient()
}
-void KServerSocket::error_connect()
+void KServerSocket::displayErrorMessage()
+{
+ if ( mErrorMessage == 1 )
+ KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
+ else if ( mErrorMessage == 2 )
+ KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
+ mErrorMessage = 0;
+}
+void KServerSocket::error_connect( QString errmess )
{
@@ -1213,6 +1241,7 @@ void KServerSocket::error_connect()
os.setEncoding( QTextStream::Latin1 );
- os << "ERROR_PW\r\n\r\n";
+ os << errmess ;
mSocket->close();
- if ( mSocket->state() == QSocket::Idle )
- QTimer::singleShot( 10, this , SLOT ( discardClient()));
+ if ( mSocket->state() == QSocket::Idle ) {
+ QTimer::singleShot( 0, this , SLOT ( discardClient()));
+ }
}
@@ -1238,2 +1267,3 @@ void KServerSocket::send_file()
int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
+ secs = 333;
if ( secs < 0 )
@@ -1251,3 +1281,6 @@ void KServerSocket::send_file()
if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
- qDebug("KSS::Sync cancelled ,cs");
+ qDebug("KSS::Sync cancelled ,cs");
+ mErrorMessage = 0;
+ end_connect();
+ error_connect("ERROR_CA\r\n\r\n");
return ;
@@ -1280,10 +1313,6 @@ void KServerSocket::send_file()
if (!file.open( IO_ReadOnly ) ) {
- delete mSyncActionDialog;
- mSyncActionDialog = 0;
- qDebug("KSS::error open sync file: %s ", fileName.latin1());
- mSocket->close();
- if ( mSocket->state() == QSocket::Idle )
- QTimer::singleShot( 10, this , SLOT ( discardClient()));
- return ;
-
+ mErrorMessage = 0;
+ end_connect();
+ error_connect("ERROR_FI\r\n\r\n");
+ return ;
}
@@ -1478,4 +1507,19 @@ void KCommandSocket::readFileFromSocket()
mFirstLine = false;
- if ( line.left( 8 ) == "ERROR_PW" ) {
- mRetVal = errorPW;
+ if ( line.left( 6 ) == "ERROR_" ) {
+ 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;
+ deleteSocket();
+ return ;
+ }
+ mRetVal = errorUN;
deleteSocket();
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 810a515..bd3ecdc 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -57,5 +57,8 @@ class KServerSocket : public QServerSocket
void discardClient();
+ void deleteSocket();
void readClient();
+ void displayErrorMessage();
void readBackFileFromSocket();
private :
+ int mErrorMessage;
bool blockRC;
@@ -64,3 +67,3 @@ class KServerSocket : public QServerSocket
void end_connect();
- void error_connect();
+ void error_connect( QString );
QDialog* mSyncActionDialog;
@@ -77,3 +80,3 @@ class KCommandSocket : public QObject
public:
- enum state { successR, errorR, successW, errorW, errorTO, errorPW,quiet };
+ enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN,quiet };
KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );