author | zautrix <zautrix> | 2004-09-23 07:35:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-23 07:35:02 (UTC) |
commit | e395b9a15f5047582c17665de85d28dad64b8a8e (patch) (unidiff) | |
tree | 141b178531d66bfeb810cf9b6f2ba1cd54a7fce5 /korganizer | |
parent | e2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b (diff) | |
download | kdepimpi-e395b9a15f5047582c17665de85d28dad64b8a8e.zip kdepimpi-e395b9a15f5047582c17665de85d28dad64b8a8e.tar.gz kdepimpi-e395b9a15f5047582c17665de85d28dad64b8a8e.tar.bz2 |
fixes in kopi
-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,50 +1,52 @@ | |||
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> |
13 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
14 | #include <qlabel.h> | 15 | #include <qlabel.h> |
15 | #include <qmap.h> | 16 | #include <qmap.h> |
16 | #include <qwmatrix.h> | 17 | #include <qwmatrix.h> |
17 | #include <qtextbrowser.h> | 18 | #include <qtextbrowser.h> |
18 | #include <qtextstream.h> | 19 | #include <qtextstream.h> |
19 | #ifndef DESKTOP_VERSION | 20 | #ifndef DESKTOP_VERSION |
20 | #include <qpe/global.h> | 21 | #include <qpe/global.h> |
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 | ||
33 | #endif | 35 | #endif |
34 | #include <libkcal/calendarlocal.h> | 36 | #include <libkcal/calendarlocal.h> |
35 | #include <libkcal/todo.h> | 37 | #include <libkcal/todo.h> |
36 | #include <libkdepim/ksyncprofile.h> | 38 | #include <libkdepim/ksyncprofile.h> |
37 | #include <libkcal/kincidenceformatter.h> | 39 | #include <libkcal/kincidenceformatter.h> |
38 | #include <libkdepim/kpimglobalprefs.h> | 40 | #include <libkdepim/kpimglobalprefs.h> |
39 | 41 | ||
40 | #include "calendarview.h" | 42 | #include "calendarview.h" |
41 | #include "koviewmanager.h" | 43 | #include "koviewmanager.h" |
42 | #include "datenavigator.h" | 44 | #include "datenavigator.h" |
43 | #include "koagendaview.h" | 45 | #include "koagendaview.h" |
44 | #include "koagenda.h" | 46 | #include "koagenda.h" |
45 | #include "kodialogmanager.h" | 47 | #include "kodialogmanager.h" |
46 | #include "kdialogbase.h" | 48 | #include "kdialogbase.h" |
47 | #include "kapplication.h" | 49 | #include "kapplication.h" |
48 | #include "kofilterview.h" | 50 | #include "kofilterview.h" |
49 | #include "kstandarddirs.h" | 51 | #include "kstandarddirs.h" |
50 | #include "koprefs.h" | 52 | #include "koprefs.h" |
@@ -1125,54 +1127,49 @@ void MainWindow::displayFile( QString fn, QString cap ) | |||
1125 | { | 1127 | { |
1126 | QString fileName = resourcePath() + fn; | 1128 | QString fileName = resourcePath() + fn; |
1127 | QString text; | 1129 | QString text; |
1128 | QFile file( fileName ); | 1130 | QFile file( fileName ); |
1129 | if (!file.open( IO_ReadOnly ) ) { | 1131 | if (!file.open( IO_ReadOnly ) ) { |
1130 | return ; | 1132 | return ; |
1131 | 1133 | ||
1132 | } | 1134 | } |
1133 | QTextStream ts( &file ); | 1135 | QTextStream ts( &file ); |
1134 | text = ts.read(); | 1136 | text = ts.read(); |
1135 | file.close(); | 1137 | file.close(); |
1136 | displayText( text, cap); | 1138 | displayText( text, cap); |
1137 | } | 1139 | } |
1138 | void MainWindow::features() | 1140 | void MainWindow::features() |
1139 | { | 1141 | { |
1140 | 1142 | ||
1141 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1143 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1142 | } | 1144 | } |
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; |
1161 | QString strout; | 1158 | QString strout; |
1162 | while ( inR ) { | 1159 | while ( inR ) { |
1163 | if ( inR->type() == "Todo" ) | 1160 | if ( inR->type() == "Todo" ) |
1164 | strout = vf.todoToString( (Todo *) inR ); | 1161 | strout = vf.todoToString( (Todo *) inR ); |
1165 | if ( inR->type() == "Event" ) | 1162 | if ( inR->type() == "Event" ) |
1166 | strout = vf.eventToString( (Event *) inR ); | 1163 | strout = vf.eventToString( (Event *) inR ); |
1167 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1164 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1168 | inR = er.next(); | 1165 | inR = er.next(); |
1169 | } | 1166 | } |
1170 | #endif | 1167 | #endif |
1171 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1168 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1172 | } | 1169 | } |
1173 | void MainWindow::faq() | 1170 | void MainWindow::faq() |
1174 | { | 1171 | { |
1175 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1172 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1176 | 1173 | ||
1177 | } | 1174 | } |
1178 | void MainWindow::whatsNew() | 1175 | void MainWindow::whatsNew() |
@@ -1407,49 +1404,48 @@ void MainWindow::saveOnClose() | |||
1407 | { | 1404 | { |
1408 | KOPrefs *p = KOPrefs::instance(); | 1405 | KOPrefs *p = KOPrefs::instance(); |
1409 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1406 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1410 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1407 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1411 | iconToolBar->y() > height()/2; | 1408 | iconToolBar->y() > height()/2; |
1412 | mView->writeSettings(); | 1409 | mView->writeSettings(); |
1413 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1410 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1414 | save(); | 1411 | save(); |
1415 | } | 1412 | } |
1416 | void MainWindow::slotModifiedChanged( bool changed ) | 1413 | void MainWindow::slotModifiedChanged( bool changed ) |
1417 | { | 1414 | { |
1418 | if ( mBlockAtStartup ) | 1415 | if ( mBlockAtStartup ) |
1419 | return; | 1416 | return; |
1420 | int msec; | 1417 | int msec; |
1421 | // we store the changes after 1 minute, | 1418 | // we store the changes after 1 minute, |
1422 | // and for safety reasons after 10 minutes again | 1419 | // and for safety reasons after 10 minutes again |
1423 | if ( !mBlockSaveFlag ) | 1420 | if ( !mBlockSaveFlag ) |
1424 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1421 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
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; |
1438 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1434 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1439 | 1435 | ||
1440 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1436 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1441 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1437 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1442 | qDebug("KO: Start saving data to file!"); | 1438 | qDebug("KO: Start saving data to file!"); |
1443 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1439 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1444 | mView->saveCalendar( defaultFileName() ); | 1440 | mView->saveCalendar( defaultFileName() ); |
1445 | 1441 | ||
1446 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1442 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1447 | mView->watchSavedFile(); | 1443 | mView->watchSavedFile(); |
1448 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1444 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1449 | QString savemes; | 1445 | QString savemes; |
1450 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1446 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1451 | setCaption(savemes); | 1447 | setCaption(savemes); |
1452 | } else | 1448 | } else |
1453 | setCaption(i18n("Saving cancelled!")); | 1449 | setCaption(i18n("Saving cancelled!")); |
1454 | mCalendarModifiedFlag = false; | 1450 | mCalendarModifiedFlag = false; |
1455 | mBlockSaveFlag = store; | 1451 | mBlockSaveFlag = store; |
@@ -1845,49 +1841,48 @@ void MainWindow::exportVCalendar() | |||
1845 | info.setFile( fn ); | 1841 | info.setFile( fn ); |
1846 | QString mes; | 1842 | QString mes; |
1847 | bool createbup = true; | 1843 | bool createbup = true; |
1848 | if ( info. exists() ) { | 1844 | if ( info. exists() ) { |
1849 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1845 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1850 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1846 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1851 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1847 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1852 | 0, 1 ); | 1848 | 0, 1 ); |
1853 | if ( result != 0 ) { | 1849 | if ( result != 0 ) { |
1854 | createbup = false; | 1850 | createbup = false; |
1855 | } | 1851 | } |
1856 | } | 1852 | } |
1857 | if ( createbup ) { | 1853 | if ( createbup ) { |
1858 | if ( mView->exportVCalendar( fn ) ) { | 1854 | if ( mView->exportVCalendar( fn ) ) { |
1859 | KOPrefs::instance()->mLastVcalFile = fn; | 1855 | KOPrefs::instance()->mLastVcalFile = fn; |
1860 | if ( fn.length() > 20 ) | 1856 | if ( fn.length() > 20 ) |
1861 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1857 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1862 | else | 1858 | else |
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 ); |
1876 | QVBoxLayout lay( &dia ); | 1871 | QVBoxLayout lay( &dia ); |
1877 | lay.setMargin(7); | 1872 | lay.setMargin(7); |
1878 | lay.setSpacing(7); | 1873 | lay.setSpacing(7); |
1879 | lay.addWidget( &lab); | 1874 | lay.addWidget( &lab); |
1880 | dia.setFixedSize( 230,50 ); | 1875 | dia.setFixedSize( 230,50 ); |
1881 | dia.setCaption( i18n("Enter password") ); | 1876 | dia.setCaption( i18n("Enter password") ); |
1882 | QPushButton pb ( "OK", &dia); | 1877 | QPushButton pb ( "OK", &dia); |
1883 | lay.addWidget( &pb ); | 1878 | lay.addWidget( &pb ); |
1884 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1879 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1885 | dia.show(); | 1880 | dia.show(); |
1886 | int res = dia.exec(); | 1881 | int res = dia.exec(); |
1887 | if ( res ) | 1882 | if ( res ) |
1888 | retfile = lab.text(); | 1883 | retfile = lab.text(); |
1889 | dia.hide(); | 1884 | dia.hide(); |
1890 | qApp->processEvents(); | 1885 | qApp->processEvents(); |
1891 | return retfile; | 1886 | return retfile; |
1892 | 1887 | ||
1893 | } | 1888 | } |
@@ -1980,51 +1975,84 @@ void MainWindow::sendFile(QSocket* socket) | |||
1980 | qDebug("file sent "); | 1975 | qDebug("file sent "); |
1981 | } | 1976 | } |
1982 | void MainWindow::getFile(QSocket* socket) | 1977 | void MainWindow::getFile(QSocket* socket) |
1983 | { | 1978 | { |
1984 | setCaption( i18n("Receiving synced file...") ); | 1979 | setCaption( i18n("Receiving synced file...") ); |
1985 | 1980 | ||
1986 | QString fileName = defaultFileName(); | 1981 | QString fileName = defaultFileName(); |
1987 | QFile file( fileName ); | 1982 | QFile file( fileName ); |
1988 | if (!file.open( IO_WriteOnly ) ) { | 1983 | if (!file.open( IO_WriteOnly ) ) { |
1989 | setCaption( i18n("Error open file") ); | 1984 | setCaption( i18n("Error open file") ); |
1990 | delete mSyncActionDialog; | 1985 | delete mSyncActionDialog; |
1991 | mSyncActionDialog = 0; | 1986 | mSyncActionDialog = 0; |
1992 | qDebug("error open cal file "); | 1987 | qDebug("error open cal file "); |
1993 | return ; | 1988 | return ; |
1994 | 1989 | ||
1995 | } | 1990 | } |
1996 | 1991 | ||
1997 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1992 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
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() ); |
2013 | setCaption( i18n("Easy-Pi-Sync successful!") ); | 2041 | setCaption( i18n("Easy-Pi-Sync successful!") ); |
2014 | delete mSyncActionDialog; | 2042 | delete mSyncActionDialog; |
2015 | mSyncActionDialog = 0; | 2043 | mSyncActionDialog = 0; |
2016 | 2044 | ||
2017 | 2045 | ||
2018 | } | 2046 | } |
2019 | void MainWindow::endConnect() | 2047 | void MainWindow::endConnect() |
2020 | { | 2048 | { |
2021 | setCaption( i18n("No file received - syncing successful") ); | 2049 | setCaption( i18n("No file received - syncing successful") ); |
2022 | delete mSyncActionDialog; | 2050 | delete mSyncActionDialog; |
2023 | mSyncActionDialog = 0; | 2051 | mSyncActionDialog = 0; |
2024 | } | 2052 | } |
2025 | void MainWindow::performQuick() | 2053 | void MainWindow::performQuick() |
2026 | { | 2054 | { |
2027 | setCaption( i18n("Please input connection settings") ); | 2055 | setCaption( i18n("Please input connection settings") ); |
2028 | QString retfile = ""; | 2056 | QString retfile = ""; |
2029 | QDialog dia ( this, "input-dialog", true ); | 2057 | QDialog dia ( this, "input-dialog", true ); |
2030 | QLineEdit lab ( &dia ); | 2058 | QLineEdit lab ( &dia ); |
@@ -2088,50 +2116,58 @@ void MainWindow::readFileFromSocket() | |||
2088 | qDebug("MainWindow::readFileFromSocket() "); | 2116 | qDebug("MainWindow::readFileFromSocket() "); |
2089 | QString fileName; | 2117 | QString fileName; |
2090 | #ifdef _WIN32_ | 2118 | #ifdef _WIN32_ |
2091 | fileName = defaultFileName() +"sync"; | 2119 | fileName = defaultFileName() +"sync"; |
2092 | #else | 2120 | #else |
2093 | fileName = "/tmp/kopitempfile.ics"; | 2121 | fileName = "/tmp/kopitempfile.ics"; |
2094 | #endif | 2122 | #endif |
2095 | QFile file( fileName ); | 2123 | QFile file( fileName ); |
2096 | if (!file.open( IO_WriteOnly ) ) { | 2124 | if (!file.open( IO_WriteOnly ) ) { |
2097 | setCaption( i18n("Error: Cannot open temp file for write.") ); | 2125 | setCaption( i18n("Error: Cannot open temp file for write.") ); |
2098 | qDebug("Error open calender file for writing: %s",fileName.latin1() ); | 2126 | qDebug("Error open calender file for writing: %s",fileName.latin1() ); |
2099 | return ; | 2127 | return ; |
2100 | } | 2128 | } |
2101 | 2129 | ||
2102 | //QTextStream os2( mCommandSocket ); | 2130 | //QTextStream os2( mCommandSocket ); |
2103 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); | 2131 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); |
2104 | 2132 | ||
2105 | QTextStream ts( &file ); | 2133 | QTextStream ts( &file ); |
2106 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2134 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
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 (); |
2140 | } | ||
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 ); | ||
2112 | } | 2148 | } |
2113 | mCommandSocket->waitForMore ( 5000 ); | 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; |
2120 | mCurrentSyncProfile = 2 ; // last file | 2156 | mCurrentSyncProfile = 2 ; // last file |
2121 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 2157 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
2122 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 2158 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
2123 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2159 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2124 | KSyncProfile* temp = new KSyncProfile (); | 2160 | KSyncProfile* temp = new KSyncProfile (); |
2125 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2161 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2126 | temp->readConfig(&config); | 2162 | temp->readConfig(&config); |
2127 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2163 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2128 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2164 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2129 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2165 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2130 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2166 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2131 | KOPrefs::instance()->mWriteBackInFuture = 0; | 2167 | KOPrefs::instance()->mWriteBackInFuture = 0; |
2132 | if ( temp->getWriteBackFuture() ) | 2168 | if ( temp->getWriteBackFuture() ) |
2133 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2169 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2134 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2170 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2135 | 2171 | ||
2136 | setCaption( i18n("Remote file saved to temp file.") ); | 2172 | setCaption( i18n("Remote file saved to temp file.") ); |
2137 | if ( ! syncWithFile( fileName , true ) ) { | 2173 | if ( ! syncWithFile( fileName , true ) ) { |
@@ -2431,24 +2467,75 @@ void MainWindow::syncSharp() | |||
2431 | if ( mCalendarModifiedFlag ) | 2467 | if ( mCalendarModifiedFlag ) |
2432 | save(); | 2468 | save(); |
2433 | mView->syncSharp(); | 2469 | mView->syncSharp(); |
2434 | slotModifiedChanged( true ); | 2470 | slotModifiedChanged( true ); |
2435 | 2471 | ||
2436 | } | 2472 | } |
2437 | void MainWindow::syncPhone() | 2473 | void MainWindow::syncPhone() |
2438 | { | 2474 | { |
2439 | if ( mCalendarModifiedFlag ) | 2475 | if ( mCalendarModifiedFlag ) |
2440 | save(); | 2476 | save(); |
2441 | mView->syncPhone(); | 2477 | mView->syncPhone(); |
2442 | slotModifiedChanged( true ); | 2478 | slotModifiedChanged( true ); |
2443 | 2479 | ||
2444 | } | 2480 | } |
2445 | 2481 | ||
2446 | void MainWindow::printSel( ) | 2482 | void MainWindow::printSel( ) |
2447 | { | 2483 | { |
2448 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2484 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
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 | |||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 5985d56..7b4fd27 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -6,87 +6,59 @@ | |||
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qregexp.h> | 7 | #include <qregexp.h> |
8 | 8 | ||
9 | #include <libkcal/incidence.h> | 9 | #include <libkcal/incidence.h> |
10 | #include "simplealarmclient.h" | 10 | #include "simplealarmclient.h" |
11 | 11 | ||
12 | class QAction; | 12 | class QAction; |
13 | class CalendarView; | 13 | class CalendarView; |
14 | class KSyncProfile; | 14 | class KSyncProfile; |
15 | #ifdef DESKTOP_VERSION | 15 | #ifdef DESKTOP_VERSION |
16 | 16 | ||
17 | #define QPEToolBar QToolBar | 17 | #define QPEToolBar QToolBar |
18 | #define QPEMenuBar QMenuBar | 18 | #define QPEMenuBar QMenuBar |
19 | #endif | 19 | #endif |
20 | class QPEToolBar; | 20 | class QPEToolBar; |
21 | #include <qserversocket.h> | 21 | #include <qserversocket.h> |
22 | #include <qsocket.h> | 22 | #include <qsocket.h> |
23 | #include <qnetworkprotocol.h> | 23 | #include <qnetworkprotocol.h> |
24 | 24 | ||
25 | class KServerSocket : public QServerSocket | 25 | class KServerSocket : public QServerSocket |
26 | { | 26 | { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | 28 | ||
29 | public: | 29 | public: |
30 | KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ) : | 30 | KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
31 | QServerSocket( port, backlog, parent, name ){;}; | 31 | |
32 | void newConnection ( int socket ) | 32 | void newConnection ( int socket ) ; |
33 | { | ||
34 | qDebug("KServerSocket:New connection %d ", socket); | ||
35 | QSocket* s = new QSocket( this ); | ||
36 | connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); | ||
37 | connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | ||
38 | s->setSocket( socket ); | ||
39 | } | ||
40 | 33 | ||
41 | signals: | 34 | signals: |
42 | void sendFile(QSocket*); | 35 | void sendFile(QSocket*); |
43 | void getFile(QSocket*); | 36 | void getFile(QSocket*); |
44 | void endConnect(); | 37 | void endConnect(); |
45 | private slots: | 38 | private slots: |
46 | void discardClient() | 39 | void discardClient(); |
47 | { | 40 | void readClient(); |
48 | QSocket* socket = (QSocket*)sender(); | ||
49 | delete socket; | ||
50 | //emit endConnect(); | ||
51 | } | ||
52 | void readClient() | ||
53 | { | ||
54 | qDebug("readClient() "); | ||
55 | QSocket* socket = (QSocket*)sender(); | ||
56 | if ( socket->canReadLine() ) { | ||
57 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() ); | ||
58 | if ( tokens[0] == "GET" ) { | ||
59 | emit sendFile( socket ); | ||
60 | } | ||
61 | if ( tokens[0] == "PUT" ) { | ||
62 | emit getFile( socket ); | ||
63 | } | ||
64 | if ( tokens[0] == "STOP" ) { | ||
65 | emit endConnect(); | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | }; | 41 | }; |
70 | 42 | ||
71 | 43 | ||
72 | namespace KCal { | 44 | namespace KCal { |
73 | class CalendarLocal; | 45 | class CalendarLocal; |
74 | } | 46 | } |
75 | 47 | ||
76 | using namespace KCal; | 48 | using namespace KCal; |
77 | 49 | ||
78 | class MainWindow : public QMainWindow | 50 | class MainWindow : public QMainWindow |
79 | { | 51 | { |
80 | Q_OBJECT | 52 | Q_OBJECT |
81 | public: | 53 | public: |
82 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 54 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
83 | ~MainWindow(); | 55 | ~MainWindow(); |
84 | public slots: | 56 | public slots: |
85 | virtual void showMaximized (); | 57 | virtual void showMaximized (); |
86 | void configureAgenda( int ); | 58 | void configureAgenda( int ); |
87 | void recieve( const QCString& msg, const QByteArray& data ); | 59 | void recieve( const QCString& msg, const QByteArray& data ); |
88 | static QString defaultFileName(); | 60 | static QString defaultFileName(); |
89 | static QString resourcePath(); | 61 | static QString resourcePath(); |
90 | protected slots: | 62 | protected slots: |
91 | void setCaptionToDates(); | 63 | void setCaptionToDates(); |
92 | int ringSync(); | 64 | int ringSync(); |