summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp23
-rw-r--r--korganizer/mainwindow.h1
2 files changed, 15 insertions, 9 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index fe7e6d3..b7176a1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -2517,51 +2517,56 @@ void KCommandSocket::readFile( QString fn )
2517 mFileString = ""; 2517 mFileString = "";
2518 mFileName = fn; 2518 mFileName = fn;
2519 mFirst = true; 2519 mFirst = true;
2520 mSocket->connectToHost( mHost, mPort ); 2520 mSocket->connectToHost( mHost, mPort );
2521 QTextStream os( mSocket ); 2521 QTextStream os( mSocket );
2522 os.setEncoding( QTextStream::UnicodeUTF8 ); 2522 os.setEncoding( QTextStream::UnicodeUTF8 );
2523 os << "GET " << mPassWord << "\r\n"; 2523 os << "GET " << mPassWord << "\r\n";
2524 mTimerSocket->start( 10000 ); 2524 mTimerSocket->start( 10000 );
2525} 2525}
2526 2526
2527void KCommandSocket::writeFile( QString fileName ) 2527void KCommandSocket::writeFile( QString fileName )
2528{ 2528{
2529 QFile file2( fileName );
2530 if (!file2.open( IO_ReadOnly ) ) {
2531 mRetVal= false;
2532 deleteSocket();
2533 return ;
2534
2535 }
2536 if ( !mSocket ) { 2529 if ( !mSocket ) {
2537 mSocket = new QSocket( this ); 2530 mSocket = new QSocket( this );
2538 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2531 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2532 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
2539 } 2533 }
2534 mFileName = fileName ;
2540 mSocket->connectToHost( mHost, mPort ); 2535 mSocket->connectToHost( mHost, mPort );
2536}
2537void KCommandSocket::writeFileToSocket()
2538{
2539 QFile file2( mFileName );
2540 if (!file2.open( IO_ReadOnly ) ) {
2541 mRetVal= false;
2542 mSocket->close();
2543 if ( mSocket->state() == QSocket::Idle )
2544 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2545 return ;
2546 }
2541 QTextStream ts2( &file2 ); 2547 QTextStream ts2( &file2 );
2542 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2548 ts2.setCodec( QTextCodec::codecForName("utf8") );
2543 QTextStream os2( mSocket ); 2549 QTextStream os2( mSocket );
2544 os2.setCodec( QTextCodec::codecForName("utf8") ); 2550 os2.setCodec( QTextCodec::codecForName("utf8") );
2545 os2 << "PUT " << mPassWord << "\r\n";; 2551 os2 << "PUT " << mPassWord << "\r\n";;
2546 while ( ! ts2.atEnd() ) { 2552 while ( ! ts2.atEnd() ) {
2547 os2 << ts2.readLine() << "\n"; 2553 os2 << ts2.readLine() << "\n";
2548 } 2554 }
2549 mRetVal= true; 2555 mRetVal= true;
2556 file2.close();
2550 mSocket->close(); 2557 mSocket->close();
2551 if ( mSocket->state() == QSocket::Idle ) 2558 if ( mSocket->state() == QSocket::Idle )
2552 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2559 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2553 file2.close();
2554} 2560}
2555
2556void KCommandSocket::sendStop() 2561void KCommandSocket::sendStop()
2557{ 2562{
2558 if ( !mSocket ) { 2563 if ( !mSocket ) {
2559 mSocket = new QSocket( this ); 2564 mSocket = new QSocket( this );
2560 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2565 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2561 } 2566 }
2562 mSocket->connectToHost( mHost, mPort ); 2567 mSocket->connectToHost( mHost, mPort );
2563 QTextStream os2( mSocket ); 2568 QTextStream os2( mSocket );
2564 os2.setCodec( QTextCodec::codecForName("utf8") ); 2569 os2.setCodec( QTextCodec::codecForName("utf8") );
2565 os2 << "STOP\r\n"; 2570 os2 << "STOP\r\n";
2566 mRetVal= true; 2571 mRetVal= true;
2567 mSocket->close(); 2572 mSocket->close();
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index f8b2334..90b3a88 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -66,24 +66,25 @@ public:
66 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 66 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
67 void readFile( QString ); 67 void readFile( QString );
68 void writeFile( QString ); 68 void writeFile( QString );
69 void sendStop(); 69 void sendStop();
70 70
71 71
72signals: 72signals:
73 void commandFinished( KCommandSocket*, bool ); 73 void commandFinished( KCommandSocket*, bool );
74private slots: 74private slots:
75 void startReadFileFromSocket(); 75 void startReadFileFromSocket();
76 void readFileFromSocket(); 76 void readFileFromSocket();
77 void deleteSocket(); 77 void deleteSocket();
78 void writeFileToSocket();
78 private : 79 private :
79 QSocket* mSocket; 80 QSocket* mSocket;
80 QString mPassWord; 81 QString mPassWord;
81 Q_UINT16 mPort; 82 Q_UINT16 mPort;
82 QString mHost; 83 QString mHost;
83 QString mFileName; 84 QString mFileName;
84 QTimer* mTimerSocket; 85 QTimer* mTimerSocket;
85 bool mRetVal; 86 bool mRetVal;
86 QTime mTime; 87 QTime mTime;
87 QString mFileString; 88 QString mFileString;
88 bool mFirst; 89 bool mFirst;
89}; 90};