-rw-r--r-- | korganizer/mainwindow.h | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 47a7a90..58081f6 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -6,2 +6,3 @@ #include <qdict.h> +#include <qregexp.h> @@ -19,2 +20,52 @@ class KSyncProfile; class QPEToolBar; +#include <qserversocket.h> +#include <qsocket.h> +#include <qnetworkprotocol.h> + +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 ); + } + +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(); + } + } + } +}; + @@ -90,3 +141,11 @@ class MainWindow : public QMainWindow + private slots: + void fillSyncMenu(); + void sendFile(QSocket* s); + void getFile(QSocket* socket); + void readFileFromSocket(); + void endConnect(); private: + QSocket* mCommandSocket; + KServerSocket * mServerSocket; bool mClosed; @@ -94,4 +153,6 @@ class MainWindow : public QMainWindow int mCurrentSyncProfile; + void enableQuick(); + void performQuick(); + void performQuickQuick(); void syncRemote( KSyncProfile* , bool ask = true); - void fillSyncMenu(); bool mFlagKeyPressed; @@ -120,4 +181,6 @@ class MainWindow : public QMainWindow QPixmap loadPixmap( QString ); + QDialog * mSyncActionDialog; }; + #endif |