-rw-r--r-- | korganizer/mainwindow.cpp | 105 |
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 | |||
@@ -1,12 +1,13 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | ||
7 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
8 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
9 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
10 | #include <qfile.h> | 11 | #include <qfile.h> |
11 | #include <qdir.h> | 12 | #include <qdir.h> |
12 | #include <qapp.h> | 13 | #include <qapp.h> |
@@ -21,12 +22,13 @@ | |||
21 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
24 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
25 | #include <qtopia/alarmserver.h> | 26 | #include <qtopia/alarmserver.h> |
26 | #include <qtopia/qcopenvelope_qws.h> | 27 | #include <qtopia/qcopenvelope_qws.h> |
28 | #include <unistd.h> // for sleep | ||
27 | #else | 29 | #else |
28 | #include <qmenubar.h> | 30 | #include <qmenubar.h> |
29 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
30 | #include <qapplication.h> | 32 | #include <qapplication.h> |
31 | //#include <resource.h> | 33 | //#include <resource.h> |
32 | 34 | ||
@@ -1143,18 +1145,13 @@ void MainWindow::features() | |||
1143 | 1145 | ||
1144 | void MainWindow::usertrans() | 1146 | void MainWindow::usertrans() |
1145 | { | 1147 | { |
1146 | 1148 | ||
1147 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1149 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1148 | } | 1150 | } |
1149 | #if 0 | 1151 | |
1150 | #include <libkcal/vcalformat.h> | ||
1151 | #include <libkcal/event.h> | ||
1152 | #include <libkcal/todo.h> | ||
1153 | #include <libkcal/incidence.h> | ||
1154 | #endif | ||
1155 | void MainWindow::synchowto() | 1152 | void MainWindow::synchowto() |
1156 | { | 1153 | { |
1157 | #if 0 | 1154 | #if 0 |
1158 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1155 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1159 | Incidence* inR = er.first(); | 1156 | Incidence* inR = er.first(); |
1160 | VCalFormat vf; | 1157 | VCalFormat vf; |
@@ -1425,13 +1422,12 @@ void MainWindow::slotModifiedChanged( bool changed ) | |||
1425 | else | 1422 | else |
1426 | msec = 1000 * 600; | 1423 | msec = 1000 * 600; |
1427 | mSaveTimer.start( msec, true ); // 1 minute | 1424 | mSaveTimer.start( msec, true ); // 1 minute |
1428 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1425 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1429 | mCalendarModifiedFlag = true; | 1426 | mCalendarModifiedFlag = true; |
1430 | } | 1427 | } |
1431 | #include <qfileinfo.h> | ||
1432 | void MainWindow::save() | 1428 | void MainWindow::save() |
1433 | { | 1429 | { |
1434 | if ( mBlockSaveFlag ) | 1430 | if ( mBlockSaveFlag ) |
1435 | return; | 1431 | return; |
1436 | bool store = mBlockSaveFlag; | 1432 | bool store = mBlockSaveFlag; |
1437 | mBlockSaveFlag = true; | 1433 | mBlockSaveFlag = true; |
@@ -1863,13 +1859,12 @@ void MainWindow::exportVCalendar() | |||
1863 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1859 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1864 | setCaption(mes); | 1860 | setCaption(mes); |
1865 | } | 1861 | } |
1866 | } | 1862 | } |
1867 | 1863 | ||
1868 | } | 1864 | } |
1869 | #include <qpushbutton.h> | ||
1870 | QString MainWindow::getPassword( ) | 1865 | QString MainWindow::getPassword( ) |
1871 | { | 1866 | { |
1872 | QString retfile = ""; | 1867 | QString retfile = ""; |
1873 | QDialog dia ( this, "input-dialog", true ); | 1868 | QDialog dia ( this, "input-dialog", true ); |
1874 | QLineEdit lab ( &dia ); | 1869 | QLineEdit lab ( &dia ); |
1875 | lab.setEchoMode( QLineEdit::Password ); | 1870 | lab.setEchoMode( QLineEdit::Password ); |
@@ -1998,15 +1993,48 @@ void MainWindow::getFile(QSocket* socket) | |||
1998 | QTextStream ts( &file ); | 1993 | QTextStream ts( &file ); |
1999 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1994 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2000 | bool first = true; | 1995 | bool first = true; |
2001 | while ( socket->canReadLine () || first ) { | 1996 | while ( socket->canReadLine () || first ) { |
2002 | first = false; | 1997 | first = false; |
2003 | while ( socket->canReadLine () ) { | 1998 | while ( socket->canReadLine () ) { |
1999 | qDebug("avail %d ", socket->bytesAvailable () ); | ||
2004 | ts << socket->readLine (); | 2000 | ts << socket->readLine (); |
2005 | } | 2001 | } |
2002 | QTime ti; | ||
2003 | ti.start(); | ||
2004 | while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { | ||
2005 | qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); | ||
2006 | //qApp->processEvents(); | ||
2007 | qDebug("waiting1b %d ",ti.elapsed () ); | ||
2008 | if ( !socket->canReadLine () ) { | ||
2009 | qDebug("waiting1c %d ",ti.elapsed () ); | ||
2010 | usleep( 100000); | ||
2011 | } | ||
2012 | //socket->waitForMore ( 100 ); | ||
2013 | } | ||
2014 | ts << socket->readLine (); | ||
2015 | #if 0 | ||
2016 | #ifdef DESKTOP_VERSION | ||
2006 | socket->waitForMore ( 5000 ); | 2017 | socket->waitForMore ( 5000 ); |
2018 | #else | ||
2019 | // socket->waitForMore ( 5000 ); | ||
2020 | // seems to be broken in qt2 | ||
2021 | bool stop = false; | ||
2022 | QTime ti; | ||
2023 | ti.start(); | ||
2024 | while ( ti.elapsed < 5000 && !stop ) { | ||
2025 | qApp->processEvents(); | ||
2026 | if ( socket->canReadLine () ) | ||
2027 | stop = true ; | ||
2028 | else { | ||
2029 | usleep( 100000 ); | ||
2030 | |||
2031 | } | ||
2032 | } | ||
2033 | #endif | ||
2034 | #endif | ||
2007 | } | 2035 | } |
2008 | setCaption( i18n("File received - reloading calendar...") ); | 2036 | setCaption( i18n("File received - reloading calendar...") ); |
2009 | file.close(); | 2037 | file.close(); |
2010 | socket->close(); | 2038 | socket->close(); |
2011 | mView->watchSavedFile(); | 2039 | mView->watchSavedFile(); |
2012 | mView->openCalendar( defaultFileName() ); | 2040 | mView->openCalendar( defaultFileName() ); |
@@ -2107,13 +2135,21 @@ QString fileName; | |||
2107 | bool first = true; | 2135 | bool first = true; |
2108 | while ( mCommandSocket->canReadLine () || first) { | 2136 | while ( mCommandSocket->canReadLine () || first) { |
2109 | first = false; | 2137 | first = false; |
2110 | while ( mCommandSocket->canReadLine () ) { | 2138 | while ( mCommandSocket->canReadLine () ) { |
2111 | ts << mCommandSocket->readLine (); | 2139 | ts << mCommandSocket->readLine (); |
2112 | } | 2140 | } |
2113 | mCommandSocket->waitForMore ( 5000 ); | 2141 | QTime ti; |
2142 | ti.start(); | ||
2143 | while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { | ||
2144 | qApp->processEvents(); | ||
2145 | qDebug("waiting2 %d ",ti.elapsed () ); | ||
2146 | if ( !mCommandSocket->canReadLine () ) | ||
2147 | mCommandSocket->waitForMore ( 100 ); | ||
2148 | } | ||
2149 | //mCommandSocket->waitForMore ( 5000 ); | ||
2114 | } | 2150 | } |
2115 | file.close(); | 2151 | file.close(); |
2116 | mCommandSocket->close(); | 2152 | mCommandSocket->close(); |
2117 | //delete mCommandSocket; | 2153 | //delete mCommandSocket; |
2118 | setCaption( i18n("Remote file saved to temp file.") ); | 2154 | setCaption( i18n("Remote file saved to temp file.") ); |
2119 | //mCommandSocket = 0; | 2155 | //mCommandSocket = 0; |
@@ -2449,6 +2485,57 @@ void MainWindow::printSel( ) | |||
2449 | } | 2485 | } |
2450 | 2486 | ||
2451 | void MainWindow::printCal() | 2487 | void MainWindow::printCal() |
2452 | { | 2488 | { |
2453 | mView->print();//mCp->showDialog(); | 2489 | mView->print();//mCp->showDialog(); |
2454 | } | 2490 | } |
2491 | |||
2492 | |||
2493 | |||
2494 | KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ){;}; | ||
2495 | |||
2496 | void KServerSocket::newConnection ( int socket ) | ||
2497 | { | ||
2498 | qDebug("KServerSocket:New connection %d ", socket); | ||
2499 | QSocket* s = new QSocket( this ); | ||
2500 | connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); | ||
2501 | connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | ||
2502 | s->setSocket( socket ); | ||
2503 | } | ||
2504 | |||
2505 | void KServerSocket::discardClient() | ||
2506 | { | ||
2507 | qDebug(" KServerSocket::discardClient()"); | ||
2508 | QSocket* socket = (QSocket*)sender(); | ||
2509 | delete socket; | ||
2510 | //emit endConnect(); | ||
2511 | } | ||
2512 | void KServerSocket::readClient() | ||
2513 | { | ||
2514 | qDebug("KServerSocket readClient()"); | ||
2515 | QSocket* socket = (QSocket*)sender(); | ||
2516 | if ( socket->canReadLine() ) { | ||
2517 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); | ||
2518 | qDebug("KServerSocket socket->canReadLine()"); | ||
2519 | if ( tokens[0] == "GET" ) { | ||
2520 | emit sendFile( socket ); | ||
2521 | } | ||
2522 | if ( tokens[0] == "PUT" ) { | ||
2523 | emit getFile( socket ); | ||
2524 | } | ||
2525 | if ( tokens[0] == "STOP" ) { | ||
2526 | emit endConnect(); | ||
2527 | } | ||
2528 | } | ||
2529 | } | ||
2530 | |||
2531 | |||
2532 | |||
2533 | |||
2534 | |||
2535 | |||
2536 | |||
2537 | |||
2538 | |||
2539 | |||
2540 | |||
2541 | |||