author | zautrix <zautrix> | 2004-10-04 17:32:48 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-04 17:32:48 (UTC) |
commit | 2a99a7ca0816fd68b7fcf2f1fee023aef019000d (patch) (unidiff) | |
tree | cef1bc6813689ecc05ef8d1d4323947adeabafcb /korganizer | |
parent | 01b5806c61deb8368f8f454fdec1c4767c73a840 (diff) | |
download | kdepimpi-2a99a7ca0816fd68b7fcf2f1fee023aef019000d.zip kdepimpi-2a99a7ca0816fd68b7fcf2f1fee023aef019000d.tar.gz kdepimpi-2a99a7ca0816fd68b7fcf2f1fee023aef019000d.tar.bz2 |
more sync fixes
-rw-r--r-- | korganizer/mainwindow.cpp | 178 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 34 |
2 files changed, 142 insertions, 70 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 10cb2a2..e4b7869 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -26,98 +26,96 @@ | |||
26 | #include <qtopia/alarmserver.h> | 26 | #include <qtopia/alarmserver.h> |
27 | #include <qtopia/qcopenvelope_qws.h> | 27 | #include <qtopia/qcopenvelope_qws.h> |
28 | #include <unistd.h> // for sleep | 28 | #include <unistd.h> // for sleep |
29 | #else | 29 | #else |
30 | #include <qmenubar.h> | 30 | #include <qmenubar.h> |
31 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | //#include <resource.h> | 33 | //#include <resource.h> |
34 | 34 | ||
35 | #endif | 35 | #endif |
36 | #include <libkcal/calendarlocal.h> | 36 | #include <libkcal/calendarlocal.h> |
37 | #include <libkcal/todo.h> | 37 | #include <libkcal/todo.h> |
38 | #include <libkdepim/ksyncprofile.h> | 38 | #include <libkdepim/ksyncprofile.h> |
39 | #include <libkcal/kincidenceformatter.h> | 39 | #include <libkcal/kincidenceformatter.h> |
40 | #include <libkdepim/kpimglobalprefs.h> | 40 | #include <libkdepim/kpimglobalprefs.h> |
41 | 41 | ||
42 | #include "calendarview.h" | 42 | #include "calendarview.h" |
43 | #include "koviewmanager.h" | 43 | #include "koviewmanager.h" |
44 | #include "datenavigator.h" | 44 | #include "datenavigator.h" |
45 | #include "koagendaview.h" | 45 | #include "koagendaview.h" |
46 | #include "koagenda.h" | 46 | #include "koagenda.h" |
47 | #include "kodialogmanager.h" | 47 | #include "kodialogmanager.h" |
48 | #include "kdialogbase.h" | 48 | #include "kdialogbase.h" |
49 | #include "kapplication.h" | 49 | #include "kapplication.h" |
50 | #include "kofilterview.h" | 50 | #include "kofilterview.h" |
51 | #include "kstandarddirs.h" | 51 | #include "kstandarddirs.h" |
52 | #include "koprefs.h" | 52 | #include "koprefs.h" |
53 | #include "kfiledialog.h" | 53 | #include "kfiledialog.h" |
54 | #include "koglobals.h" | 54 | #include "koglobals.h" |
55 | #include "kglobal.h" | 55 | #include "kglobal.h" |
56 | #include "klocale.h" | 56 | #include "klocale.h" |
57 | #include "kconfig.h" | 57 | #include "kconfig.h" |
58 | #include "simplealarmclient.h" | 58 | #include "simplealarmclient.h" |
59 | #include "externalapphandler.h" | 59 | #include "externalapphandler.h" |
60 | 60 | ||
61 | using namespace KCal; | 61 | using namespace KCal; |
62 | #ifndef _WIN32_ | 62 | #ifndef _WIN32_ |
63 | #include <unistd.h> | 63 | #include <unistd.h> |
64 | #else | 64 | #else |
65 | #include "koimportoldialog.h" | 65 | #include "koimportoldialog.h" |
66 | #endif | 66 | #endif |
67 | #include "mainwindow.h" | 67 | #include "mainwindow.h" |
68 | 68 | ||
69 | int globalFlagBlockStartup; | 69 | int globalFlagBlockStartup; |
70 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 70 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
71 | QMainWindow( parent, name ) | 71 | QMainWindow( parent, name ) |
72 | { | 72 | { |
73 | mPassWordPiSync = "abc"; | 73 | mPassWordPiSync = "abc"; |
74 | mTimerCommandSocket = new QTimer ( this ); | ||
75 | connect( mTimerCommandSocket, SIGNAL ( timeout () ), this, SLOT ( deleteCommandSocket() ) ); | ||
76 | #ifdef DESKTOP_VERSION | 74 | #ifdef DESKTOP_VERSION |
77 | setFont( QFont("Arial"), 14 ); | 75 | setFont( QFont("Arial"), 14 ); |
78 | #endif | 76 | #endif |
79 | mCommandSocket = 0; | 77 | mCommandSocket = 0; |
80 | mCommandSocketFinish = 0; | 78 | mCommandSocketFinish = 0; |
81 | mSyncActionDialog = 0; | 79 | mSyncActionDialog = 0; |
82 | mServerSocket = 0; | 80 | mServerSocket = 0; |
83 | mClosed = false; | 81 | mClosed = false; |
84 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 82 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
85 | QString confFile = locateLocal("config","korganizerrc"); | 83 | QString confFile = locateLocal("config","korganizerrc"); |
86 | QFileInfo finf ( confFile ); | 84 | QFileInfo finf ( confFile ); |
87 | bool showWarning = !finf.exists(); | 85 | bool showWarning = !finf.exists(); |
88 | setIcon(SmallIcon( "ko24" ) ); | 86 | setIcon(SmallIcon( "ko24" ) ); |
89 | mBlockAtStartup = true; | 87 | mBlockAtStartup = true; |
90 | mFlagKeyPressed = false; | 88 | mFlagKeyPressed = false; |
91 | setCaption("KOrganizer/Pi"); | 89 | setCaption("KOrganizer/Pi"); |
92 | KOPrefs *p = KOPrefs::instance(); | 90 | KOPrefs *p = KOPrefs::instance(); |
93 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 91 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
94 | // if ( QApplication::desktop()->height() > 480 ) { | 92 | // if ( QApplication::desktop()->height() > 480 ) { |
95 | // if ( p->mHourSize == 4 ) | 93 | // if ( p->mHourSize == 4 ) |
96 | // p->mHourSize = 6; | 94 | // p->mHourSize = 6; |
97 | // } | 95 | // } |
98 | if ( p->mHourSize > 18 ) | 96 | if ( p->mHourSize > 18 ) |
99 | p->mHourSize = 18; | 97 | p->mHourSize = 18; |
100 | QMainWindow::ToolBarDock tbd; | 98 | QMainWindow::ToolBarDock tbd; |
101 | if ( p->mToolBarHor ) { | 99 | if ( p->mToolBarHor ) { |
102 | if ( p->mToolBarUp ) | 100 | if ( p->mToolBarUp ) |
103 | tbd = Bottom; | 101 | tbd = Bottom; |
104 | else | 102 | else |
105 | tbd = Top; | 103 | tbd = Top; |
106 | } | 104 | } |
107 | else { | 105 | else { |
108 | if ( p->mToolBarUp ) | 106 | if ( p->mToolBarUp ) |
109 | tbd = Right; | 107 | tbd = Right; |
110 | else | 108 | else |
111 | tbd = Left; | 109 | tbd = Left; |
112 | } | 110 | } |
113 | if ( KOPrefs::instance()->mUseAppColors ) | 111 | if ( KOPrefs::instance()->mUseAppColors ) |
114 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 112 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
115 | globalFlagBlockStartup = 1; | 113 | globalFlagBlockStartup = 1; |
116 | iconToolBar = new QPEToolBar( this ); | 114 | iconToolBar = new QPEToolBar( this ); |
117 | addToolBar (iconToolBar , tbd ); | 115 | addToolBar (iconToolBar , tbd ); |
118 | mBlockSaveFlag = false; | 116 | mBlockSaveFlag = false; |
119 | mCalendarModifiedFlag = false; | 117 | mCalendarModifiedFlag = false; |
120 | 118 | ||
121 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 119 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
122 | splash->setAlignment ( AlignCenter ); | 120 | splash->setAlignment ( AlignCenter ); |
123 | setCentralWidget( splash ); | 121 | setCentralWidget( splash ); |
@@ -2058,237 +2056,196 @@ void MainWindow::performQuick() | |||
2058 | QVBoxLayout lay( &dia ); | 2056 | QVBoxLayout lay( &dia ); |
2059 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); | 2057 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); |
2060 | lay.addWidget( &label); | 2058 | lay.addWidget( &label); |
2061 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); | 2059 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); |
2062 | lay.setMargin(7); | 2060 | lay.setMargin(7); |
2063 | lay.setSpacing(7); | 2061 | lay.setSpacing(7); |
2064 | lay.addWidget( &lab); | 2062 | lay.addWidget( &lab); |
2065 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); | 2063 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); |
2066 | lay.addWidget( &label2); | 2064 | lay.addWidget( &label2); |
2067 | QLineEdit lab2 ( &dia ); | 2065 | QLineEdit lab2 ( &dia ); |
2068 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); | 2066 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); |
2069 | lay.addWidget( &lab2); | 2067 | lay.addWidget( &lab2); |
2070 | 2068 | ||
2071 | QLineEdit lepw ( &dia ); | 2069 | QLineEdit lepw ( &dia ); |
2072 | lepw.setText( mPassWordPiSync ); | 2070 | lepw.setText( mPassWordPiSync ); |
2073 | QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia ); | 2071 | QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia ); |
2074 | lay.addWidget( &label3); | 2072 | lay.addWidget( &label3); |
2075 | lay.addWidget( &lepw); | 2073 | lay.addWidget( &lepw); |
2076 | 2074 | ||
2077 | dia.setFixedSize( 230,200 ); | 2075 | dia.setFixedSize( 230,200 ); |
2078 | dia.setCaption( i18n("Enter port for Pi-Sync ") ); | 2076 | dia.setCaption( i18n("Enter port for Pi-Sync ") ); |
2079 | QPushButton pb ( "OK", &dia); | 2077 | QPushButton pb ( "OK", &dia); |
2080 | lay.addWidget( &pb ); | 2078 | lay.addWidget( &pb ); |
2081 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2079 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2082 | dia.show(); | 2080 | dia.show(); |
2083 | int res = dia.exec(); | 2081 | int res = dia.exec(); |
2084 | if ( !res ) { | 2082 | if ( !res ) { |
2085 | setCaption( i18n("Syncing cancelled!") ); | 2083 | setCaption( i18n("Syncing cancelled!") ); |
2086 | return; | 2084 | return; |
2087 | } | 2085 | } |
2088 | mPassWordPiSync = lepw.text(); | 2086 | mPassWordPiSync = lepw.text(); |
2089 | dia.hide(); | 2087 | dia.hide(); |
2090 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); | 2088 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); |
2091 | KOPrefs::instance()->mActiveSyncIP = lab.text(); | 2089 | KOPrefs::instance()->mActiveSyncIP = lab.text(); |
2092 | qApp->processEvents(); | 2090 | qApp->processEvents(); |
2093 | performQuickQuick(); | 2091 | performQuickQuick(); |
2094 | } | 2092 | } |
2095 | 2093 | ||
2096 | void MainWindow::performQuickQuick() | 2094 | void MainWindow::performQuickQuick() |
2097 | { | 2095 | { |
2098 | // setCaption( i18n("") ); | 2096 | // setCaption( i18n("") ); |
2099 | 2097 | ||
2100 | bool ok; | 2098 | bool ok; |
2101 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2099 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2102 | if ( ! ok ) { | 2100 | if ( ! ok ) { |
2103 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2101 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2104 | return; | 2102 | return; |
2105 | } | 2103 | } |
2106 | if ( !mCommandSocket ) { | 2104 | mCommandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); |
2107 | mCommandSocket = new QSocket( this ); | 2105 | connect( mCommandSocket, SIGNAL(commandFinished( bool )), this, SLOT(deleteCommandSocket(bool)) ); |
2108 | // delete mCommandSocket; | ||
2109 | //mCommandSocket = new QSocket( this ); | ||
2110 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); | ||
2111 | connect( mCommandSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocket()) ); | ||
2112 | } | ||
2113 | QString host = KOPrefs::instance()->mActiveSyncIP; | ||
2114 | mCommandSocket->connectToHost( host, port ); | ||
2115 | QTextStream os( mCommandSocket ); | ||
2116 | os.setEncoding( QTextStream::UnicodeUTF8 ); | ||
2117 | os << "GET " << mPassWordPiSync << "\r\n"; | ||
2118 | setCaption( i18n("Sending request for remote file ...") ); | 2106 | setCaption( i18n("Sending request for remote file ...") ); |
2119 | mTimerCommandSocket->start( 10000 ); | 2107 | QString fileName; |
2120 | 2108 | #ifdef _WIN32_ | |
2109 | fileName = defaultFileName() +"sync"; | ||
2110 | #else | ||
2111 | fileName = "/tmp/kopitempfile.ics"; | ||
2112 | #endif | ||
2113 | mCommandSocket->readFile( fileName ); | ||
2121 | } | 2114 | } |
2122 | void MainWindow::deleteCommandSocket() | 2115 | void MainWindow::deleteCommandSocket( bool success) |
2123 | { | 2116 | { |
2124 | if ( !mCommandSocket) | 2117 | if ( ! success ) { |
2118 | setCaption( i18n("ERROR:Receiving remote file failed.") ); | ||
2119 | // pending : send stop | ||
2125 | return; | 2120 | return; |
2126 | if ( mTimerCommandSocket->isActive () ) { | 2121 | |
2127 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out ")); | ||
2128 | mTimerCommandSocket->stop(); | ||
2129 | } | 2122 | } |
2130 | //KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocket ")); | 2123 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
2131 | qDebug("MainWindow::deletemCommandSocket() "); | 2124 | delete mCommandSocket; |
2132 | delete mCommandSocket; | ||
2133 | mCommandSocket = 0; | ||
2134 | } | 2125 | } |
2135 | void MainWindow::deleteCommandSocketFinish() | 2126 | void MainWindow::deleteCommandSocketFinish() |
2136 | { | 2127 | { |
2137 | if ( ! mCommandSocketFinish) | 2128 | if ( ! mCommandSocketFinish) |
2138 | return; | 2129 | return; |
2139 | // KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocketFinish() ")); | 2130 | // KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocketFinish() ")); |
2140 | qDebug("MainWindow::deletemCommandSocketFinish() "); | 2131 | qDebug("MainWindow::deletemCommandSocketFinish() "); |
2141 | delete mCommandSocketFinish; | 2132 | delete mCommandSocketFinish; |
2142 | mCommandSocketFinish = 0; | 2133 | mCommandSocketFinish = 0; |
2143 | } | 2134 | } |
2144 | void MainWindow::readFileFromSocket() | 2135 | void MainWindow::readFileFromSocket() |
2145 | { | 2136 | { |
2146 | mTimerCommandSocket->stop(); | 2137 | // mTimerCommandSocket->stop(); |
2147 | setCaption( i18n("Receiving remote file ...") ); | 2138 | setCaption( i18n("Receiving remote file ...") ); |
2148 | qDebug("MainWindow::readFileFromSocket() "); | 2139 | qDebug("MainWindow::readFileFromSocket() "); |
2149 | QString fileName; | 2140 | QString fileName; |
2150 | #ifdef _WIN32_ | 2141 | #ifdef _WIN32_ |
2151 | fileName = defaultFileName() +"sync"; | 2142 | fileName = defaultFileName() +"sync"; |
2152 | #else | 2143 | #else |
2153 | fileName = "/tmp/kopitempfile.ics"; | 2144 | fileName = "/tmp/kopitempfile.ics"; |
2154 | #endif | 2145 | #endif |
2155 | QFile file( fileName ); | 2146 | |
2156 | if (!file.open( IO_WriteOnly ) ) { | ||
2157 | setCaption( i18n("Error: Cannot open temp file for write.") ); | ||
2158 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | ||
2159 | return ; | ||
2160 | } | ||
2161 | |||
2162 | //QTextStream os2( mCommandSocket ); | ||
2163 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); | ||
2164 | |||
2165 | QTextStream ts( &file ); | ||
2166 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
2167 | bool first = true; | ||
2168 | while ( mCommandSocket->canReadLine () || first) { | ||
2169 | first = false; | ||
2170 | while ( mCommandSocket->canReadLine () ) { | ||
2171 | ts << mCommandSocket->readLine (); | ||
2172 | } | ||
2173 | QTime ti; | ||
2174 | ti.start(); | ||
2175 | while ( ti.elapsed () < 3000 && !mCommandSocket->canReadLine () ) { | ||
2176 | qApp->processEvents(); | ||
2177 | qDebug("waiting2 %d ",ti.elapsed () ); | ||
2178 | if ( !mCommandSocket->canReadLine () ) | ||
2179 | mCommandSocket->waitForMore ( 100 ); | ||
2180 | } | ||
2181 | //mCommandSocket->waitForMore ( 5000 ); | ||
2182 | } | ||
2183 | file.close(); | ||
2184 | mCommandSocket->close(); | ||
2185 | if ( mCommandSocket->state() == QSocket::Idle ) | ||
2186 | deleteCommandSocket(); | ||
2187 | // pending: deleting after signal SIGNAL(delayedCloseFinished()) | ||
2188 | //delete mCommandSocket; | ||
2189 | setCaption( i18n("Remote file saved to temp file.") ); | 2147 | setCaption( i18n("Remote file saved to temp file.") ); |
2190 | //mCommandSocket = 0; | 2148 | //mCommandSocket = 0; |
2191 | mCurrentSyncProfile = 2 ; // last file | 2149 | mCurrentSyncProfile = 2 ; // last file |
2192 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 2150 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
2193 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 2151 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
2194 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2152 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2195 | KSyncProfile* temp = new KSyncProfile (); | 2153 | KSyncProfile* temp = new KSyncProfile (); |
2196 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2154 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2197 | temp->readConfig(&config); | 2155 | temp->readConfig(&config); |
2198 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2156 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2199 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2157 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2200 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2158 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2201 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2159 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2202 | KOPrefs::instance()->mWriteBackInFuture = 0; | 2160 | KOPrefs::instance()->mWriteBackInFuture = 0; |
2203 | if ( temp->getWriteBackFuture() ) | 2161 | if ( temp->getWriteBackFuture() ) |
2204 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2162 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2205 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2163 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2206 | delete temp; | 2164 | delete temp; |
2207 | setCaption( i18n("Remote file saved to temp file.") ); | 2165 | setCaption( i18n("Remote file saved to temp file.") ); |
2208 | if ( ! syncWithFile( fileName , true ) ) { | 2166 | if ( ! syncWithFile( fileName , true ) ) { |
2209 | setCaption( i18n("Syncing failed.") ); | 2167 | setCaption( i18n("Syncing failed.") ); |
2210 | qDebug("Syncing failed "); | 2168 | qDebug("Syncing failed "); |
2211 | return; | 2169 | return; |
2212 | } | 2170 | } |
2213 | 2171 | ||
2214 | if ( !mCommandSocketFinish ) { | 2172 | if ( !mCommandSocketFinish ) { |
2215 | mCommandSocketFinish = new QSocket( this ); | 2173 | mCommandSocketFinish = new QSocket( this ); |
2216 | connect( mCommandSocketFinish, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocketFinish()) ); | 2174 | connect( mCommandSocketFinish, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocketFinish()) ); |
2217 | } | 2175 | } |
2218 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); | 2176 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); |
2219 | 2177 | ||
2220 | // pending connect signals connected () and error to new slots | ||
2221 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2178 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2222 | QFile file2( fileName ); | 2179 | QFile file2( fileName ); |
2223 | if (!file2.open( IO_ReadOnly ) ) { | 2180 | if (!file2.open( IO_ReadOnly ) ) { |
2224 | setCaption( i18n("Error: Cannot open temp file for read.") ); | 2181 | setCaption( i18n("Error: Cannot open temp file for read.") ); |
2225 | qDebug("error open cal file "); | 2182 | qDebug("error open cal file "); |
2226 | return ; | 2183 | return ; |
2227 | 2184 | ||
2228 | } | 2185 | } |
2229 | QTextStream ts2( &file2 ); | 2186 | QTextStream ts2( &file2 ); |
2230 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2187 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2231 | QTextStream os2( mCommandSocketFinish ); | 2188 | QTextStream os2( mCommandSocketFinish ); |
2232 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2189 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2233 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2190 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2234 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2191 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2235 | setCaption( i18n("Sending back synced file...") ); | 2192 | setCaption( i18n("Sending back synced file...") ); |
2236 | os2 << "PUT " << mPassWordPiSync << "\r\n";; | 2193 | os2 << "PUT " << mPassWordPiSync << "\r\n";; |
2237 | while ( ! ts2.atEnd() ) { | 2194 | while ( ! ts2.atEnd() ) { |
2238 | os2 << ts2.readLine() << "\n"; | 2195 | os2 << ts2.readLine() << "\n"; |
2239 | } | 2196 | } |
2240 | } else { | 2197 | } else { |
2241 | os2 << "STOP\r\n"; | 2198 | os2 << "STOP\r\n"; |
2242 | } | 2199 | } |
2243 | mCommandSocketFinish->close(); | 2200 | mCommandSocketFinish->close(); |
2244 | if ( mCommandSocketFinish->state() == QSocket::Idle ) | 2201 | if ( mCommandSocketFinish->state() == QSocket::Idle ) |
2245 | QTimer::singleShot( 10, this , SLOT ( deleteCommandSocketFinish())); | 2202 | QTimer::singleShot( 10, this , SLOT ( deleteCommandSocketFinish())); |
2246 | file.close(); | 2203 | file2.close(); |
2247 | qDebug("Syncing succesful! "); | 2204 | qDebug("Syncing succesful! "); |
2248 | setCaption( i18n("Pi-Sync succesful!") ); | 2205 | setCaption( i18n("Pi-Sync succesful!") ); |
2249 | 2206 | ||
2250 | // KMessageBox::information( 0, i18n(" Pi-Sync succesful! ")); | 2207 | // KMessageBox::information( 0, i18n(" Pi-Sync succesful! ")); |
2251 | 2208 | ||
2252 | } | 2209 | } |
2253 | 2210 | ||
2254 | void MainWindow::syncLocalFile() | 2211 | void MainWindow::syncLocalFile() |
2255 | { | 2212 | { |
2256 | 2213 | ||
2257 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2214 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2258 | 2215 | ||
2259 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2216 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2260 | if ( fn == "" ) | 2217 | if ( fn == "" ) |
2261 | return; | 2218 | return; |
2262 | //mView->setSyncDevice("local-file" ); | 2219 | //mView->setSyncDevice("local-file" ); |
2263 | if ( syncWithFile( fn, false ) ) { | 2220 | if ( syncWithFile( fn, false ) ) { |
2264 | // Event* e = mView->getLastSyncEvent(); | 2221 | // Event* e = mView->getLastSyncEvent(); |
2265 | // e->setReadOnly( false ); | 2222 | // e->setReadOnly( false ); |
2266 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2223 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2267 | // e->setReadOnly( true ); | 2224 | // e->setReadOnly( true ); |
2268 | } | 2225 | } |
2269 | 2226 | ||
2270 | } | 2227 | } |
2271 | 2228 | ||
2272 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2229 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2273 | { | 2230 | { |
2274 | bool ret = false; | 2231 | bool ret = false; |
2275 | QFileInfo info; | 2232 | QFileInfo info; |
2276 | info.setFile( fn ); | 2233 | info.setFile( fn ); |
2277 | QString mess; | 2234 | QString mess; |
2278 | bool loadbup = true; | 2235 | bool loadbup = true; |
2279 | if ( !info. exists() ) { | 2236 | if ( !info. exists() ) { |
2280 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2237 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2281 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2238 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2282 | mess ); | 2239 | mess ); |
2283 | return ret; | 2240 | return ret; |
2284 | } | 2241 | } |
2285 | int result = 0; | 2242 | int result = 0; |
2286 | if ( !quick ) { | 2243 | if ( !quick ) { |
2287 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2244 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2288 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2245 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2289 | mess, | 2246 | mess, |
2290 | i18n("Sync"), i18n("Cancel"), 0, | 2247 | i18n("Sync"), i18n("Cancel"), 0, |
2291 | 0, 1 ); | 2248 | 0, 1 ); |
2292 | if ( result ) | 2249 | if ( result ) |
2293 | return false; | 2250 | return false; |
2294 | } | 2251 | } |
@@ -2546,59 +2503,146 @@ void KServerSocket::newConnection ( int socket ) | |||
2546 | mSocket = new QSocket( this ); | 2503 | mSocket = new QSocket( this ); |
2547 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 2504 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
2548 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 2505 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
2549 | mSocket->setSocket( socket ); | 2506 | mSocket->setSocket( socket ); |
2550 | } | 2507 | } |
2551 | 2508 | ||
2552 | void KServerSocket::discardClient() | 2509 | void KServerSocket::discardClient() |
2553 | { | 2510 | { |
2554 | qDebug(" KServerSocket::discardClient()"); | 2511 | qDebug(" KServerSocket::discardClient()"); |
2555 | if ( mSocket ) { | 2512 | if ( mSocket ) { |
2556 | qDebug("delete "); | 2513 | qDebug("delete "); |
2557 | delete mSocket; | 2514 | delete mSocket; |
2558 | mSocket = 0; | 2515 | mSocket = 0; |
2559 | } | 2516 | } |
2560 | //emit endConnect(); | 2517 | //emit endConnect(); |
2561 | } | 2518 | } |
2562 | void KServerSocket::readClient() | 2519 | void KServerSocket::readClient() |
2563 | { | 2520 | { |
2564 | if ( mSocket == 0 ) { | 2521 | if ( mSocket == 0 ) { |
2565 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 2522 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
2566 | return; | 2523 | return; |
2567 | } | 2524 | } |
2568 | qDebug("KServerSocket readClient()"); | 2525 | qDebug("KServerSocket readClient()"); |
2569 | if ( mSocket->canReadLine() ) { | 2526 | if ( mSocket->canReadLine() ) { |
2570 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); | 2527 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); |
2571 | qDebug("KServerSocket socket->canReadLine()"); | 2528 | qDebug("KServerSocket socket->canReadLine()"); |
2572 | if ( tokens[0] == "GET" ) { | 2529 | if ( tokens[0] == "GET" ) { |
2573 | if ( tokens[1] == mPassWord ) | 2530 | if ( tokens[1] == mPassWord ) |
2574 | emit sendFile( mSocket ); | 2531 | emit sendFile( mSocket ); |
2575 | else { | 2532 | else { |
2576 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | 2533 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); |
2577 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2534 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2578 | } | 2535 | } |
2579 | } | 2536 | } |
2580 | if ( tokens[0] == "PUT" ) { | 2537 | if ( tokens[0] == "PUT" ) { |
2581 | if ( tokens[1] == mPassWord ) | 2538 | if ( tokens[1] == mPassWord ) |
2582 | emit getFile( mSocket ); | 2539 | emit getFile( mSocket ); |
2583 | else { | 2540 | else { |
2584 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | 2541 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); |
2585 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2542 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2586 | } | 2543 | } |
2587 | } | 2544 | } |
2588 | if ( tokens[0] == "STOP" ) { | 2545 | if ( tokens[0] == "STOP" ) { |
2589 | emit endConnect(); | 2546 | emit endConnect(); |
2590 | } | 2547 | } |
2591 | } | 2548 | } |
2592 | } | 2549 | } |
2593 | 2550 | ||
2551 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | ||
2552 | { | ||
2553 | mPassWord = password; | ||
2554 | mSocket = 0; | ||
2555 | mPort = port; | ||
2556 | mHost = host; | ||
2594 | 2557 | ||
2558 | mRetVal = false; | ||
2559 | mTimerSocket = new QTimer ( this ); | ||
2560 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | ||
2561 | } | ||
2562 | void KCommandSocket::readFile( QString fn ) | ||
2563 | { | ||
2564 | if ( !mSocket ) { | ||
2565 | mSocket = new QSocket( this ); | ||
2566 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | ||
2567 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
2568 | } | ||
2569 | mFileString = ""; | ||
2570 | mFileName = fn; | ||
2571 | mFirst = true; | ||
2572 | mSocket->connectToHost( mHost, mPort ); | ||
2573 | QTextStream os( mSocket ); | ||
2574 | os.setEncoding( QTextStream::UnicodeUTF8 ); | ||
2575 | os << "GET " << mPassWord << "\r\n"; | ||
2576 | mTimerSocket->start( 10000 ); | ||
2577 | } | ||
2595 | 2578 | ||
2579 | void KCommandSocket::writeFile( QString ) | ||
2580 | { | ||
2596 | 2581 | ||
2582 | } | ||
2583 | void KCommandSocket::startReadFileFromSocket() | ||
2584 | { | ||
2585 | if ( ! mFirst ) | ||
2586 | return; | ||
2587 | mFirst = false; | ||
2588 | mTimerSocket->stop(); | ||
2589 | mFileString = ""; | ||
2590 | mTime.start(); | ||
2591 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | ||
2597 | 2592 | ||
2593 | } | ||
2594 | void KCommandSocket::readFileFromSocket() | ||
2595 | { | ||
2596 | qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | ||
2597 | while ( mSocket->canReadLine () ) { | ||
2598 | mTime.restart(); | ||
2599 | QString line = mSocket->readLine (); | ||
2600 | mFileString += line; | ||
2601 | qDebug("readline: %s ", line.latin1()); | ||
2602 | } | ||
2603 | if ( mTime.elapsed () < 3000 ) { | ||
2604 | // wait for more | ||
2605 | qDebug("waitformore "); | ||
2606 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | ||
2607 | return; | ||
2608 | } | ||
2609 | QString fileName = mFileName; | ||
2610 | QFile file ( fileName ); | ||
2611 | if (!file.open( IO_WriteOnly ) ) { | ||
2612 | mFileString = ""; | ||
2613 | mRetVal = false; | ||
2614 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | ||
2615 | deleteSocket(); | ||
2616 | return ; | ||
2617 | |||
2618 | } | ||
2619 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | ||
2620 | QTextStream ts ( &file ); | ||
2621 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
2622 | qDebug("finish "); | ||
2623 | ts << mFileString; | ||
2624 | file.close(); | ||
2625 | mFileString = ""; | ||
2626 | mRetVal = true; | ||
2627 | mSocket->close(); | ||
2628 | // if state is not idle, deleteSocket(); is called via | ||
2629 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | ||
2630 | if ( mSocket->state() == QSocket::Idle ) | ||
2631 | deleteSocket(); | ||
2632 | } | ||
2598 | 2633 | ||
2599 | 2634 | void KCommandSocket::deleteSocket() | |
2600 | 2635 | { | |
2601 | 2636 | if ( !mSocket) | |
2602 | 2637 | return; | |
2603 | 2638 | if ( mTimerSocket->isActive () ) { | |
2639 | mTimerSocket->stop(); | ||
2640 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out ")); | ||
2641 | mRetVal = false; | ||
2642 | } | ||
2643 | qDebug("KCommandSocket::deleteSocket() %d", mRetVal); | ||
2644 | delete mSocket; | ||
2645 | mSocket = 0; | ||
2646 | emit commandFinished( mRetVal ); | ||
2647 | } | ||
2604 | 2648 | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index d217578..11a816c 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,173 +1,201 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qsocket.h> | 8 | #include <qsocket.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <qregexp.h> | 10 | #include <qregexp.h> |
11 | 11 | ||
12 | #include <libkcal/incidence.h> | 12 | #include <libkcal/incidence.h> |
13 | #include "simplealarmclient.h" | 13 | #include "simplealarmclient.h" |
14 | 14 | ||
15 | class QAction; | 15 | class QAction; |
16 | class CalendarView; | 16 | class CalendarView; |
17 | class KSyncProfile; | 17 | class KSyncProfile; |
18 | #ifdef DESKTOP_VERSION | 18 | #ifdef DESKTOP_VERSION |
19 | 19 | ||
20 | #define QPEToolBar QToolBar | 20 | #define QPEToolBar QToolBar |
21 | #define QPEMenuBar QMenuBar | 21 | #define QPEMenuBar QMenuBar |
22 | #endif | 22 | #endif |
23 | class QPEToolBar; | 23 | class QPEToolBar; |
24 | #include <qserversocket.h> | 24 | #include <qserversocket.h> |
25 | #include <qsocket.h> | 25 | #include <qsocket.h> |
26 | #include <qnetworkprotocol.h> | 26 | #include <qnetworkprotocol.h> |
27 | 27 | ||
28 | class KServerSocket : public QServerSocket | 28 | class KServerSocket : public QServerSocket |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 33 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
34 | 34 | ||
35 | void newConnection ( int socket ) ; | 35 | void newConnection ( int socket ) ; |
36 | 36 | ||
37 | signals: | 37 | signals: |
38 | void sendFile(QSocket*); | 38 | void sendFile(QSocket*); |
39 | void getFile(QSocket*); | 39 | void getFile(QSocket*); |
40 | void endConnect(); | 40 | void endConnect(); |
41 | private slots: | 41 | private slots: |
42 | void discardClient(); | 42 | void discardClient(); |
43 | void readClient(); | 43 | void readClient(); |
44 | private : | 44 | private : |
45 | QSocket* mSocket; | 45 | QSocket* mSocket; |
46 | QString mPassWord; | 46 | QString mPassWord; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | class KCommandSocket : public QObject | ||
50 | { | ||
51 | Q_OBJECT | ||
52 | |||
53 | public: | ||
54 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | ||
55 | void readFile( QString ); | ||
56 | void writeFile( QString ); | ||
57 | |||
58 | |||
59 | signals: | ||
60 | void commandFinished( bool ); | ||
61 | private slots: | ||
62 | void startReadFileFromSocket(); | ||
63 | void readFileFromSocket(); | ||
64 | void deleteSocket(); | ||
65 | private : | ||
66 | QSocket* mSocket; | ||
67 | QString mPassWord; | ||
68 | Q_UINT16 mPort; | ||
69 | QString mHost; | ||
70 | QString mFileName; | ||
71 | QTimer* mTimerSocket; | ||
72 | bool mRetVal; | ||
73 | QTime mTime; | ||
74 | QString mFileString; | ||
75 | bool mFirst; | ||
76 | }; | ||
49 | 77 | ||
50 | namespace KCal { | 78 | namespace KCal { |
51 | class CalendarLocal; | 79 | class CalendarLocal; |
52 | } | 80 | } |
53 | 81 | ||
54 | using namespace KCal; | 82 | using namespace KCal; |
55 | 83 | ||
56 | class MainWindow : public QMainWindow | 84 | class MainWindow : public QMainWindow |
57 | { | 85 | { |
58 | Q_OBJECT | 86 | Q_OBJECT |
59 | public: | 87 | public: |
60 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 88 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
61 | ~MainWindow(); | 89 | ~MainWindow(); |
62 | public slots: | 90 | public slots: |
63 | virtual void showMaximized (); | 91 | virtual void showMaximized (); |
64 | void configureAgenda( int ); | 92 | void configureAgenda( int ); |
65 | void recieve( const QCString& msg, const QByteArray& data ); | 93 | void recieve( const QCString& msg, const QByteArray& data ); |
66 | static QString defaultFileName(); | 94 | static QString defaultFileName(); |
67 | static QString resourcePath(); | 95 | static QString resourcePath(); |
68 | protected slots: | 96 | protected slots: |
69 | void setCaptionToDates(); | 97 | void setCaptionToDates(); |
70 | int ringSync(); | 98 | int ringSync(); |
71 | void multiSync( bool askforPrefs = false ); | 99 | void multiSync( bool askforPrefs = false ); |
72 | void about(); | 100 | void about(); |
73 | void licence(); | 101 | void licence(); |
74 | void faq(); | 102 | void faq(); |
75 | void usertrans(); | 103 | void usertrans(); |
76 | void features(); | 104 | void features(); |
77 | void synchowto(); | 105 | void synchowto(); |
78 | void whatsNew(); | 106 | void whatsNew(); |
79 | void keyBindings(); | 107 | void keyBindings(); |
80 | void aboutAutoSaving();; | 108 | void aboutAutoSaving();; |
81 | void aboutKnownBugs(); | 109 | void aboutKnownBugs(); |
82 | 110 | ||
83 | void processIncidenceSelection( Incidence * ); | 111 | void processIncidenceSelection( Incidence * ); |
84 | 112 | ||
85 | void importQtopia(); | 113 | void importQtopia(); |
86 | void importBday(); | 114 | void importBday(); |
87 | void importOL(); | 115 | void importOL(); |
88 | void importIcal(); | 116 | void importIcal(); |
89 | void importFile( QString, bool ); | 117 | void importFile( QString, bool ); |
90 | void quickImportIcal(); | 118 | void quickImportIcal(); |
91 | 119 | ||
92 | void slotModifiedChanged( bool ); | 120 | void slotModifiedChanged( bool ); |
93 | 121 | ||
94 | void save(); | 122 | void save(); |
95 | void configureToolBar( int ); | 123 | void configureToolBar( int ); |
96 | void printSel(); | 124 | void printSel(); |
97 | void printCal(); | 125 | void printCal(); |
98 | void saveCalendar(); | 126 | void saveCalendar(); |
99 | void loadCalendar(); | 127 | void loadCalendar(); |
100 | void exportVCalendar(); | 128 | void exportVCalendar(); |
101 | void fillFilterMenu(); | 129 | void fillFilterMenu(); |
102 | void selectFilter( int ); | 130 | void selectFilter( int ); |
103 | 131 | ||
104 | void slotSyncMenu( int ); | 132 | void slotSyncMenu( int ); |
105 | void syncSSH(); | 133 | void syncSSH(); |
106 | void confSync(); | 134 | void confSync(); |
107 | void syncSharp(); | 135 | void syncSharp(); |
108 | void syncPhone(); | 136 | void syncPhone(); |
109 | void syncLocalFile(); | 137 | void syncLocalFile(); |
110 | bool syncWithFile( QString, bool ); | 138 | bool syncWithFile( QString, bool ); |
111 | void quickSyncLocalFile(); | 139 | void quickSyncLocalFile(); |
112 | 140 | ||
113 | 141 | ||
114 | protected: | 142 | protected: |
115 | void displayText( QString, QString); | 143 | void displayText( QString, QString); |
116 | void displayFile( QString, QString); | 144 | void displayFile( QString, QString); |
117 | 145 | ||
118 | void enableIncidenceActions( bool ); | 146 | void enableIncidenceActions( bool ); |
119 | 147 | ||
120 | private slots: | 148 | private slots: |
121 | QSocket* piSocket; | 149 | QSocket* piSocket; |
122 | QString piFileString; | 150 | QString piFileString; |
123 | QTime piTime; | 151 | QTime piTime; |
124 | void deleteCommandSocket(); | 152 | void deleteCommandSocket(bool); |
125 | void deleteCommandSocketFinish(); | 153 | void deleteCommandSocketFinish(); |
126 | void fillSyncMenu(); | 154 | void fillSyncMenu(); |
127 | void sendFile(QSocket* s); | 155 | void sendFile(QSocket* s); |
128 | void getFile(QSocket* socket); | 156 | void getFile(QSocket* socket); |
129 | void readFileFromSocket(); | 157 | void readFileFromSocket(); |
130 | void readBackFileFromSocket(); | 158 | void readBackFileFromSocket(); |
131 | void endConnect(); | 159 | void endConnect(); |
132 | private: | 160 | private: |
133 | QTimer* mTimerCommandSocket; | 161 | //QTimer* mTimerCommandSocket; |
134 | QString mPassWordPiSync; | 162 | QString mPassWordPiSync; |
135 | QSocket* mCommandSocket; | 163 | KCommandSocket* mCommandSocket; |
136 | QSocket* mCommandSocketFinish; | 164 | QSocket* mCommandSocketFinish; |
137 | KServerSocket * mServerSocket; | 165 | KServerSocket * mServerSocket; |
138 | bool mClosed; | 166 | bool mClosed; |
139 | void saveOnClose(); | 167 | void saveOnClose(); |
140 | int mCurrentSyncProfile; | 168 | int mCurrentSyncProfile; |
141 | void enableQuick(); | 169 | void enableQuick(); |
142 | void performQuick(); | 170 | void performQuick(); |
143 | void performQuickQuick(); | 171 | void performQuickQuick(); |
144 | void syncRemote( KSyncProfile* , bool ask = true); | 172 | void syncRemote( KSyncProfile* , bool ask = true); |
145 | bool mFlagKeyPressed; | 173 | bool mFlagKeyPressed; |
146 | bool mBlockAtStartup; | 174 | bool mBlockAtStartup; |
147 | QPEToolBar *iconToolBar; | 175 | QPEToolBar *iconToolBar; |
148 | void initActions(); | 176 | void initActions(); |
149 | void setDefaultPreferences(); | 177 | void setDefaultPreferences(); |
150 | void keyPressEvent ( QKeyEvent * ) ; | 178 | void keyPressEvent ( QKeyEvent * ) ; |
151 | void keyReleaseEvent ( QKeyEvent * ) ; | 179 | void keyReleaseEvent ( QKeyEvent * ) ; |
152 | QPopupMenu *configureToolBarMenu; | 180 | QPopupMenu *configureToolBarMenu; |
153 | QPopupMenu *selectFilterMenu; | 181 | QPopupMenu *selectFilterMenu; |
154 | QPopupMenu *configureAgendaMenu, *syncMenu; | 182 | QPopupMenu *configureAgendaMenu, *syncMenu; |
155 | CalendarLocal *mCalendar; | 183 | CalendarLocal *mCalendar; |
156 | CalendarView *mView; | 184 | CalendarView *mView; |
157 | QString getPassword(); | 185 | QString getPassword(); |
158 | QAction *mNewSubTodoAction; | 186 | QAction *mNewSubTodoAction; |
159 | 187 | ||
160 | QAction *mShowAction; | 188 | QAction *mShowAction; |
161 | QAction *mEditAction; | 189 | QAction *mEditAction; |
162 | QAction *mDeleteAction; | 190 | QAction *mDeleteAction; |
163 | void closeEvent( QCloseEvent* ce ); | 191 | void closeEvent( QCloseEvent* ce ); |
164 | SimpleAlarmClient mAlarmClient; | 192 | SimpleAlarmClient mAlarmClient; |
165 | QTimer mSaveTimer; | 193 | QTimer mSaveTimer; |
166 | bool mBlockSaveFlag; | 194 | bool mBlockSaveFlag; |
167 | bool mCalendarModifiedFlag; | 195 | bool mCalendarModifiedFlag; |
168 | QPixmap loadPixmap( QString ); | 196 | QPixmap loadPixmap( QString ); |
169 | QDialog * mSyncActionDialog; | 197 | QDialog * mSyncActionDialog; |
170 | }; | 198 | }; |
171 | 199 | ||
172 | 200 | ||
173 | #endif | 201 | #endif |