summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-22 23:36:37 (UTC)
committer zautrix <zautrix>2004-09-22 23:36:37 (UTC)
commite2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b (patch) (unidiff)
treef45771acfd61a0ddda6b253082f243acac473d33
parent772411a6c16f9b2299bd173116faeb4482325bcc (diff)
downloadkdepimpi-e2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b.zip
kdepimpi-e2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b.tar.gz
kdepimpi-e2bc785d2f98d2aeac6ab6a5e39ff4f6e679517b.tar.bz2
bugfixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp32
-rw-r--r--korganizer/mainwindow.h1
2 files changed, 19 insertions, 14 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index ebe761a..2e6b5c8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -64,24 +64,25 @@ using namespace KCal;
64#endif 64#endif
65#include "mainwindow.h" 65#include "mainwindow.h"
66 66
67int globalFlagBlockStartup; 67int globalFlagBlockStartup;
68MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 68MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
69 QMainWindow( parent, name ) 69 QMainWindow( parent, name )
70{ 70{
71 71
72#ifdef DESKTOP_VERSION 72#ifdef DESKTOP_VERSION
73 setFont( QFont("Arial"), 14 ); 73 setFont( QFont("Arial"), 14 );
74#endif 74#endif
75 mCommandSocket = 0; 75 mCommandSocket = 0;
76 mCommandSocketFinish = 0;
76 mSyncActionDialog = 0; 77 mSyncActionDialog = 0;
77 mServerSocket = 0; 78 mServerSocket = 0;
78 mClosed = false; 79 mClosed = false;
79 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 80 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
80 QString confFile = locateLocal("config","korganizerrc"); 81 QString confFile = locateLocal("config","korganizerrc");
81 QFileInfo finf ( confFile ); 82 QFileInfo finf ( confFile );
82 bool showWarning = !finf.exists(); 83 bool showWarning = !finf.exists();
83 setIcon(SmallIcon( "ko24" ) ); 84 setIcon(SmallIcon( "ko24" ) );
84 mBlockAtStartup = true; 85 mBlockAtStartup = true;
85 mFlagKeyPressed = false; 86 mFlagKeyPressed = false;
86 setCaption("KOrganizer/Pi"); 87 setCaption("KOrganizer/Pi");
87 KOPrefs *p = KOPrefs::instance(); 88 KOPrefs *p = KOPrefs::instance();
@@ -1972,25 +1973,24 @@ void MainWindow::sendFile(QSocket* socket)
1972 while ( ! ts.atEnd() ) { 1973 while ( ! ts.atEnd() ) {
1973 os << ts.readLine() << "\n"; 1974 os << ts.readLine() << "\n";
1974 } 1975 }
1975 //os << ts.read(); 1976 //os << ts.read();
1976 socket->close(); 1977 socket->close();
1977 file.close(); 1978 file.close();
1978 setCaption( i18n("File sent. Waiting to get back synced file") ); 1979 setCaption( i18n("File sent. Waiting to get back synced file") );
1979 qDebug("file sent "); 1980 qDebug("file sent ");
1980} 1981}
1981void MainWindow::getFile(QSocket* socket) 1982void MainWindow::getFile(QSocket* socket)
1982{ 1983{
1983 setCaption( i18n("Receiving synced file...") ); 1984 setCaption( i18n("Receiving synced file...") );
1984 qDebug("MainWindow::sendFile(QSocket* s) ");
1985 1985
1986 QString fileName = defaultFileName(); 1986 QString fileName = defaultFileName();
1987 QFile file( fileName ); 1987 QFile file( fileName );
1988 if (!file.open( IO_WriteOnly ) ) { 1988 if (!file.open( IO_WriteOnly ) ) {
1989 setCaption( i18n("Error open file") ); 1989 setCaption( i18n("Error open file") );
1990 delete mSyncActionDialog; 1990 delete mSyncActionDialog;
1991 mSyncActionDialog = 0; 1991 mSyncActionDialog = 0;
1992 qDebug("error open cal file "); 1992 qDebug("error open cal file ");
1993 return ; 1993 return ;
1994 1994
1995 } 1995 }
1996 1996
@@ -2059,28 +2059,30 @@ void MainWindow::performQuick()
2059} 2059}
2060 2060
2061void MainWindow::performQuickQuick() 2061void MainWindow::performQuickQuick()
2062{ 2062{
2063 // setCaption( i18n("") ); 2063 // setCaption( i18n("") );
2064 2064
2065 bool ok; 2065 bool ok;
2066 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 2066 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2067 if ( ! ok ) { 2067 if ( ! ok ) {
2068 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 2068 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2069 return; 2069 return;
2070 } 2070 }
2071 if ( mCommandSocket ) 2071 if ( !mCommandSocket ) {
2072 delete mCommandSocket; 2072 mCommandSocket = new QSocket( this );
2073 mCommandSocket = new QSocket( this ); 2073 // delete mCommandSocket;
2074 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) ); 2074 //mCommandSocket = new QSocket( this );
2075 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) );
2076 }
2075 QString host = KOPrefs::instance()->mActiveSyncIP; 2077 QString host = KOPrefs::instance()->mActiveSyncIP;
2076 mCommandSocket->connectToHost( host, port ); 2078 mCommandSocket->connectToHost( host, port );
2077 QTextStream os( mCommandSocket ); 2079 QTextStream os( mCommandSocket );
2078 os.setEncoding( QTextStream::UnicodeUTF8 ); 2080 os.setEncoding( QTextStream::UnicodeUTF8 );
2079 os << "GET\r\n"; 2081 os << "GET\r\n";
2080 setCaption( i18n("Sending request for remote file ...") ); 2082 setCaption( i18n("Sending request for remote file ...") );
2081 2083
2082} 2084}
2083void MainWindow::readFileFromSocket() 2085void MainWindow::readFileFromSocket()
2084{ 2086{
2085 setCaption( i18n("Receiving remote file ...") ); 2087 setCaption( i18n("Receiving remote file ...") );
2086 qDebug("MainWindow::readFileFromSocket() "); 2088 qDebug("MainWindow::readFileFromSocket() ");
@@ -2103,79 +2105,81 @@ QString fileName;
2103 QTextStream ts( &file ); 2105 QTextStream ts( &file );
2104 ts.setCodec( QTextCodec::codecForName("utf8") ); 2106 ts.setCodec( QTextCodec::codecForName("utf8") );
2105 bool first = true; 2107 bool first = true;
2106 while ( mCommandSocket->canReadLine () || first) { 2108 while ( mCommandSocket->canReadLine () || first) {
2107 first = false; 2109 first = false;
2108 while ( mCommandSocket->canReadLine () ) { 2110 while ( mCommandSocket->canReadLine () ) {
2109 ts << mCommandSocket->readLine (); 2111 ts << mCommandSocket->readLine ();
2110 } 2112 }
2111 mCommandSocket->waitForMore ( 5000 ); 2113 mCommandSocket->waitForMore ( 5000 );
2112 } 2114 }
2113 file.close(); 2115 file.close();
2114 mCommandSocket->close(); 2116 mCommandSocket->close();
2115 delete mCommandSocket; 2117 //delete mCommandSocket;
2116 setCaption( i18n("Remote file saved to temp file.") ); 2118 setCaption( i18n("Remote file saved to temp file.") );
2117 mCommandSocket = 0; 2119 //mCommandSocket = 0;
2118 mCurrentSyncProfile = 2 ; // last file 2120 mCurrentSyncProfile = 2 ; // last file
2119 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 2121 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
2120 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 2122 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
2121 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2123 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2122 KSyncProfile* temp = new KSyncProfile (); 2124 KSyncProfile* temp = new KSyncProfile ();
2123 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2125 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2124 temp->readConfig(&config); 2126 temp->readConfig(&config);
2125 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2127 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2126 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2128 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2127 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2129 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2128 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2130 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2129 KOPrefs::instance()->mWriteBackInFuture = 0; 2131 KOPrefs::instance()->mWriteBackInFuture = 0;
2130 if ( temp->getWriteBackFuture() ) 2132 if ( temp->getWriteBackFuture() )
2131 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2133 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2132 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2134 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2133 2135
2134 setCaption( i18n("Remote file saved to temp file.") ); 2136 setCaption( i18n("Remote file saved to temp file.") );
2135 if ( ! syncWithFile( fileName , true ) ) { 2137 if ( ! syncWithFile( fileName , true ) ) {
2136 setCaption( i18n("Syncing failed.") ); 2138 setCaption( i18n("Syncing failed.") );
2137 qDebug("Syncing failed "); 2139 qDebug("Syncing failed ");
2138 return; 2140 return;
2139 } 2141 }
2140 2142
2141 mCommandSocket = new QSocket( this ); 2143 if ( !mCommandSocketFinish ) {
2142 QString host = KOPrefs::instance()->mActiveSyncIP; 2144 mCommandSocketFinish = new QSocket( this );
2143 mCommandSocket->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() ); 2145 }
2146 mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() );
2144 2147
2148 QString host = KOPrefs::instance()->mActiveSyncIP;
2145 QFile file2( fileName ); 2149 QFile file2( fileName );
2146 if (!file2.open( IO_ReadOnly ) ) { 2150 if (!file2.open( IO_ReadOnly ) ) {
2147 setCaption( i18n("Error: Cannot open temp file for read.") ); 2151 setCaption( i18n("Error: Cannot open temp file for read.") );
2148 qDebug("error open cal file "); 2152 qDebug("error open cal file ");
2149 return ; 2153 return ;
2150 2154
2151 } 2155 }
2152 setCaption( i18n("Sending back synced file...") ); 2156 setCaption( i18n("Sending back synced file...") );
2153 QTextStream ts2( &file2 ); 2157 QTextStream ts2( &file2 );
2154 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2158 ts2.setCodec( QTextCodec::codecForName("utf8") );
2155 QTextStream os2( mCommandSocket ); 2159 QTextStream os2( mCommandSocketFinish );
2156 os2.setCodec( QTextCodec::codecForName("utf8") ); 2160 os2.setCodec( QTextCodec::codecForName("utf8") );
2157 //os.setEncoding( QTextStream::UnicodeUTF8 ); 2161 //os.setEncoding( QTextStream::UnicodeUTF8 );
2158 if ( KOPrefs::instance()->mWriteBackFile ) { 2162 if ( KOPrefs::instance()->mWriteBackFile ) {
2159 os2 << "PUT\r\n"; 2163 os2 << "PUT\r\n";
2160 while ( ! ts2.atEnd() ) { 2164 while ( ! ts2.atEnd() ) {
2161 os2 << ts2.readLine() << "\n"; 2165 os2 << ts2.readLine() << "\n";
2162 } 2166 }
2163 } else { 2167 } else {
2164 os2 << "STOP\r\n"; 2168 os2 << "STOP\r\n";
2165 } 2169 }
2166 mCommandSocket->close(); 2170 mCommandSocketFinish->close();
2167 file.close(); 2171 file.close();
2168 delete mCommandSocket; 2172 //delete ( mCommandSocket);
2169 mCommandSocket = 0; 2173 //mCommandSocket = 0;
2170 qDebug("Syncing succesful! "); 2174 qDebug("Syncing succesful! ");
2171 setCaption( i18n("Easy-Pi-Sync succesful!") ); 2175 setCaption( i18n("Easy-Pi-Sync succesful!") );
2172 2176
2173 2177
2174} 2178}
2175 2179
2176void MainWindow::syncLocalFile() 2180void MainWindow::syncLocalFile()
2177{ 2181{
2178 2182
2179 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2183 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2180 2184
2181 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2185 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 9bb2302..5985d56 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -138,24 +138,25 @@ class MainWindow : public QMainWindow
138 void displayFile( QString, QString); 138 void displayFile( QString, QString);
139 139
140 void enableIncidenceActions( bool ); 140 void enableIncidenceActions( bool );
141 141
142 private slots: 142 private slots:
143 void fillSyncMenu(); 143 void fillSyncMenu();
144 void sendFile(QSocket* s); 144 void sendFile(QSocket* s);
145 void getFile(QSocket* socket); 145 void getFile(QSocket* socket);
146 void readFileFromSocket(); 146 void readFileFromSocket();
147 void endConnect(); 147 void endConnect();
148 private: 148 private:
149 QSocket* mCommandSocket; 149 QSocket* mCommandSocket;
150 QSocket* mCommandSocketFinish;
150 KServerSocket * mServerSocket; 151 KServerSocket * mServerSocket;
151 bool mClosed; 152 bool mClosed;
152 void saveOnClose(); 153 void saveOnClose();
153 int mCurrentSyncProfile; 154 int mCurrentSyncProfile;
154 void enableQuick(); 155 void enableQuick();
155 void performQuick(); 156 void performQuick();
156 void performQuickQuick(); 157 void performQuickQuick();
157 void syncRemote( KSyncProfile* , bool ask = true); 158 void syncRemote( KSyncProfile* , bool ask = true);
158 bool mFlagKeyPressed; 159 bool mFlagKeyPressed;
159 bool mBlockAtStartup; 160 bool mBlockAtStartup;
160 QPEToolBar *iconToolBar; 161 QPEToolBar *iconToolBar;
161 void initActions(); 162 void initActions();