-rw-r--r-- | korganizer/mainwindow.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 8e2f956..10cb2a2 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -2055,258 +2055,260 @@ void MainWindow::performQuick() | |||
2055 | QString retfile = ""; | 2055 | QString retfile = ""; |
2056 | QDialog dia ( this, "input-dialog", true ); | 2056 | QDialog dia ( this, "input-dialog", true ); |
2057 | QLineEdit lab ( &dia ); | 2057 | QLineEdit lab ( &dia ); |
2058 | QVBoxLayout lay( &dia ); | 2058 | QVBoxLayout lay( &dia ); |
2059 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); | 2059 | QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); |
2060 | lay.addWidget( &label); | 2060 | lay.addWidget( &label); |
2061 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); | 2061 | lab.setText( KOPrefs::instance()->mActiveSyncIP ); |
2062 | lay.setMargin(7); | 2062 | lay.setMargin(7); |
2063 | lay.setSpacing(7); | 2063 | lay.setSpacing(7); |
2064 | lay.addWidget( &lab); | 2064 | lay.addWidget( &lab); |
2065 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); | 2065 | QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); |
2066 | lay.addWidget( &label2); | 2066 | lay.addWidget( &label2); |
2067 | QLineEdit lab2 ( &dia ); | 2067 | QLineEdit lab2 ( &dia ); |
2068 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); | 2068 | lab2.setText( KOPrefs::instance()->mActiveSyncPort ); |
2069 | lay.addWidget( &lab2); | 2069 | lay.addWidget( &lab2); |
2070 | 2070 | ||
2071 | QLineEdit lepw ( &dia ); | 2071 | QLineEdit lepw ( &dia ); |
2072 | lepw.setText( mPassWordPiSync ); | 2072 | lepw.setText( mPassWordPiSync ); |
2073 | QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia ); | 2073 | QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia ); |
2074 | lay.addWidget( &label3); | 2074 | lay.addWidget( &label3); |
2075 | lay.addWidget( &lepw); | 2075 | lay.addWidget( &lepw); |
2076 | 2076 | ||
2077 | dia.setFixedSize( 230,200 ); | 2077 | dia.setFixedSize( 230,200 ); |
2078 | dia.setCaption( i18n("Enter port for Pi-Sync ") ); | 2078 | dia.setCaption( i18n("Enter port for Pi-Sync ") ); |
2079 | QPushButton pb ( "OK", &dia); | 2079 | QPushButton pb ( "OK", &dia); |
2080 | lay.addWidget( &pb ); | 2080 | lay.addWidget( &pb ); |
2081 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2081 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2082 | dia.show(); | 2082 | dia.show(); |
2083 | int res = dia.exec(); | 2083 | int res = dia.exec(); |
2084 | if ( !res ) { | 2084 | if ( !res ) { |
2085 | setCaption( i18n("Syncing cancelled!") ); | 2085 | setCaption( i18n("Syncing cancelled!") ); |
2086 | return; | 2086 | return; |
2087 | } | 2087 | } |
2088 | mPassWordPiSync = lepw.text(); | 2088 | mPassWordPiSync = lepw.text(); |
2089 | dia.hide(); | 2089 | dia.hide(); |
2090 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); | 2090 | KOPrefs::instance()->mActiveSyncPort = lab2.text(); |
2091 | KOPrefs::instance()->mActiveSyncIP = lab.text(); | 2091 | KOPrefs::instance()->mActiveSyncIP = lab.text(); |
2092 | qApp->processEvents(); | 2092 | qApp->processEvents(); |
2093 | performQuickQuick(); | 2093 | performQuickQuick(); |
2094 | } | 2094 | } |
2095 | 2095 | ||
2096 | void MainWindow::performQuickQuick() | 2096 | void MainWindow::performQuickQuick() |
2097 | { | 2097 | { |
2098 | // setCaption( i18n("") ); | 2098 | // setCaption( i18n("") ); |
2099 | 2099 | ||
2100 | bool ok; | 2100 | bool ok; |
2101 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2101 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2102 | if ( ! ok ) { | 2102 | if ( ! ok ) { |
2103 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2103 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2104 | return; | 2104 | return; |
2105 | } | 2105 | } |
2106 | if ( !mCommandSocket ) { | 2106 | if ( !mCommandSocket ) { |
2107 | mCommandSocket = new QSocket( this ); | 2107 | mCommandSocket = new QSocket( this ); |
2108 | // delete mCommandSocket; | 2108 | // delete mCommandSocket; |
2109 | //mCommandSocket = new QSocket( this ); | 2109 | //mCommandSocket = new QSocket( this ); |
2110 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); | 2110 | connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); |
2111 | connect( mCommandSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocket()) ); | 2111 | connect( mCommandSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocket()) ); |
2112 | } | 2112 | } |
2113 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2113 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2114 | mCommandSocket->connectToHost( host, port ); | 2114 | mCommandSocket->connectToHost( host, port ); |
2115 | QTextStream os( mCommandSocket ); | 2115 | QTextStream os( mCommandSocket ); |
2116 | os.setEncoding( QTextStream::UnicodeUTF8 ); | 2116 | os.setEncoding( QTextStream::UnicodeUTF8 ); |
2117 | os << "GET " << mPassWordPiSync << "\r\n"; | 2117 | os << "GET " << mPassWordPiSync << "\r\n"; |
2118 | setCaption( i18n("Sending request for remote file ...") ); | 2118 | setCaption( i18n("Sending request for remote file ...") ); |
2119 | mTimerCommandSocket->start( 15000 ); | 2119 | mTimerCommandSocket->start( 10000 ); |
2120 | 2120 | ||
2121 | } | 2121 | } |
2122 | void MainWindow::deleteCommandSocket() | 2122 | void MainWindow::deleteCommandSocket() |
2123 | { | 2123 | { |
2124 | if ( !mCommandSocket) | 2124 | if ( !mCommandSocket) |
2125 | return; | 2125 | return; |
2126 | if ( mTimerCommandSocket->isActive () ) { | 2126 | if ( mTimerCommandSocket->isActive () ) { |
2127 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out ")); | 2127 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out ")); |
2128 | mTimerCommandSocket->stop(); | 2128 | mTimerCommandSocket->stop(); |
2129 | } | 2129 | } |
2130 | //KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocket ")); | ||
2130 | qDebug("MainWindow::deletemCommandSocket() "); | 2131 | qDebug("MainWindow::deletemCommandSocket() "); |
2131 | delete mCommandSocket; | 2132 | delete mCommandSocket; |
2132 | mCommandSocket = 0; | 2133 | mCommandSocket = 0; |
2133 | } | 2134 | } |
2134 | void MainWindow::deleteCommandSocketFinish() | 2135 | void MainWindow::deleteCommandSocketFinish() |
2135 | { | 2136 | { |
2136 | if ( ! mCommandSocketFinish) | 2137 | if ( ! mCommandSocketFinish) |
2137 | return; | 2138 | return; |
2138 | //KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocketFinish() ")); | 2139 | // KMessageBox::information( 0, i18n("MainWindow::deleteCommandSocketFinish() ")); |
2139 | qDebug("MainWindow::deletemCommandSocketFinish() "); | 2140 | qDebug("MainWindow::deletemCommandSocketFinish() "); |
2140 | delete mCommandSocketFinish; | 2141 | delete mCommandSocketFinish; |
2141 | mCommandSocketFinish = 0; | 2142 | mCommandSocketFinish = 0; |
2142 | } | 2143 | } |
2143 | void MainWindow::readFileFromSocket() | 2144 | void MainWindow::readFileFromSocket() |
2144 | { | 2145 | { |
2145 | mTimerCommandSocket->stop(); | 2146 | mTimerCommandSocket->stop(); |
2146 | setCaption( i18n("Receiving remote file ...") ); | 2147 | setCaption( i18n("Receiving remote file ...") ); |
2147 | qDebug("MainWindow::readFileFromSocket() "); | 2148 | qDebug("MainWindow::readFileFromSocket() "); |
2148 | QString fileName; | 2149 | QString fileName; |
2149 | #ifdef _WIN32_ | 2150 | #ifdef _WIN32_ |
2150 | fileName = defaultFileName() +"sync"; | 2151 | fileName = defaultFileName() +"sync"; |
2151 | #else | 2152 | #else |
2152 | fileName = "/tmp/kopitempfile.ics"; | 2153 | fileName = "/tmp/kopitempfile.ics"; |
2153 | #endif | 2154 | #endif |
2154 | QFile file( fileName ); | 2155 | QFile file( fileName ); |
2155 | if (!file.open( IO_WriteOnly ) ) { | 2156 | if (!file.open( IO_WriteOnly ) ) { |
2156 | setCaption( i18n("Error: Cannot open temp file for write.") ); | 2157 | setCaption( i18n("Error: Cannot open temp file for write.") ); |
2157 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 2158 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
2158 | return ; | 2159 | return ; |
2159 | } | 2160 | } |
2160 | 2161 | ||
2161 | //QTextStream os2( mCommandSocket ); | 2162 | //QTextStream os2( mCommandSocket ); |
2162 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); | 2163 | //os2.setEncoding( QTextStream::UnicodeUTF8 ); |
2163 | 2164 | ||
2164 | QTextStream ts( &file ); | 2165 | QTextStream ts( &file ); |
2165 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2166 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2166 | bool first = true; | 2167 | bool first = true; |
2167 | while ( mCommandSocket->canReadLine () || first) { | 2168 | while ( mCommandSocket->canReadLine () || first) { |
2168 | first = false; | 2169 | first = false; |
2169 | while ( mCommandSocket->canReadLine () ) { | 2170 | while ( mCommandSocket->canReadLine () ) { |
2170 | ts << mCommandSocket->readLine (); | 2171 | ts << mCommandSocket->readLine (); |
2171 | } | 2172 | } |
2172 | QTime ti; | 2173 | QTime ti; |
2173 | ti.start(); | 2174 | ti.start(); |
2174 | while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { | 2175 | while ( ti.elapsed () < 3000 && !mCommandSocket->canReadLine () ) { |
2175 | qApp->processEvents(); | 2176 | qApp->processEvents(); |
2176 | qDebug("waiting2 %d ",ti.elapsed () ); | 2177 | qDebug("waiting2 %d ",ti.elapsed () ); |
2177 | if ( !mCommandSocket->canReadLine () ) | 2178 | if ( !mCommandSocket->canReadLine () ) |
2178 | mCommandSocket->waitForMore ( 100 ); | 2179 | mCommandSocket->waitForMore ( 100 ); |
2179 | } | 2180 | } |
2180 | //mCommandSocket->waitForMore ( 5000 ); | 2181 | //mCommandSocket->waitForMore ( 5000 ); |
2181 | } | 2182 | } |
2182 | file.close(); | 2183 | file.close(); |
2183 | mCommandSocket->close(); | 2184 | mCommandSocket->close(); |
2184 | if ( mCommandSocket->state() == QSocket::Idle ) | 2185 | if ( mCommandSocket->state() == QSocket::Idle ) |
2185 | deleteCommandSocket(); | 2186 | deleteCommandSocket(); |
2186 | // pending: deleting after signal SIGNAL(delayedCloseFinished()) | 2187 | // pending: deleting after signal SIGNAL(delayedCloseFinished()) |
2187 | //delete mCommandSocket; | 2188 | //delete mCommandSocket; |
2188 | setCaption( i18n("Remote file saved to temp file.") ); | 2189 | setCaption( i18n("Remote file saved to temp file.") ); |
2189 | //mCommandSocket = 0; | 2190 | //mCommandSocket = 0; |
2190 | mCurrentSyncProfile = 2 ; // last file | 2191 | mCurrentSyncProfile = 2 ; // last file |
2191 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 2192 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
2192 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 2193 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
2193 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2194 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2194 | KSyncProfile* temp = new KSyncProfile (); | 2195 | KSyncProfile* temp = new KSyncProfile (); |
2195 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2196 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2196 | temp->readConfig(&config); | 2197 | temp->readConfig(&config); |
2197 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2198 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2198 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2199 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2199 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2200 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2200 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2201 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2201 | KOPrefs::instance()->mWriteBackInFuture = 0; | 2202 | KOPrefs::instance()->mWriteBackInFuture = 0; |
2202 | if ( temp->getWriteBackFuture() ) | 2203 | if ( temp->getWriteBackFuture() ) |
2203 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2204 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2204 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2205 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2205 | delete temp; | 2206 | delete temp; |
2206 | setCaption( i18n("Remote file saved to temp file.") ); | 2207 | setCaption( i18n("Remote file saved to temp file.") ); |
2207 | if ( ! syncWithFile( fileName , true ) ) { | 2208 | if ( ! syncWithFile( fileName , true ) ) { |
2208 | setCaption( i18n("Syncing failed.") ); | 2209 | setCaption( i18n("Syncing failed.") ); |
2209 | qDebug("Syncing failed "); | 2210 | qDebug("Syncing failed "); |
2210 | return; | 2211 | return; |
2211 | } | 2212 | } |
2212 | 2213 | ||
2213 | if ( !mCommandSocketFinish ) { | 2214 | if ( !mCommandSocketFinish ) { |
2214 | mCommandSocketFinish = new QSocket( this ); | 2215 | mCommandSocketFinish = new QSocket( this ); |
2215 | connect( mCommandSocketFinish, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocketFinish()) ); | 2216 | connect( mCommandSocketFinish, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteCommandSocketFinish()) ); |
2216 | } | 2217 | } |
2217 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); | 2218 | mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); |
2218 | 2219 | ||
2219 | // pending connect signals connected () and error to new slots | 2220 | // pending connect signals connected () and error to new slots |
2220 | QString host = KOPrefs::instance()->mActiveSyncIP; | 2221 | QString host = KOPrefs::instance()->mActiveSyncIP; |
2221 | QFile file2( fileName ); | 2222 | QFile file2( fileName ); |
2222 | if (!file2.open( IO_ReadOnly ) ) { | 2223 | if (!file2.open( IO_ReadOnly ) ) { |
2223 | setCaption( i18n("Error: Cannot open temp file for read.") ); | 2224 | setCaption( i18n("Error: Cannot open temp file for read.") ); |
2224 | qDebug("error open cal file "); | 2225 | qDebug("error open cal file "); |
2225 | return ; | 2226 | return ; |
2226 | 2227 | ||
2227 | } | 2228 | } |
2228 | setCaption( i18n("Sending back synced file...") ); | ||
2229 | QTextStream ts2( &file2 ); | 2229 | QTextStream ts2( &file2 ); |
2230 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2230 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2231 | QTextStream os2( mCommandSocketFinish ); | 2231 | QTextStream os2( mCommandSocketFinish ); |
2232 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2232 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2233 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2233 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2234 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2234 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2235 | setCaption( i18n("Sending back synced file...") ); | ||
2235 | os2 << "PUT " << mPassWordPiSync << "\r\n";; | 2236 | os2 << "PUT " << mPassWordPiSync << "\r\n";; |
2236 | while ( ! ts2.atEnd() ) { | 2237 | while ( ! ts2.atEnd() ) { |
2237 | os2 << ts2.readLine() << "\n"; | 2238 | os2 << ts2.readLine() << "\n"; |
2238 | } | 2239 | } |
2239 | } else { | 2240 | } else { |
2240 | os2 << "STOP\r\n"; | 2241 | os2 << "STOP\r\n"; |
2241 | } | 2242 | } |
2242 | mCommandSocketFinish->close(); | 2243 | mCommandSocketFinish->close(); |
2243 | if ( mCommandSocketFinish->state() == QSocket::Idle ) | 2244 | if ( mCommandSocketFinish->state() == QSocket::Idle ) |
2244 | deleteCommandSocketFinish(); | 2245 | QTimer::singleShot( 10, this , SLOT ( deleteCommandSocketFinish())); |
2245 | file.close(); | 2246 | file.close(); |
2246 | qDebug("Syncing succesful! "); | 2247 | qDebug("Syncing succesful! "); |
2247 | setCaption( i18n("Pi-Sync succesful!") ); | 2248 | setCaption( i18n("Pi-Sync succesful!") ); |
2248 | 2249 | ||
2250 | // KMessageBox::information( 0, i18n(" Pi-Sync succesful! ")); | ||
2249 | 2251 | ||
2250 | } | 2252 | } |
2251 | 2253 | ||
2252 | void MainWindow::syncLocalFile() | 2254 | void MainWindow::syncLocalFile() |
2253 | { | 2255 | { |
2254 | 2256 | ||
2255 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2257 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2256 | 2258 | ||
2257 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2259 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2258 | if ( fn == "" ) | 2260 | if ( fn == "" ) |
2259 | return; | 2261 | return; |
2260 | //mView->setSyncDevice("local-file" ); | 2262 | //mView->setSyncDevice("local-file" ); |
2261 | if ( syncWithFile( fn, false ) ) { | 2263 | if ( syncWithFile( fn, false ) ) { |
2262 | // Event* e = mView->getLastSyncEvent(); | 2264 | // Event* e = mView->getLastSyncEvent(); |
2263 | // e->setReadOnly( false ); | 2265 | // e->setReadOnly( false ); |
2264 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2266 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2265 | // e->setReadOnly( true ); | 2267 | // e->setReadOnly( true ); |
2266 | } | 2268 | } |
2267 | 2269 | ||
2268 | } | 2270 | } |
2269 | 2271 | ||
2270 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2272 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2271 | { | 2273 | { |
2272 | bool ret = false; | 2274 | bool ret = false; |
2273 | QFileInfo info; | 2275 | QFileInfo info; |
2274 | info.setFile( fn ); | 2276 | info.setFile( fn ); |
2275 | QString mess; | 2277 | QString mess; |
2276 | bool loadbup = true; | 2278 | bool loadbup = true; |
2277 | if ( !info. exists() ) { | 2279 | if ( !info. exists() ) { |
2278 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2280 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2279 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2281 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2280 | mess ); | 2282 | mess ); |
2281 | return ret; | 2283 | return ret; |
2282 | } | 2284 | } |
2283 | int result = 0; | 2285 | int result = 0; |
2284 | if ( !quick ) { | 2286 | if ( !quick ) { |
2285 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2287 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2286 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2288 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2287 | mess, | 2289 | mess, |
2288 | i18n("Sync"), i18n("Cancel"), 0, | 2290 | i18n("Sync"), i18n("Cancel"), 0, |
2289 | 0, 1 ); | 2291 | 0, 1 ); |
2290 | if ( result ) | 2292 | if ( result ) |
2291 | return false; | 2293 | return false; |
2292 | } | 2294 | } |
2293 | if ( KOPrefs::instance()->mAskForPreferences ) | 2295 | if ( KOPrefs::instance()->mAskForPreferences ) |
2294 | mView->edit_sync_options(); | 2296 | mView->edit_sync_options(); |
2295 | if ( result == 0 ) { | 2297 | if ( result == 0 ) { |
2296 | //qDebug("Now sycing ... "); | 2298 | //qDebug("Now sycing ... "); |
2297 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | 2299 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) |
2298 | setCaption( i18n("Synchronization successful") ); | 2300 | setCaption( i18n("Synchronization successful") ); |
2299 | else | 2301 | else |
2300 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2302 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2301 | if ( ! quick ) | 2303 | if ( ! quick ) |
2302 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | 2304 | KOPrefs::instance()->mLastSyncedLocalFile = fn; |
2303 | slotModifiedChanged( true ); | 2305 | slotModifiedChanged( true ); |
2304 | } | 2306 | } |
2305 | return ret; | 2307 | return ret; |
2306 | } | 2308 | } |
2307 | void MainWindow::quickSyncLocalFile() | 2309 | void MainWindow::quickSyncLocalFile() |
2308 | { | 2310 | { |
2309 | //mView->setSyncDevice("local-file" ); | 2311 | //mView->setSyncDevice("local-file" ); |
2310 | //qDebug("quickSyncLocalFile() "); | 2312 | //qDebug("quickSyncLocalFile() "); |
2311 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2313 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2312 | // Event* e = mView->getLastSyncEvent(); | 2314 | // Event* e = mView->getLastSyncEvent(); |