summaryrefslogtreecommitdiffabout
path: root/korganizer/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp105
1 files changed, 96 insertions, 9 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2e6b5c8..460bbdc 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -4,6 +4,7 @@
#include <qpopupmenu.h>
#include <qpainter.h>
#include <qwhatsthis.h>
+#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qtextcodec.h>
@@ -24,6 +25,7 @@
#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>
@@ -1146,12 +1148,7 @@ 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
@@ -1428,7 +1425,6 @@ void MainWindow::slotModifiedChanged( bool changed )
qDebug("KO: Saving File in %d secs!", msec/1000);
mCalendarModifiedFlag = true;
}
-#include <qfileinfo.h>
void MainWindow::save()
{
if ( mBlockSaveFlag )
@@ -1866,7 +1862,6 @@ void MainWindow::exportVCalendar()
}
}
-#include <qpushbutton.h>
QString MainWindow::getPassword( )
{
QString retfile = "";
@@ -2001,9 +1996,42 @@ void MainWindow::getFile(QSocket* socket)
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();
@@ -2110,7 +2138,15 @@ QString fileName;
while ( mCommandSocket->canReadLine () ) {
ts << mCommandSocket->readLine ();
}
- mCommandSocket->waitForMore ( 5000 );
+ 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 );
}
file.close();
mCommandSocket->close();
@@ -2452,3 +2488,54 @@ 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();
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+