-rw-r--r-- | korganizer/mainwindow.cpp | 105 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 38 |
2 files changed, 101 insertions, 42 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 2e6b5c8..460bbdc 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1,12 +1,13 @@ #include <stdlib.h> #include <qaction.h> #include <qpopupmenu.h> #include <qpainter.h> #include <qwhatsthis.h> +#include <qpushbutton.h> #include <qmessagebox.h> #include <qlineedit.h> #include <qtextcodec.h> #include <qfile.h> #include <qdir.h> #include <qapp.h> @@ -21,12 +22,13 @@ #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qtopia/alarmserver.h> #include <qtopia/qcopenvelope_qws.h> +#include <unistd.h> // for sleep #else #include <qmenubar.h> #include <qtoolbar.h> #include <qapplication.h> //#include <resource.h> @@ -1143,18 +1145,13 @@ void MainWindow::features() void MainWindow::usertrans() { displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); } -#if 0 -#include <libkcal/vcalformat.h> -#include <libkcal/event.h> -#include <libkcal/todo.h> -#include <libkcal/incidence.h> -#endif + void MainWindow::synchowto() { #if 0 QPtrList<Incidence> er = mCalendar->rawIncidences(); Incidence* inR = er.first(); VCalFormat vf; @@ -1425,13 +1422,12 @@ void MainWindow::slotModifiedChanged( bool changed ) else msec = 1000 * 600; mSaveTimer.start( msec, true ); // 1 minute qDebug("KO: Saving File in %d secs!", msec/1000); mCalendarModifiedFlag = true; } -#include <qfileinfo.h> void MainWindow::save() { if ( mBlockSaveFlag ) return; bool store = mBlockSaveFlag; mBlockSaveFlag = true; @@ -1863,13 +1859,12 @@ void MainWindow::exportVCalendar() mes = i18n("KO/Pi:Exported to %1").arg(fn ); setCaption(mes); } } } -#include <qpushbutton.h> QString MainWindow::getPassword( ) { QString retfile = ""; QDialog dia ( this, "input-dialog", true ); QLineEdit lab ( &dia ); lab.setEchoMode( QLineEdit::Password ); @@ -1998,15 +1993,48 @@ void MainWindow::getFile(QSocket* socket) QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); bool first = true; while ( socket->canReadLine () || first ) { first = false; while ( socket->canReadLine () ) { + qDebug("avail %d ", socket->bytesAvailable () ); ts << socket->readLine (); } + QTime ti; + ti.start(); + while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { + qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); + //qApp->processEvents(); + qDebug("waiting1b %d ",ti.elapsed () ); + if ( !socket->canReadLine () ) { + qDebug("waiting1c %d ",ti.elapsed () ); + usleep( 100000); + } + //socket->waitForMore ( 100 ); + } + ts << socket->readLine (); +#if 0 +#ifdef DESKTOP_VERSION socket->waitForMore ( 5000 ); +#else + // socket->waitForMore ( 5000 ); + // seems to be broken in qt2 + bool stop = false; + QTime ti; + ti.start(); + while ( ti.elapsed < 5000 && !stop ) { + qApp->processEvents(); + if ( socket->canReadLine () ) + stop = true ; + else { + usleep( 100000 ); + + } + } +#endif +#endif } setCaption( i18n("File received - reloading calendar...") ); file.close(); socket->close(); mView->watchSavedFile(); mView->openCalendar( defaultFileName() ); @@ -2106,14 +2134,22 @@ QString fileName; ts.setCodec( QTextCodec::codecForName("utf8") ); bool first = true; while ( mCommandSocket->canReadLine () || first) { first = false; while ( mCommandSocket->canReadLine () ) { ts << mCommandSocket->readLine (); + } + QTime ti; + ti.start(); + while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { + qApp->processEvents(); + qDebug("waiting2 %d ",ti.elapsed () ); + if ( !mCommandSocket->canReadLine () ) + mCommandSocket->waitForMore ( 100 ); } - mCommandSocket->waitForMore ( 5000 ); + //mCommandSocket->waitForMore ( 5000 ); } file.close(); mCommandSocket->close(); //delete mCommandSocket; setCaption( i18n("Remote file saved to temp file.") ); //mCommandSocket = 0; @@ -2449,6 +2485,57 @@ void MainWindow::printSel( ) } void MainWindow::printCal() { mView->print();//mCp->showDialog(); } + + + +KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ){;}; + +void KServerSocket::newConnection ( int socket ) +{ + qDebug("KServerSocket:New connection %d ", socket); + QSocket* s = new QSocket( this ); + connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); + connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); + s->setSocket( socket ); +} + +void KServerSocket::discardClient() +{ + qDebug(" KServerSocket::discardClient()"); + QSocket* socket = (QSocket*)sender(); + delete socket; + //emit endConnect(); +} +void KServerSocket::readClient() +{ + qDebug("KServerSocket readClient()"); + QSocket* socket = (QSocket*)sender(); + if ( socket->canReadLine() ) { + QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); + qDebug("KServerSocket socket->canReadLine()"); + if ( tokens[0] == "GET" ) { + emit sendFile( socket ); + } + if ( tokens[0] == "PUT" ) { + emit getFile( socket ); + } + if ( tokens[0] == "STOP" ) { + emit endConnect(); + } + } +} + + + + + + + + + + + + diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 5985d56..7b4fd27 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -24,51 +24,23 @@ class QPEToolBar; class KServerSocket : public QServerSocket { Q_OBJECT public: - KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ) : - QServerSocket( port, backlog, parent, name ){;}; - void newConnection ( int socket ) - { - qDebug("KServerSocket:New connection %d ", socket); - QSocket* s = new QSocket( this ); - connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); - connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); - s->setSocket( socket ); - } + KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); + + void newConnection ( int socket ) ; signals: void sendFile(QSocket*); void getFile(QSocket*); void endConnect(); private slots: - void discardClient() - { - QSocket* socket = (QSocket*)sender(); - delete socket; - //emit endConnect(); - } - void readClient() - { - qDebug("readClient() "); - QSocket* socket = (QSocket*)sender(); - if ( socket->canReadLine() ) { - QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); - if ( tokens[0] == "GET" ) { - emit sendFile( socket ); - } - if ( tokens[0] == "PUT" ) { - emit getFile( socket ); - } - if ( tokens[0] == "STOP" ) { - emit endConnect(); - } - } - } + void discardClient(); + void readClient(); }; namespace KCal { class CalendarLocal; } |