summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp52
-rw-r--r--korganizer/mainwindow.h2
2 files changed, 37 insertions, 17 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 460bbdc..f4ac0d6 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1961,295 +1961,298 @@ void MainWindow::sendFile(QSocket* socket)
1961 } 1961 }
1962 setCaption( i18n("Sending file...") ); 1962 setCaption( i18n("Sending file...") );
1963 QTextStream ts( &file ); 1963 QTextStream ts( &file );
1964 ts.setCodec( QTextCodec::codecForName("utf8") ); 1964 ts.setCodec( QTextCodec::codecForName("utf8") );
1965 QTextStream os( socket ); 1965 QTextStream os( socket );
1966 os.setCodec( QTextCodec::codecForName("utf8") ); 1966 os.setCodec( QTextCodec::codecForName("utf8") );
1967 //os.setEncoding( QTextStream::UnicodeUTF8 ); 1967 //os.setEncoding( QTextStream::UnicodeUTF8 );
1968 while ( ! ts.atEnd() ) { 1968 while ( ! ts.atEnd() ) {
1969 os << ts.readLine() << "\n"; 1969 os << ts.readLine() << "\n";
1970 } 1970 }
1971 //os << ts.read(); 1971 //os << ts.read();
1972 socket->close(); 1972 socket->close();
1973 file.close(); 1973 file.close();
1974 setCaption( i18n("File sent. Waiting to get back synced file") ); 1974 setCaption( i18n("File sent. Waiting to get back synced file") );
1975 qDebug("file sent "); 1975 qDebug("file sent ");
1976} 1976}
1977void MainWindow::getFile(QSocket* socket) 1977void MainWindow::getFile(QSocket* socket)
1978{ 1978{
1979 setCaption( i18n("Receiving synced file...") ); 1979 setCaption( i18n("Receiving synced file...") );
1980 1980
1981 QString fileName = defaultFileName(); 1981 QString fileName = defaultFileName();
1982 QFile file( fileName ); 1982 QFile file( fileName );
1983 if (!file.open( IO_WriteOnly ) ) { 1983 if (!file.open( IO_WriteOnly ) ) {
1984 setCaption( i18n("Error open file") ); 1984 setCaption( i18n("Error open file") );
1985 delete mSyncActionDialog; 1985 delete mSyncActionDialog;
1986 mSyncActionDialog = 0; 1986 mSyncActionDialog = 0;
1987 qDebug("error open cal file "); 1987 qDebug("error open cal file ");
1988 return ; 1988 return ;
1989 1989
1990 } 1990 }
1991 1991
1992 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1992 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1993 QTextStream ts( &file ); 1993 QTextStream ts( &file );
1994 ts.setCodec( QTextCodec::codecForName("utf8") ); 1994 ts.setCodec( QTextCodec::codecForName("utf8") );
1995 bool first = true; 1995 bool first = true;
1996 while ( socket->canReadLine () || first ) { 1996 while ( socket->canReadLine () || first ) {
1997 first = false; 1997 first = false;
1998 while ( socket->canReadLine () ) { 1998 while ( socket->canReadLine () ) {
1999 qDebug("avail %d ", socket->bytesAvailable () ); 1999 qDebug("avail %d ", socket->bytesAvailable () );
2000 ts << socket->readLine (); 2000 ts << socket->readLine ();
2001 } 2001 }
2002 QTime ti; 2002 QTime ti;
2003 ti.start(); 2003 ti.start();
2004 while ( ti.elapsed () < 5000 && !socket->canReadLine () ) { 2004 while ( ti.elapsed () < 5000 && !socket->canReadLine () ) {
2005 qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () ); 2005 qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () );
2006 //qApp->processEvents(); 2006 //qApp->processEvents();
2007 qDebug("waiting1b %d ",ti.elapsed () ); 2007 qDebug("waiting1b %d ",ti.elapsed () );
2008 if ( !socket->canReadLine () ) { 2008 if ( !socket->canReadLine () ) {
2009 qDebug("waiting1c %d ",ti.elapsed () ); 2009 qDebug("waiting1c %d ",ti.elapsed () );
2010 usleep( 100000); 2010 usleep( 100000);
2011 } 2011 }
2012 //socket->waitForMore ( 100 ); 2012 //socket->waitForMore ( 100 );
2013 } 2013 }
2014 ts << socket->readLine (); 2014 ts << socket->readLine ();
2015#if 0 2015#if 0
2016#ifdef DESKTOP_VERSION 2016#ifdef DESKTOP_VERSION
2017 socket->waitForMore ( 5000 ); 2017 socket->waitForMore ( 5000 );
2018#else 2018#else
2019 // socket->waitForMore ( 5000 ); 2019 // socket->waitForMore ( 5000 );
2020 // seems to be broken in qt2 2020 // seems to be broken in qt2
2021 bool stop = false; 2021 bool stop = false;
2022 QTime ti; 2022 QTime ti;
2023 ti.start(); 2023 ti.start();
2024 while ( ti.elapsed < 5000 && !stop ) { 2024 while ( ti.elapsed < 5000 && !stop ) {
2025 qApp->processEvents(); 2025 qApp->processEvents();
2026 if ( socket->canReadLine () ) 2026 if ( socket->canReadLine () )
2027 stop = true ; 2027 stop = true ;
2028 else { 2028 else {
2029 usleep( 100000 ); 2029 usleep( 100000 );
2030 2030
2031 } 2031 }
2032 } 2032 }
2033#endif 2033#endif
2034#endif 2034#endif
2035 } 2035 }
2036 setCaption( i18n("File received - reloading calendar...") ); 2036 setCaption( i18n("File received - reloading calendar...") );
2037 file.close();
2038 socket->close(); 2037 socket->close();
2038 file.close();
2039 mView->watchSavedFile(); 2039 mView->watchSavedFile();
2040 mView->openCalendar( defaultFileName() ); 2040 mView->openCalendar( defaultFileName() );
2041 setCaption( i18n("Easy-Pi-Sync successful!") ); 2041 setCaption( i18n("Easy-Pi-Sync successful!") );
2042 delete mSyncActionDialog; 2042 delete mSyncActionDialog;
2043 mSyncActionDialog = 0; 2043 mSyncActionDialog = 0;
2044 2044
2045 2045
2046} 2046}
2047void MainWindow::endConnect() 2047void MainWindow::endConnect()
2048{ 2048{
2049 setCaption( i18n("No file received - syncing successful") ); 2049 setCaption( i18n("No file received - syncing successful") );
2050 delete mSyncActionDialog; 2050 delete mSyncActionDialog;
2051 mSyncActionDialog = 0; 2051 mSyncActionDialog = 0;
2052} 2052}
2053void MainWindow::performQuick() 2053void MainWindow::performQuick()
2054{ 2054{
2055 setCaption( i18n("Please input connection settings") ); 2055 setCaption( i18n("Please input connection settings") );
2056 QString retfile = ""; 2056 QString retfile = "";
2057 QDialog dia ( this, "input-dialog", true ); 2057 QDialog dia ( this, "input-dialog", true );
2058 QLineEdit lab ( &dia ); 2058 QLineEdit lab ( &dia );
2059 QVBoxLayout lay( &dia ); 2059 QVBoxLayout lay( &dia );
2060 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia ); 2060 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia );
2061 lay.addWidget( &label); 2061 lay.addWidget( &label);
2062 lab.setText( KOPrefs::instance()->mActiveSyncIP ); 2062 lab.setText( KOPrefs::instance()->mActiveSyncIP );
2063 lay.setMargin(7); 2063 lay.setMargin(7);
2064 lay.setSpacing(7); 2064 lay.setSpacing(7);
2065 lay.addWidget( &lab); 2065 lay.addWidget( &lab);
2066 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia ); 2066 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia );
2067 lay.addWidget( &label2); 2067 lay.addWidget( &label2);
2068 QLineEdit lab2 ( &dia ); 2068 QLineEdit lab2 ( &dia );
2069 lab2.setText( KOPrefs::instance()->mActiveSyncPort ); 2069 lab2.setText( KOPrefs::instance()->mActiveSyncPort );
2070 lay.addWidget( &lab2); 2070 lay.addWidget( &lab2);
2071 dia.setFixedSize( 230,200 ); 2071 dia.setFixedSize( 230,200 );
2072 dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") ); 2072 dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") );
2073 QPushButton pb ( "OK", &dia); 2073 QPushButton pb ( "OK", &dia);
2074 lay.addWidget( &pb ); 2074 lay.addWidget( &pb );
2075 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2075 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2076 dia.show(); 2076 dia.show();
2077 int res = dia.exec(); 2077 int res = dia.exec();
2078 if ( !res ) { 2078 if ( !res ) {
2079 setCaption( i18n("Syncing cancelled!") ); 2079 setCaption( i18n("Syncing cancelled!") );
2080 return; 2080 return;
2081 } 2081 }
2082 dia.hide(); 2082 dia.hide();
2083 KOPrefs::instance()->mActiveSyncPort = lab2.text(); 2083 KOPrefs::instance()->mActiveSyncPort = lab2.text();
2084 KOPrefs::instance()->mActiveSyncIP = lab.text(); 2084 KOPrefs::instance()->mActiveSyncIP = lab.text();
2085 qApp->processEvents(); 2085 qApp->processEvents();
2086 performQuickQuick(); 2086 performQuickQuick();
2087} 2087}
2088 2088
2089void MainWindow::performQuickQuick() 2089void MainWindow::performQuickQuick()
2090{ 2090{
2091 // setCaption( i18n("") ); 2091 // setCaption( i18n("") );
2092 2092
2093 bool ok; 2093 bool ok;
2094 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 2094 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2095 if ( ! ok ) { 2095 if ( ! ok ) {
2096 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 2096 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2097 return; 2097 return;
2098 } 2098 }
2099 if ( !mCommandSocket ) { 2099 if ( !mCommandSocket ) {
2100 mCommandSocket = new QSocket( this ); 2100 mCommandSocket = new QSocket( this );
2101 // delete mCommandSocket; 2101 // delete mCommandSocket;
2102 //mCommandSocket = new QSocket( this ); 2102 //mCommandSocket = new QSocket( this );
2103 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); 2103 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) );
2104 } 2104 }
2105 QString host = KOPrefs::instance()->mActiveSyncIP; 2105 QString host = KOPrefs::instance()->mActiveSyncIP;
2106 mCommandSocket->connectToHost( host, port ); 2106 mCommandSocket->connectToHost( host, port );
2107 QTextStream os( mCommandSocket ); 2107 QTextStream os( mCommandSocket );
2108 os.setEncoding( QTextStream::UnicodeUTF8 ); 2108 os.setEncoding( QTextStream::UnicodeUTF8 );
2109 os << "GET\r\n"; 2109 os << "GET\r\n";
2110 setCaption( i18n("Sending request for remote file ...") ); 2110 setCaption( i18n("Sending request for remote file ...") );
2111 2111
2112} 2112}
2113void MainWindow::readFileFromSocket() 2113void MainWindow::readFileFromSocket()
2114{ 2114{
2115 setCaption( i18n("Receiving remote file ...") ); 2115 setCaption( i18n("Receiving remote file ...") );
2116 qDebug("MainWindow::readFileFromSocket() "); 2116 qDebug("MainWindow::readFileFromSocket() ");
2117QString fileName; 2117 QString fileName;
2118#ifdef _WIN32_ 2118#ifdef _WIN32_
2119 fileName = defaultFileName() +"sync"; 2119 fileName = defaultFileName() +"sync";
2120#else 2120#else
2121 fileName = "/tmp/kopitempfile.ics"; 2121 fileName = "/tmp/kopitempfile.ics";
2122#endif 2122#endif
2123 QFile file( fileName ); 2123 QFile file( fileName );
2124 if (!file.open( IO_WriteOnly ) ) { 2124 if (!file.open( IO_WriteOnly ) ) {
2125 setCaption( i18n("Error: Cannot open temp file for write.") ); 2125 setCaption( i18n("Error: Cannot open temp file for write.") );
2126 qDebug("Error open calender file for writing: %s",fileName.latin1() ); 2126 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2127 return ; 2127 return ;
2128 } 2128 }
2129 2129
2130 //QTextStream os2( mCommandSocket ); 2130 //QTextStream os2( mCommandSocket );
2131 //os2.setEncoding( QTextStream::UnicodeUTF8 ); 2131 //os2.setEncoding( QTextStream::UnicodeUTF8 );
2132 2132
2133 QTextStream ts( &file ); 2133 QTextStream ts( &file );
2134 ts.setCodec( QTextCodec::codecForName("utf8") ); 2134 ts.setCodec( QTextCodec::codecForName("utf8") );
2135 bool first = true; 2135 bool first = true;
2136 while ( mCommandSocket->canReadLine () || first) { 2136 while ( mCommandSocket->canReadLine () || first) {
2137 first = false; 2137 first = false;
2138 while ( mCommandSocket->canReadLine () ) { 2138 while ( mCommandSocket->canReadLine () ) {
2139 ts << mCommandSocket->readLine (); 2139 ts << mCommandSocket->readLine ();
2140 } 2140 }
2141 QTime ti; 2141 QTime ti;
2142 ti.start(); 2142 ti.start();
2143 while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) { 2143 while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) {
2144 qApp->processEvents(); 2144 qApp->processEvents();
2145 qDebug("waiting2 %d ",ti.elapsed () ); 2145 qDebug("waiting2 %d ",ti.elapsed () );
2146 if ( !mCommandSocket->canReadLine () ) 2146 if ( !mCommandSocket->canReadLine () )
2147 mCommandSocket->waitForMore ( 100 ); 2147 mCommandSocket->waitForMore ( 100 );
2148 } 2148 }
2149 //mCommandSocket->waitForMore ( 5000 ); 2149 //mCommandSocket->waitForMore ( 5000 );
2150 } 2150 }
2151 file.close(); 2151 file.close();
2152 mCommandSocket->close(); 2152 mCommandSocket->close();
2153 // pending: deleting after signal SIGNAL(delayedCloseFinished())
2153 //delete mCommandSocket; 2154 //delete mCommandSocket;
2154 setCaption( i18n("Remote file saved to temp file.") ); 2155 setCaption( i18n("Remote file saved to temp file.") );
2155 //mCommandSocket = 0; 2156 //mCommandSocket = 0;
2156 mCurrentSyncProfile = 2 ; // last file 2157 mCurrentSyncProfile = 2 ; // last file
2157 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 2158 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
2158 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 2159 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
2159 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2160 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2160 KSyncProfile* temp = new KSyncProfile (); 2161 KSyncProfile* temp = new KSyncProfile ();
2161 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2162 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2162 temp->readConfig(&config); 2163 temp->readConfig(&config);
2163 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2164 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2164 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2165 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2165 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2166 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2166 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2167 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2167 KOPrefs::instance()->mWriteBackInFuture = 0; 2168 KOPrefs::instance()->mWriteBackInFuture = 0;
2168 if ( temp->getWriteBackFuture() ) 2169 if ( temp->getWriteBackFuture() )
2169 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2170 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2170 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2171 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2171 2172
2172 setCaption( i18n("Remote file saved to temp file.") ); 2173 setCaption( i18n("Remote file saved to temp file.") );
2173 if ( ! syncWithFile( fileName , true ) ) { 2174 if ( ! syncWithFile( fileName , true ) ) {
2174 setCaption( i18n("Syncing failed.") ); 2175 setCaption( i18n("Syncing failed.") );
2175 qDebug("Syncing failed "); 2176 qDebug("Syncing failed ");
2176 return; 2177 return;
2177 } 2178 }
2178 2179
2179 if ( !mCommandSocketFinish ) { 2180 if ( !mCommandSocketFinish ) {
2180 mCommandSocketFinish = new QSocket( this ); 2181 mCommandSocketFinish = new QSocket( this );
2181 } 2182 }
2182 mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); 2183 mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() );
2183 2184
2185 // pending connect signals connected () and error to new slots
2184 QString host = KOPrefs::instance()->mActiveSyncIP; 2186 QString host = KOPrefs::instance()->mActiveSyncIP;
2185 QFile file2( fileName ); 2187 QFile file2( fileName );
2186 if (!file2.open( IO_ReadOnly ) ) { 2188 if (!file2.open( IO_ReadOnly ) ) {
2187 setCaption( i18n("Error: Cannot open temp file for read.") ); 2189 setCaption( i18n("Error: Cannot open temp file for read.") );
2188 qDebug("error open cal file "); 2190 qDebug("error open cal file ");
2189 return ; 2191 return ;
2190 2192
2191 } 2193 }
2192 setCaption( i18n("Sending back synced file...") ); 2194 setCaption( i18n("Sending back synced file...") );
2193 QTextStream ts2( &file2 ); 2195 QTextStream ts2( &file2 );
2194 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2196 ts2.setCodec( QTextCodec::codecForName("utf8") );
2195 QTextStream os2( mCommandSocketFinish ); 2197 QTextStream os2( mCommandSocketFinish );
2196 os2.setCodec( QTextCodec::codecForName("utf8") ); 2198 os2.setCodec( QTextCodec::codecForName("utf8") );
2197 //os.setEncoding( QTextStream::UnicodeUTF8 ); 2199 //os.setEncoding( QTextStream::UnicodeUTF8 );
2198 if ( KOPrefs::instance()->mWriteBackFile ) { 2200 if ( KOPrefs::instance()->mWriteBackFile ) {
2199 os2 << "PUT\r\n"; 2201 os2 << "PUT\r\n";
2200 while ( ! ts2.atEnd() ) { 2202 while ( ! ts2.atEnd() ) {
2201 os2 << ts2.readLine() << "\n"; 2203 os2 << ts2.readLine() << "\n";
2202 } 2204 }
2203 } else { 2205 } else {
2204 os2 << "STOP\r\n"; 2206 os2 << "STOP\r\n";
2205 } 2207 }
2206 mCommandSocketFinish->close(); 2208 mCommandSocketFinish->close();
2207 file.close(); 2209 file.close();
2210 // pending: deleting after signal SIGNAL(delayedCloseFinished())
2208 //delete ( mCommandSocket); 2211 //delete ( mCommandSocket);
2209 //mCommandSocket = 0; 2212 //mCommandSocket = 0;
2210 qDebug("Syncing succesful! "); 2213 qDebug("Syncing succesful! ");
2211 setCaption( i18n("Easy-Pi-Sync succesful!") ); 2214 setCaption( i18n("Easy-Pi-Sync succesful!") );
2212 2215
2213 2216
2214} 2217}
2215 2218
2216void MainWindow::syncLocalFile() 2219void MainWindow::syncLocalFile()
2217{ 2220{
2218 2221
2219 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2222 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2220 2223
2221 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2224 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2222 if ( fn == "" ) 2225 if ( fn == "" )
2223 return; 2226 return;
2224 //mView->setSyncDevice("local-file" ); 2227 //mView->setSyncDevice("local-file" );
2225 if ( syncWithFile( fn, false ) ) { 2228 if ( syncWithFile( fn, false ) ) {
2226 // Event* e = mView->getLastSyncEvent(); 2229 // Event* e = mView->getLastSyncEvent();
2227// e->setReadOnly( false ); 2230// e->setReadOnly( false );
2228// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2231// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2229// e->setReadOnly( true ); 2232// e->setReadOnly( true );
2230 } 2233 }
2231 2234
2232} 2235}
2233 2236
2234bool MainWindow::syncWithFile( QString fn , bool quick ) 2237bool MainWindow::syncWithFile( QString fn , bool quick )
2235{ 2238{
2236 bool ret = false; 2239 bool ret = false;
2237 QFileInfo info; 2240 QFileInfo info;
2238 info.setFile( fn ); 2241 info.setFile( fn );
2239 QString mess; 2242 QString mess;
2240 bool loadbup = true; 2243 bool loadbup = true;
2241 if ( !info. exists() ) { 2244 if ( !info. exists() ) {
2242 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2245 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2243 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2246 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2244 mess ); 2247 mess );
2245 return ret; 2248 return ret;
2246 } 2249 }
2247 int result = 0; 2250 int result = 0;
2248 if ( !quick ) { 2251 if ( !quick ) {
2249 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2252 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2250 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2253 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2251 mess, 2254 mess,
2252 i18n("Sync"), i18n("Cancel"), 0, 2255 i18n("Sync"), i18n("Cancel"), 0,
2253 0, 1 ); 2256 0, 1 );
2254 if ( result ) 2257 if ( result )
2255 return false; 2258 return false;
@@ -2446,96 +2449,111 @@ void MainWindow::syncSSH()
2446 } 2449 }
2447 } 2450 }
2448 return; 2451 return;
2449#if 0 2452#if 0
2450 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2453 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2451 while ( timer.elapsed() < 5000 ) 2454 while ( timer.elapsed() < 5000 )
2452 qApp->processEvents(); 2455 qApp->processEvents();
2453 2456
2454 qDebug("MainWindow::merging) "); 2457 qDebug("MainWindow::merging) ");
2455 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2458 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2456 while ( mBlockSaveFlag ) 2459 while ( mBlockSaveFlag )
2457 qApp->processEvents(); 2460 qApp->processEvents();
2458 save(); 2461 save();
2459 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2462 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2460#endif 2463#endif
2461 2464
2462} 2465}
2463 2466
2464 2467
2465void MainWindow::syncSharp() 2468void MainWindow::syncSharp()
2466{ 2469{
2467 if ( mCalendarModifiedFlag ) 2470 if ( mCalendarModifiedFlag )
2468 save(); 2471 save();
2469 mView->syncSharp(); 2472 mView->syncSharp();
2470 slotModifiedChanged( true ); 2473 slotModifiedChanged( true );
2471 2474
2472} 2475}
2473void MainWindow::syncPhone() 2476void MainWindow::syncPhone()
2474{ 2477{
2475 if ( mCalendarModifiedFlag ) 2478 if ( mCalendarModifiedFlag )
2476 save(); 2479 save();
2477 mView->syncPhone(); 2480 mView->syncPhone();
2478 slotModifiedChanged( true ); 2481 slotModifiedChanged( true );
2479 2482
2480} 2483}
2481 2484
2482void MainWindow::printSel( ) 2485void MainWindow::printSel( )
2483{ 2486{
2484 mView->viewManager()->agendaView()->agenda()->printSelection(); 2487 mView->viewManager()->agendaView()->agenda()->printSelection();
2485} 2488}
2486 2489
2487void MainWindow::printCal() 2490void MainWindow::printCal()
2488{ 2491{
2489 mView->print();//mCp->showDialog(); 2492 mView->print();//mCp->showDialog();
2490} 2493}
2491 2494
2492 2495
2493 2496
2494KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ){;}; 2497KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
2498{
2499
2500 mSocket = 0;
2501};
2495 2502
2496void KServerSocket::newConnection ( int socket ) 2503void KServerSocket::newConnection ( int socket )
2497{ 2504{
2498 qDebug("KServerSocket:New connection %d ", socket); 2505 qDebug("KServerSocket:New connection %d ", socket);
2499 QSocket* s = new QSocket( this ); 2506 if ( mSocket ) {
2500 connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) ); 2507 qDebug("KServerSocket::newConnection Socket deleted! ");
2501 connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 2508 delete mSocket;
2502 s->setSocket( socket ); 2509 mSocket = 0;
2510 }
2511 mSocket = new QSocket( this );
2512 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2513 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2514 mSocket->setSocket( socket );
2503} 2515}
2504 2516
2505void KServerSocket::discardClient() 2517void KServerSocket::discardClient()
2506{ 2518{
2507 qDebug(" KServerSocket::discardClient()"); 2519 qDebug(" KServerSocket::discardClient()");
2508 QSocket* socket = (QSocket*)sender(); 2520 if ( mSocket ) {
2509 delete socket; 2521 qDebug("delete ");
2522 delete mSocket;
2523 mSocket = 0;
2524 }
2510 //emit endConnect(); 2525 //emit endConnect();
2511} 2526}
2512void KServerSocket::readClient() 2527void KServerSocket::readClient()
2513{ 2528{
2529 if ( mSocket == 0 ) {
2530 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2531 return;
2532 }
2514 qDebug("KServerSocket readClient()"); 2533 qDebug("KServerSocket readClient()");
2515 QSocket* socket = (QSocket*)sender(); 2534 if ( mSocket->canReadLine() ) {
2516 if ( socket->canReadLine() ) { 2535 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
2517 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() );
2518 qDebug("KServerSocket socket->canReadLine()"); 2536 qDebug("KServerSocket socket->canReadLine()");
2519 if ( tokens[0] == "GET" ) { 2537 if ( tokens[0] == "GET" ) {
2520 emit sendFile( socket ); 2538 emit sendFile( mSocket );
2521 } 2539 }
2522 if ( tokens[0] == "PUT" ) { 2540 if ( tokens[0] == "PUT" ) {
2523 emit getFile( socket ); 2541 emit getFile( mSocket );
2524 } 2542 }
2525 if ( tokens[0] == "STOP" ) { 2543 if ( tokens[0] == "STOP" ) {
2526 emit endConnect(); 2544 emit endConnect();
2527 } 2545 }
2528 } 2546 }
2529} 2547}
2530 2548
2531 2549
2532 2550
2533 2551
2534 2552
2535 2553
2536 2554
2537 2555
2538 2556
2539 2557
2540 2558
2541 2559
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 7b4fd27..cc656a3 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,88 +1,90 @@
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 <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
12class QAction; 12class QAction;
13class CalendarView; 13class CalendarView;
14class KSyncProfile; 14class 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
20class QPEToolBar; 20class 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
25class KServerSocket : public QServerSocket 25class KServerSocket : public QServerSocket
26{ 26{
27 Q_OBJECT 27 Q_OBJECT
28 28
29public: 29public:
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 31
32 void newConnection ( int socket ) ; 32 void newConnection ( int socket ) ;
33 33
34signals: 34signals:
35 void sendFile(QSocket*); 35 void sendFile(QSocket*);
36 void getFile(QSocket*); 36 void getFile(QSocket*);
37 void endConnect(); 37 void endConnect();
38private slots: 38private slots:
39 void discardClient(); 39 void discardClient();
40 void readClient(); 40 void readClient();
41 private :
42 QSocket* mSocket;
41}; 43};
42 44
43 45
44namespace KCal { 46namespace KCal {
45class CalendarLocal; 47class CalendarLocal;
46} 48}
47 49
48using namespace KCal; 50using namespace KCal;
49 51
50class MainWindow : public QMainWindow 52class MainWindow : public QMainWindow
51{ 53{
52 Q_OBJECT 54 Q_OBJECT
53 public: 55 public:
54 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 56 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
55 ~MainWindow(); 57 ~MainWindow();
56 public slots: 58 public slots:
57 virtual void showMaximized (); 59 virtual void showMaximized ();
58 void configureAgenda( int ); 60 void configureAgenda( int );
59 void recieve( const QCString& msg, const QByteArray& data ); 61 void recieve( const QCString& msg, const QByteArray& data );
60 static QString defaultFileName(); 62 static QString defaultFileName();
61 static QString resourcePath(); 63 static QString resourcePath();
62 protected slots: 64 protected slots:
63 void setCaptionToDates(); 65 void setCaptionToDates();
64 int ringSync(); 66 int ringSync();
65 void multiSync( bool askforPrefs = false ); 67 void multiSync( bool askforPrefs = false );
66 void about(); 68 void about();
67 void licence(); 69 void licence();
68 void faq(); 70 void faq();
69 void usertrans(); 71 void usertrans();
70 void features(); 72 void features();
71 void synchowto(); 73 void synchowto();
72 void whatsNew(); 74 void whatsNew();
73 void keyBindings(); 75 void keyBindings();
74 void aboutAutoSaving();; 76 void aboutAutoSaving();;
75 void aboutKnownBugs(); 77 void aboutKnownBugs();
76 78
77 void processIncidenceSelection( Incidence * ); 79 void processIncidenceSelection( Incidence * );
78 80
79 void importQtopia(); 81 void importQtopia();
80 void importBday(); 82 void importBday();
81 void importOL(); 83 void importOL();
82 void importIcal(); 84 void importIcal();
83 void importFile( QString, bool ); 85 void importFile( QString, bool );
84 void quickImportIcal(); 86 void quickImportIcal();
85 87
86 void slotModifiedChanged( bool ); 88 void slotModifiedChanged( bool );
87 89
88 void save(); 90 void save();