summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-07 07:28:54 (UTC)
committer zautrix <zautrix>2004-10-07 07:28:54 (UTC)
commit77280f6a176a15b60004f312e6cacdfbbd3909c1 (patch) (unidiff)
treee074d4abedc2f4cc575e5655575e038b9d460106 /korganizer
parentf1eb5b74c962909851607c4b4cb05ee18a347d37 (diff)
downloadkdepimpi-77280f6a176a15b60004f312e6cacdfbbd3909c1.zip
kdepimpi-77280f6a176a15b60004f312e6cacdfbbd3909c1.tar.gz
kdepimpi-77280f6a176a15b60004f312e6cacdfbbd3909c1.tar.bz2
sync changes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koprefs.cpp2
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp321
-rw-r--r--korganizer/mainwindow.h70
4 files changed, 2 insertions, 394 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 84e3d00..1210094 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -163,66 +163,64 @@ KOPrefs::KOPrefs() :
163 163
164 164
165 KPrefs::setCurrentGroup("Calendar"); 165 KPrefs::setCurrentGroup("Calendar");
166 166
167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
168 168
169 KPrefs::setCurrentGroup("Fonts"); 169 KPrefs::setCurrentGroup("Fonts");
170 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 170 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
171 addItemFont("TimeBar Font",&mTimeBarFont); 171 addItemFont("TimeBar Font",&mTimeBarFont);
172 addItemFont("MonthView Font",&mMonthViewFont); 172 addItemFont("MonthView Font",&mMonthViewFont);
173 addItemFont("AgendaView Font",&mAgendaViewFont); 173 addItemFont("AgendaView Font",&mAgendaViewFont);
174 addItemFont("MarcusBains Font",&mMarcusBainsFont); 174 addItemFont("MarcusBains Font",&mMarcusBainsFont);
175 addItemFont("TimeLabels Font",&mTimeLabelsFont); 175 addItemFont("TimeLabels Font",&mTimeLabelsFont);
176 addItemFont("TodoView Font",&mTodoViewFont); 176 addItemFont("TodoView Font",&mTodoViewFont);
177 addItemFont("ListView Font",&mListViewFont); 177 addItemFont("ListView Font",&mListViewFont);
178 addItemFont("DateNavigator Font",&mDateNavigatorFont); 178 addItemFont("DateNavigator Font",&mDateNavigatorFont);
179 addItemFont("EditBox Font",&mEditBoxFont); 179 addItemFont("EditBox Font",&mEditBoxFont);
180 addItemFont("JournalView Font",&mJornalViewFont); 180 addItemFont("JournalView Font",&mJornalViewFont);
181 addItemFont("WhatsNextView Font",&mWhatsNextFont); 181 addItemFont("WhatsNextView Font",&mWhatsNextFont);
182 addItemFont("EventView Font",&mEventViewFont); 182 addItemFont("EventView Font",&mEventViewFont);
183 183
184// KPrefs::setCurrentGroup("SyncProfiles"); 184// KPrefs::setCurrentGroup("SyncProfiles");
185// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); 185// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
186// addItemStringList("SyncProfileNames",&mSyncProfileNames); 186// addItemStringList("SyncProfileNames",&mSyncProfileNames);
187// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); 187// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
188 188
189 KPrefs::setCurrentGroup("RemoteSyncing"); 189 KPrefs::setCurrentGroup("RemoteSyncing");
190// addItemBool("UsePasswd",&mUsePassWd,false); 190// addItemBool("UsePasswd",&mUsePassWd,false);
191// addItemBool("WriteBackFile",&mWriteBackFile,true); 191// addItemBool("WriteBackFile",&mWriteBackFile,true);
192// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); 192// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
193// addItemBool("AskForPreferences",&mAskForPreferences,true); 193// addItemBool("AskForPreferences",&mAskForPreferences,true);
194// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 194// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
195 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
196 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
197 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 195 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
198 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 196 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
199 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 197 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
200 addItemInt("LastSyncTime",&mLastSyncTime,0); 198 addItemInt("LastSyncTime",&mLastSyncTime,0);
201 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); 199 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
202 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 200 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
203 201
204#ifdef _WIN32_ 202#ifdef _WIN32_
205 QString hdp= locateLocal("data","korganizer")+"\\\\"; 203 QString hdp= locateLocal("data","korganizer")+"\\\\";
206#else 204#else
207 QString hdp= locateLocal("data","korganizer")+"/"; 205 QString hdp= locateLocal("data","korganizer")+"/";
208#endif 206#endif
209// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); 207// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
210// addItemString("RemoteUser",&mRemoteUser, "zaurus"); 208// addItemString("RemoteUser",&mRemoteUser, "zaurus");
211// addItemString("RemotePassWd",&mRemotePassWd, ""); 209// addItemString("RemotePassWd",&mRemotePassWd, "");
212// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); 210// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
213// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); 211// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
214 212
215 213
216 KPrefs::setCurrentGroup("LoadSaveFileNames"); 214 KPrefs::setCurrentGroup("LoadSaveFileNames");
217 215
218 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 216 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
219 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 217 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
220 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 218 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
221 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 219 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
222 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); 220 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
223 221
224 222
225 KPrefs::setCurrentGroup("Locale"); 223 KPrefs::setCurrentGroup("Locale");
226 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 224 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
227 addItemInt("PreferredTime",&mPreferredTime,0); 225 addItemInt("PreferredTime",&mPreferredTime,0);
228 addItemInt("PreferredDate",&mPreferredDate,0); 226 addItemInt("PreferredDate",&mPreferredDate,0);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index d9ac851..ff09e19 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -249,65 +249,64 @@ class KOPrefs : public KPimPrefs
249 int mDestination; 249 int mDestination;
250 250
251 251
252 bool mEditOnDoubleClick; 252 bool mEditOnDoubleClick;
253 bool mViewChangeHoldFullscreen; 253 bool mViewChangeHoldFullscreen;
254 bool mViewChangeHoldNonFullscreen; 254 bool mViewChangeHoldNonFullscreen;
255 bool mCenterOnCurrentTime; 255 bool mCenterOnCurrentTime;
256 bool mSetTimeToDayStartAt; 256 bool mSetTimeToDayStartAt;
257 bool mHighlightCurrentDay; 257 bool mHighlightCurrentDay;
258 bool mUseHighlightLightColor; 258 bool mUseHighlightLightColor;
259 bool mListViewMonthTimespan; 259 bool mListViewMonthTimespan;
260 bool mWNViewShowsParents; 260 bool mWNViewShowsParents;
261 bool mWNViewShowLocation; 261 bool mWNViewShowLocation;
262 bool mTodoViewShowsPercentage; 262 bool mTodoViewShowsPercentage;
263 bool mTodoViewUsesCatColors; 263 bool mTodoViewUsesCatColors;
264 bool mTodoViewUsesSmallFont; 264 bool mTodoViewUsesSmallFont;
265 bool mTodoViewUsesForegroundColor; 265 bool mTodoViewUsesForegroundColor;
266 bool mMonthViewUsesForegroundColor; 266 bool mMonthViewUsesForegroundColor;
267 267
268 bool mHightlightDateTimeEdit; 268 bool mHightlightDateTimeEdit;
269 bool mShortDateInViewer; 269 bool mShortDateInViewer;
270 270
271 QStringList mLocationDefaults; 271 QStringList mLocationDefaults;
272 QStringList mEventSummaryUser; 272 QStringList mEventSummaryUser;
273 QStringList mTodoSummaryUser; 273 QStringList mTodoSummaryUser;
274 274
275 bool mUseInternalAlarmNotification; 275 bool mUseInternalAlarmNotification;
276 int mAlarmPlayBeeps; 276 int mAlarmPlayBeeps;
277 int mAlarmSuspendTime; 277 int mAlarmSuspendTime;
278 int mAlarmSuspendCount; 278 int mAlarmSuspendCount;
279 int mAlarmBeepInterval; 279 int mAlarmBeepInterval;
280 280
281 QString mPassiveSyncPort; 281
282 QString mPassiveSyncPw;
283 QString mActiveSyncPort; 282 QString mActiveSyncPort;
284 QString mActiveSyncIP; 283 QString mActiveSyncIP;
285 284
286 285
287 //US I copied the following settings into KPimGlobalPrefs 286 //US I copied the following settings into KPimGlobalPrefs
288 // that allows us later to easily remove the settings from here. 287 // that allows us later to easily remove the settings from here.
289 int mPreferredDate; 288 int mPreferredDate;
290 QString mUserDateFormatLong; 289 QString mUserDateFormatLong;
291 QString mUserDateFormatShort; 290 QString mUserDateFormatShort;
292 int mPreferredLanguage; 291 int mPreferredLanguage;
293 int mPreferredTime; 292 int mPreferredTime;
294 bool mWeekStartsOnSunday; 293 bool mWeekStartsOnSunday;
295 QString mTimeZoneId; 294 QString mTimeZoneId;
296 bool mUseDaylightsaving; 295 bool mUseDaylightsaving;
297 int mDaylightsavingStart; 296 int mDaylightsavingStart;
298 int mDaylightsavingEnd; 297 int mDaylightsavingEnd;
299 298
300 299
301 private: 300 private:
302 QDict<QColor> mCategoryColors; 301 QDict<QColor> mCategoryColors;
303 QColor mDefaultCategoryColor; 302 QColor mDefaultCategoryColor;
304 303
305 QFont mDefaultTimeBarFont; 304 QFont mDefaultTimeBarFont;
306 QFont mDefaultViewFont; 305 QFont mDefaultViewFont;
307 QFont mDefaultMonthViewFont; 306 QFont mDefaultMonthViewFont;
308 307
309 QString mName; 308 QString mName;
310 QString mEmail; 309 QString mEmail;
311}; 310};
312 311
313#endif 312#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 9104347..e3324ee 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -101,65 +101,64 @@ class KOex2phonePrefs : public QDialog
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 mPassWordPiSync = "abc"; 129 mPassWordPiSync = "abc";
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mSyncActionDialog = 0;
134 mServerSocket = 0; 133 mServerSocket = 0;
135 mClosed = false; 134 mClosed = false;
136 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 135 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
137 QString confFile = locateLocal("config","korganizerrc"); 136 QString confFile = locateLocal("config","korganizerrc");
138 QFileInfo finf ( confFile ); 137 QFileInfo finf ( confFile );
139 bool showWarning = !finf.exists(); 138 bool showWarning = !finf.exists();
140 setIcon(SmallIcon( "ko24" ) ); 139 setIcon(SmallIcon( "ko24" ) );
141 mBlockAtStartup = true; 140 mBlockAtStartup = true;
142 mFlagKeyPressed = false; 141 mFlagKeyPressed = false;
143 setCaption("KOrganizer/Pi"); 142 setCaption("KOrganizer/Pi");
144 KOPrefs *p = KOPrefs::instance(); 143 KOPrefs *p = KOPrefs::instance();
145 KPimGlobalPrefs::instance()->setGlobalConfig(); 144 KPimGlobalPrefs::instance()->setGlobalConfig();
146 // if ( QApplication::desktop()->height() > 480 ) { 145 // if ( QApplication::desktop()->height() > 480 ) {
147// if ( p->mHourSize == 4 ) 146// if ( p->mHourSize == 4 )
148// p->mHourSize = 6; 147// p->mHourSize = 6;
149// } 148// }
150 if ( p->mHourSize > 18 ) 149 if ( p->mHourSize > 18 )
151 p->mHourSize = 18; 150 p->mHourSize = 18;
152 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
153 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
154 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
155 tbd = Bottom; 154 tbd = Bottom;
156 else 155 else
157 tbd = Top; 156 tbd = Top;
158 } 157 }
159 else { 158 else {
160 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
161 tbd = Right; 160 tbd = Right;
162 else 161 else
163 tbd = Left; 162 tbd = Left;
164 } 163 }
165 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
@@ -2318,352 +2317,32 @@ void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
2318 } 2317 }
2319 } 2318 }
2320 return; 2319 return;
2321} 2320}
2322 2321
2323void MainWindow::syncSharp() 2322void MainWindow::syncSharp()
2324{ 2323{
2325 if ( mCalendarModifiedFlag ) 2324 if ( mCalendarModifiedFlag )
2326 save(); 2325 save();
2327 mView->syncSharp(); 2326 mView->syncSharp();
2328 slotModifiedChanged( true ); 2327 slotModifiedChanged( true );
2329 2328
2330} 2329}
2331void MainWindow::syncPhone() 2330void MainWindow::syncPhone()
2332{ 2331{
2333 if ( mCalendarModifiedFlag ) 2332 if ( mCalendarModifiedFlag )
2334 save(); 2333 save();
2335 mView->syncPhone(); 2334 mView->syncPhone();
2336 slotModifiedChanged( true ); 2335 slotModifiedChanged( true );
2337 2336
2338} 2337}
2339 2338
2340void MainWindow::printSel( ) 2339void MainWindow::printSel( )
2341{ 2340{
2342 mView->viewManager()->agendaView()->agenda()->printSelection(); 2341 mView->viewManager()->agendaView()->agenda()->printSelection();
2343} 2342}
2344 2343
2345void MainWindow::printCal() 2344void MainWindow::printCal()
2346{ 2345{
2347 mView->print();//mCp->showDialog(); 2346 mView->print();//mCp->showDialog();
2348} 2347}
2349 2348
2350
2351
2352KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
2353{
2354 mPassWord = pw;
2355 mSocket = 0;
2356 mSyncActionDialog = 0;
2357 blockRC = false;
2358};
2359
2360void KServerSocket::newConnection ( int socket )
2361{
2362 // qDebug("KServerSocket:New connection %d ", socket);
2363 if ( mSocket ) {
2364 qDebug("KServerSocket::newConnection Socket deleted! ");
2365 delete mSocket;
2366 mSocket = 0;
2367 }
2368 mSocket = new QSocket( this );
2369 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2370 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2371 mSocket->setSocket( socket );
2372}
2373
2374void KServerSocket::discardClient()
2375{
2376 //qDebug(" KServerSocket::discardClient()");
2377 if ( mSocket ) {
2378 delete mSocket;
2379 mSocket = 0;
2380 }
2381 //emit endConnect();
2382}
2383void KServerSocket::readClient()
2384{
2385 if ( blockRC )
2386 return;
2387 if ( mSocket == 0 ) {
2388 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2389 return;
2390 }
2391 qDebug("KServerSocket readClient()");
2392 if ( mSocket->canReadLine() ) {
2393 QString line = mSocket->readLine();
2394 qDebug("KServerSocket readline: %s ", line.latin1());
2395 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
2396 if ( tokens[0] == "GET" ) {
2397 if ( tokens[1] == mPassWord )
2398 //emit sendFile( mSocket );
2399 send_file();
2400 else {
2401 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
2402 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2403 }
2404 }
2405 if ( tokens[0] == "PUT" ) {
2406 if ( tokens[1] == mPassWord ) {
2407 //emit getFile( mSocket );
2408 blockRC = true;
2409 get_file();
2410 }
2411 else {
2412 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
2413 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2414 }
2415 }
2416 if ( tokens[0] == "STOP" ) {
2417 //emit endConnect();
2418 end_connect();
2419 }
2420 }
2421}
2422void KServerSocket::end_connect()
2423{
2424 delete mSyncActionDialog;
2425 mSyncActionDialog = 0;
2426}
2427void KServerSocket::send_file()
2428{
2429 //qDebug("MainWindow::sendFile(QSocket* s) ");
2430 if ( mSyncActionDialog )
2431 delete mSyncActionDialog;
2432 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
2433 mSyncActionDialog->setCaption(i18n("Received sync request"));
2434 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
2435 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
2436 lay->addWidget( label);
2437 lay->setMargin(7);
2438 lay->setSpacing(7);
2439 mSyncActionDialog->setFixedSize( 230, 120);
2440 mSyncActionDialog->show();
2441 qDebug("KSS::saving ... ");
2442 emit saveFile();
2443 qApp->processEvents();
2444 QString fileName = mFileName;
2445 QFile file( fileName );
2446 if (!file.open( IO_ReadOnly ) ) {
2447 delete mSyncActionDialog;
2448 mSyncActionDialog = 0;
2449 qDebug("KSS::error open file ");
2450 mSocket->close();
2451 if ( mSocket->state() == QSocket::Idle )
2452 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2453 return ;
2454
2455 }
2456 mSyncActionDialog->setCaption( i18n("Sending file...") );
2457 QTextStream ts( &file );
2458 ts.setCodec( QTextCodec::codecForName("utf8") );
2459 QTextStream os( mSocket );
2460 os.setCodec( QTextCodec::codecForName("utf8") );
2461 //os.setEncoding( QTextStream::UnicodeUTF8 );
2462 while ( ! ts.atEnd() ) {
2463 os << ts.readLine() << "\n";
2464 }
2465 //os << ts.read();
2466 file.close();
2467 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
2468 mSocket->close();
2469 if ( mSocket->state() == QSocket::Idle )
2470 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2471}
2472void KServerSocket::get_file()
2473{
2474 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
2475
2476 piTime.start();
2477 piFileString = "";
2478 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
2479}
2480
2481
2482void KServerSocket::readBackFileFromSocket()
2483{
2484 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
2485 while ( mSocket->canReadLine () ) {
2486 piTime.restart();
2487 QString line = mSocket->readLine ();
2488 piFileString += line;
2489 //qDebug("readline: %s ", line.latin1());
2490 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
2491
2492 }
2493 if ( piTime.elapsed () < 3000 ) {
2494 // wait for more
2495 //qDebug("waitformore ");
2496 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
2497 return;
2498 }
2499 QString fileName = mFileName;
2500 QFile file ( fileName );
2501 if (!file.open( IO_WriteOnly ) ) {
2502 delete mSyncActionDialog;
2503 mSyncActionDialog = 0;
2504 qDebug("error open cal file ");
2505 piFileString = "";
2506 emit file_received( false );
2507 blockRC = false;
2508 return ;
2509
2510 }
2511
2512 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2513 QTextStream ts ( &file );
2514 ts.setCodec( QTextCodec::codecForName("utf8") );
2515 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
2516 ts << piFileString;
2517 mSocket->close();
2518 if ( mSocket->state() == QSocket::Idle )
2519 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2520 file.close();
2521 delete mSyncActionDialog;
2522 mSyncActionDialog = 0;
2523 piFileString = "";
2524 blockRC = false;
2525 emit file_received( true );
2526
2527}
2528
2529KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
2530{
2531 mPassWord = password;
2532 mSocket = 0;
2533 mPort = port;
2534 mHost = host;
2535
2536 mRetVal = quiet;
2537 mTimerSocket = new QTimer ( this );
2538 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
2539}
2540void KCommandSocket::readFile( QString fn )
2541{
2542 if ( !mSocket ) {
2543 mSocket = new QSocket( this );
2544 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
2545 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2546 }
2547 mFileString = "";
2548 mFileName = fn;
2549 mFirst = true;
2550 mSocket->connectToHost( mHost, mPort );
2551 QTextStream os( mSocket );
2552 os.setEncoding( QTextStream::UnicodeUTF8 );
2553 os << "GET " << mPassWord << "\r\n";
2554 mTimerSocket->start( 10000 );
2555}
2556
2557void KCommandSocket::writeFile( QString fileName )
2558{
2559 if ( !mSocket ) {
2560 mSocket = new QSocket( this );
2561 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2562 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
2563 }
2564 mFileName = fileName ;
2565 mSocket->connectToHost( mHost, mPort );
2566}
2567void KCommandSocket::writeFileToSocket()
2568{
2569 QFile file2( mFileName );
2570 if (!file2.open( IO_ReadOnly ) ) {
2571 mRetVal= errorW;
2572 mSocket->close();
2573 if ( mSocket->state() == QSocket::Idle )
2574 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2575 return ;
2576 }
2577 QTextStream ts2( &file2 );
2578 ts2.setCodec( QTextCodec::codecForName("utf8") );
2579 QTextStream os2( mSocket );
2580 os2.setCodec( QTextCodec::codecForName("utf8") );
2581 os2 << "PUT " << mPassWord << "\r\n";;
2582 while ( ! ts2.atEnd() ) {
2583 os2 << ts2.readLine() << "\n";
2584 }
2585 mRetVal= successW;
2586 file2.close();
2587 mSocket->close();
2588 if ( mSocket->state() == QSocket::Idle )
2589 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2590}
2591void KCommandSocket::sendStop()
2592{
2593 if ( !mSocket ) {
2594 mSocket = new QSocket( this );
2595 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2596 }
2597 mSocket->connectToHost( mHost, mPort );
2598 QTextStream os2( mSocket );
2599 os2.setCodec( QTextCodec::codecForName("utf8") );
2600 os2 << "STOP\r\n";
2601 mSocket->close();
2602 if ( mSocket->state() == QSocket::Idle )
2603 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2604}
2605
2606void KCommandSocket::startReadFileFromSocket()
2607{
2608 if ( ! mFirst )
2609 return;
2610 mFirst = false;
2611 mTimerSocket->stop();
2612 mFileString = "";
2613 mTime.start();
2614 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
2615
2616}
2617void KCommandSocket::readFileFromSocket()
2618{
2619 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
2620 while ( mSocket->canReadLine () ) {
2621 mTime.restart();
2622 QString line = mSocket->readLine ();
2623 mFileString += line;
2624 //qDebug("readline: %s ", line.latin1());
2625 }
2626 if ( mTime.elapsed () < 3000 ) {
2627 // wait for more
2628 //qDebug("waitformore ");
2629 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
2630 return;
2631 }
2632 QString fileName = mFileName;
2633 QFile file ( fileName );
2634 if (!file.open( IO_WriteOnly ) ) {
2635 mFileString = "";
2636 mRetVal = errorR;
2637 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2638 deleteSocket();
2639 return ;
2640
2641 }
2642 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2643 QTextStream ts ( &file );
2644 ts.setCodec( QTextCodec::codecForName("utf8") );
2645 ts << mFileString;
2646 file.close();
2647 mFileString = "";
2648 mRetVal = successR;
2649 mSocket->close();
2650 // if state is not idle, deleteSocket(); is called via
2651 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2652 if ( mSocket->state() == QSocket::Idle )
2653 deleteSocket();
2654}
2655
2656void KCommandSocket::deleteSocket()
2657{
2658 if ( mTimerSocket->isActive () ) {
2659 mTimerSocket->stop();
2660 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
2661 mRetVal = errorR;
2662 }
2663 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
2664 if ( mSocket)
2665 delete mSocket;
2666 mSocket = 0;
2667 emit commandFinished( this, mRetVal );
2668}
2669
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 4f89e03..0da0be0 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,123 +1,56 @@
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>
9#include <qtextstream.h> 8#include <qtextstream.h>
10#include <qregexp.h> 9#include <qregexp.h>
11 10
12#include <libkcal/incidence.h> 11#include <libkcal/incidence.h>
13#include "simplealarmclient.h" 12#include "simplealarmclient.h"
13#include <ksyncmanager.h>
14 14
15class QAction; 15class QAction;
16class CalendarView; 16class CalendarView;
17class KSyncProfile; 17class 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
23class QPEToolBar; 23class QPEToolBar;
24#include <qserversocket.h>
25#include <qsocket.h>
26#include <qnetworkprotocol.h>
27 24
28class KServerSocket : public QServerSocket
29{
30 Q_OBJECT
31
32public:
33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
34
35 void newConnection ( int socket ) ;
36 void setFileName( QString fn ) {mFileName = fn;};
37
38signals:
39 //void sendFile(QSocket*);
40 //void getFile(QSocket*);
41 void file_received( bool );
42 //void file_sent();
43 void saveFile();
44 void endConnect();
45private slots:
46 void discardClient();
47 void readClient();
48 void readBackFileFromSocket();
49 private :
50 bool blockRC;
51 void send_file();
52 void get_file();
53 void end_connect();
54 QDialog* mSyncActionDialog;
55 QSocket* mSocket;
56 QString mPassWord;
57 QString mFileName;
58 QTime piTime;
59 QString piFileString;
60};
61
62class KCommandSocket : public QObject
63{
64 Q_OBJECT
65public:
66 enum state { successR, errorR, successW, errorW, quiet };
67 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
68 void readFile( QString );
69 void writeFile( QString );
70 void sendStop();
71
72
73signals:
74 void commandFinished( KCommandSocket*, int );
75private slots:
76 void startReadFileFromSocket();
77 void readFileFromSocket();
78 void deleteSocket();
79 void writeFileToSocket();
80 private :
81 QSocket* mSocket;
82 QString mPassWord;
83 Q_UINT16 mPort;
84 QString mHost;
85 QString mFileName;
86 QTimer* mTimerSocket;
87 int mRetVal;
88 QTime mTime;
89 QString mFileString;
90 bool mFirst;
91};
92 25
93namespace KCal { 26namespace KCal {
94class CalendarLocal; 27class CalendarLocal;
95} 28}
96 29
97using namespace KCal; 30using namespace KCal;
98 31
99class MainWindow : public QMainWindow 32class MainWindow : public QMainWindow
100{ 33{
101 Q_OBJECT 34 Q_OBJECT
102 public: 35 public:
103 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 36 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
104 ~MainWindow(); 37 ~MainWindow();
105 public slots: 38 public slots:
106 virtual void showMaximized (); 39 virtual void showMaximized ();
107 void configureAgenda( int ); 40 void configureAgenda( int );
108 void recieve( const QCString& msg, const QByteArray& data ); 41 void recieve( const QCString& msg, const QByteArray& data );
109 static QString defaultFileName(); 42 static QString defaultFileName();
110 static QString syncFileName(); 43 static QString syncFileName();
111 static QString resourcePath(); 44 static QString resourcePath();
112 protected slots: 45 protected slots:
113 void setCaptionToDates(); 46 void setCaptionToDates();
114 int ringSync(); 47 int ringSync();
115 void multiSync( bool askforPrefs = false ); 48 void multiSync( bool askforPrefs = false );
116 void about(); 49 void about();
117 void licence(); 50 void licence();
118 void faq(); 51 void faq();
119 void usertrans(); 52 void usertrans();
120 void features(); 53 void features();
121 void synchowto(); 54 void synchowto();
122 void whatsNew(); 55 void whatsNew();
123 void keyBindings(); 56 void keyBindings();
@@ -180,37 +113,36 @@ class MainWindow : public QMainWindow
180 void enableQuick(); 113 void enableQuick();
181 void syncRemote( KSyncProfile* , bool ask = true); 114 void syncRemote( KSyncProfile* , bool ask = true);
182 bool mFlagKeyPressed; 115 bool mFlagKeyPressed;
183 bool mBlockAtStartup; 116 bool mBlockAtStartup;
184 QPEToolBar *iconToolBar; 117 QPEToolBar *iconToolBar;
185 void initActions(); 118 void initActions();
186 void setDefaultPreferences(); 119 void setDefaultPreferences();
187 void keyPressEvent ( QKeyEvent * ) ; 120 void keyPressEvent ( QKeyEvent * ) ;
188 void keyReleaseEvent ( QKeyEvent * ) ; 121 void keyReleaseEvent ( QKeyEvent * ) ;
189 QPopupMenu *configureToolBarMenu; 122 QPopupMenu *configureToolBarMenu;
190 QPopupMenu *selectFilterMenu; 123 QPopupMenu *selectFilterMenu;
191 QPopupMenu *configureAgendaMenu, *syncMenu; 124 QPopupMenu *configureAgendaMenu, *syncMenu;
192 CalendarLocal *mCalendar; 125 CalendarLocal *mCalendar;
193 CalendarView *mView; 126 CalendarView *mView;
194 QString getPassword(); 127 QString getPassword();
195 QAction *mNewSubTodoAction; 128 QAction *mNewSubTodoAction;
196 129
197 QAction *mShowAction; 130 QAction *mShowAction;
198 QAction *mEditAction; 131 QAction *mEditAction;
199 QAction *mDeleteAction; 132 QAction *mDeleteAction;
200 QAction *mCloneAction; 133 QAction *mCloneAction;
201 QAction *mMoveAction; 134 QAction *mMoveAction;
202 QAction *mBeamAction; 135 QAction *mBeamAction;
203 QAction *mCancelAction; 136 QAction *mCancelAction;
204 137
205 138
206 void closeEvent( QCloseEvent* ce ); 139 void closeEvent( QCloseEvent* ce );
207 SimpleAlarmClient mAlarmClient; 140 SimpleAlarmClient mAlarmClient;
208 QTimer mSaveTimer; 141 QTimer mSaveTimer;
209 bool mBlockSaveFlag; 142 bool mBlockSaveFlag;
210 bool mCalendarModifiedFlag; 143 bool mCalendarModifiedFlag;
211 QPixmap loadPixmap( QString ); 144 QPixmap loadPixmap( QString );
212 QDialog * mSyncActionDialog;
213}; 145};
214 146
215 147
216#endif 148#endif