summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koprefs.cpp5
-rw-r--r--korganizer/koprefs.h4
-rw-r--r--korganizer/mainwindow.cpp317
-rw-r--r--korganizer/mainwindow.h65
4 files changed, 386 insertions, 5 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 5d7db4f..0034715 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -168,49 +168,52 @@ KOPrefs::KOPrefs() :
168 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 168 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
169 addItemFont("TimeBar Font",&mTimeBarFont); 169 addItemFont("TimeBar Font",&mTimeBarFont);
170 addItemFont("MonthView Font",&mMonthViewFont); 170 addItemFont("MonthView Font",&mMonthViewFont);
171 addItemFont("AgendaView Font",&mAgendaViewFont); 171 addItemFont("AgendaView Font",&mAgendaViewFont);
172 addItemFont("MarcusBains Font",&mMarcusBainsFont); 172 addItemFont("MarcusBains Font",&mMarcusBainsFont);
173 addItemFont("TimeLabels Font",&mTimeLabelsFont); 173 addItemFont("TimeLabels Font",&mTimeLabelsFont);
174 addItemFont("TodoView Font",&mTodoViewFont); 174 addItemFont("TodoView Font",&mTodoViewFont);
175 addItemFont("ListView Font",&mListViewFont); 175 addItemFont("ListView Font",&mListViewFont);
176 addItemFont("DateNavigator Font",&mDateNavigatorFont); 176 addItemFont("DateNavigator Font",&mDateNavigatorFont);
177 addItemFont("EditBox Font",&mEditBoxFont); 177 addItemFont("EditBox Font",&mEditBoxFont);
178 addItemFont("JournalView Font",&mJornalViewFont); 178 addItemFont("JournalView Font",&mJornalViewFont);
179 addItemFont("WhatsNextView Font",&mWhatsNextFont); 179 addItemFont("WhatsNextView Font",&mWhatsNextFont);
180 addItemFont("EventView Font",&mEventViewFont); 180 addItemFont("EventView Font",&mEventViewFont);
181 181
182// KPrefs::setCurrentGroup("SyncProfiles"); 182// KPrefs::setCurrentGroup("SyncProfiles");
183// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); 183// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
184// addItemStringList("SyncProfileNames",&mSyncProfileNames); 184// addItemStringList("SyncProfileNames",&mSyncProfileNames);
185// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); 185// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
186 186
187 KPrefs::setCurrentGroup("RemoteSyncing"); 187 KPrefs::setCurrentGroup("RemoteSyncing");
188// addItemBool("UsePasswd",&mUsePassWd,false); 188// addItemBool("UsePasswd",&mUsePassWd,false);
189// addItemBool("WriteBackFile",&mWriteBackFile,true); 189// addItemBool("WriteBackFile",&mWriteBackFile,true);
190// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); 190// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
191// addItemBool("AskForPreferences",&mAskForPreferences,true); 191// addItemBool("AskForPreferences",&mAskForPreferences,true);
192// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 192// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
193 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
194 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
195 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
193 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 196 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
194 addItemInt("LastSyncTime",&mLastSyncTime,0); 197 addItemInt("LastSyncTime",&mLastSyncTime,0);
195 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); 198 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
196 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 199 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
197 200
198#ifdef _WIN32_ 201#ifdef _WIN32_
199 QString hdp= locateLocal("data","korganizer")+"\\\\"; 202 QString hdp= locateLocal("data","korganizer")+"\\\\";
200#else 203#else
201 QString hdp= locateLocal("data","korganizer")+"/"; 204 QString hdp= locateLocal("data","korganizer")+"/";
202#endif 205#endif
203// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); 206// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
204// addItemString("RemoteUser",&mRemoteUser, "zaurus"); 207// addItemString("RemoteUser",&mRemoteUser, "zaurus");
205// addItemString("RemotePassWd",&mRemotePassWd, ""); 208// addItemString("RemotePassWd",&mRemotePassWd, "");
206// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); 209// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
207// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); 210// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
208 211
209 212
210 KPrefs::setCurrentGroup("LoadSaveFileNames"); 213 KPrefs::setCurrentGroup("LoadSaveFileNames");
211 214
212 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 215 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
213 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 216 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
214 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 217 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
215 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 218 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
216 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); 219 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 33eda60..696433e 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -258,48 +258,52 @@ class KOPrefs : public KPimPrefs
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 mUseQuicksave; 269 bool mUseQuicksave;
270 bool mShortDateInViewer; 270 bool mShortDateInViewer;
271 271
272 QStringList mLocationDefaults; 272 QStringList mLocationDefaults;
273 QStringList mEventSummaryUser; 273 QStringList mEventSummaryUser;
274 QStringList mTodoSummaryUser; 274 QStringList mTodoSummaryUser;
275 275
276 bool mUseInternalAlarmNotification; 276 bool mUseInternalAlarmNotification;
277 int mAlarmPlayBeeps; 277 int mAlarmPlayBeeps;
278 int mAlarmSuspendTime; 278 int mAlarmSuspendTime;
279 int mAlarmSuspendCount; 279 int mAlarmSuspendCount;
280 int mAlarmBeepInterval; 280 int mAlarmBeepInterval;
281 281
282 QString mPassiveSyncPort;
283 QString mActiveSyncPort;
284 QString mActiveSyncIP;
285
282 286
283 //US I copied the following settings into KPimGlobalPrefs 287 //US I copied the following settings into KPimGlobalPrefs
284 // that allows us later to easily remove the settings from here. 288 // that allows us later to easily remove the settings from here.
285 int mPreferredDate; 289 int mPreferredDate;
286 QString mUserDateFormatLong; 290 QString mUserDateFormatLong;
287 QString mUserDateFormatShort; 291 QString mUserDateFormatShort;
288 int mPreferredLanguage; 292 int mPreferredLanguage;
289 int mPreferredTime; 293 int mPreferredTime;
290 bool mWeekStartsOnSunday; 294 bool mWeekStartsOnSunday;
291 QString mTimeZoneId; 295 QString mTimeZoneId;
292 bool mUseDaylightsaving; 296 bool mUseDaylightsaving;
293 int mDaylightsavingStart; 297 int mDaylightsavingStart;
294 int mDaylightsavingEnd; 298 int mDaylightsavingEnd;
295 299
296 300
297 private: 301 private:
298 QDict<QColor> mCategoryColors; 302 QDict<QColor> mCategoryColors;
299 QColor mDefaultCategoryColor; 303 QColor mDefaultCategoryColor;
300 304
301 QFont mDefaultTimeBarFont; 305 QFont mDefaultTimeBarFont;
302 QFont mDefaultViewFont; 306 QFont mDefaultViewFont;
303 QFont mDefaultMonthViewFont; 307 QFont mDefaultMonthViewFont;
304 308
305 QString mName; 309 QString mName;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 6315c64..f2e1bf8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,32 +1,33 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qtextcodec.h>
9#include <qfile.h> 10#include <qfile.h>
10#include <qdir.h> 11#include <qdir.h>
11#include <qapp.h> 12#include <qapp.h>
12#include <qfileinfo.h> 13#include <qfileinfo.h>
13#include <qlabel.h> 14#include <qlabel.h>
14#include <qmap.h> 15#include <qmap.h>
15#include <qwmatrix.h> 16#include <qwmatrix.h>
16#include <qtextbrowser.h> 17#include <qtextbrowser.h>
17#include <qtextstream.h> 18#include <qtextstream.h>
18#ifndef DESKTOP_VERSION 19#ifndef DESKTOP_VERSION
19#include <qpe/global.h> 20#include <qpe/global.h>
20#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
21#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
22#include <qpe/resource.h> 23#include <qpe/resource.h>
23#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
24#include <qtopia/alarmserver.h> 25#include <qtopia/alarmserver.h>
25#include <qtopia/qcopenvelope_qws.h> 26#include <qtopia/qcopenvelope_qws.h>
26#else 27#else
27#include <qmenubar.h> 28#include <qmenubar.h>
28#include <qtoolbar.h> 29#include <qtoolbar.h>
29#include <qapplication.h> 30#include <qapplication.h>
30//#include <resource.h> 31//#include <resource.h>
31 32
32#endif 33#endif
@@ -50,49 +51,51 @@
50#include "kfiledialog.h" 51#include "kfiledialog.h"
51#include "koglobals.h" 52#include "koglobals.h"
52#include "kglobal.h" 53#include "kglobal.h"
53#include "klocale.h" 54#include "klocale.h"
54#include "kconfig.h" 55#include "kconfig.h"
55#include "simplealarmclient.h" 56#include "simplealarmclient.h"
56#include "externalapphandler.h" 57#include "externalapphandler.h"
57 58
58using namespace KCal; 59using namespace KCal;
59#ifndef _WIN32_ 60#ifndef _WIN32_
60#include <unistd.h> 61#include <unistd.h>
61#else 62#else
62#include "koimportoldialog.h" 63#include "koimportoldialog.h"
63#endif 64#endif
64#include "mainwindow.h" 65#include "mainwindow.h"
65 66
66int globalFlagBlockStartup; 67int globalFlagBlockStartup;
67MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 68MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
68 QMainWindow( parent, name ) 69 QMainWindow( parent, name )
69{ 70{
70 71
71#ifdef DESKTOP_VERSION 72#ifdef DESKTOP_VERSION
72 setFont( QFont("Arial"), 14 ); 73 setFont( QFont("Arial"), 14 );
73#endif 74#endif
74 75 mCommandSocket = 0;
76 mSyncActionDialog = 0;
77 mServerSocket = 0;
75 mClosed = false; 78 mClosed = false;
76 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 79 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
77 QString confFile = locateLocal("config","korganizerrc"); 80 QString confFile = locateLocal("config","korganizerrc");
78 QFileInfo finf ( confFile ); 81 QFileInfo finf ( confFile );
79 bool showWarning = !finf.exists(); 82 bool showWarning = !finf.exists();
80 setIcon(SmallIcon( "ko24" ) ); 83 setIcon(SmallIcon( "ko24" ) );
81 mBlockAtStartup = true; 84 mBlockAtStartup = true;
82 mFlagKeyPressed = false; 85 mFlagKeyPressed = false;
83 setCaption("KOrganizer/Pi"); 86 setCaption("KOrganizer/Pi");
84 KOPrefs *p = KOPrefs::instance(); 87 KOPrefs *p = KOPrefs::instance();
85 KPimGlobalPrefs::instance()->setGlobalConfig(); 88 KPimGlobalPrefs::instance()->setGlobalConfig();
86 // if ( QApplication::desktop()->height() > 480 ) { 89 // if ( QApplication::desktop()->height() > 480 ) {
87// if ( p->mHourSize == 4 ) 90// if ( p->mHourSize == 4 )
88// p->mHourSize = 6; 91// p->mHourSize = 6;
89// } 92// }
90 if ( p->mHourSize > 18 ) 93 if ( p->mHourSize > 18 )
91 p->mHourSize = 18; 94 p->mHourSize = 18;
92 QMainWindow::ToolBarDock tbd; 95 QMainWindow::ToolBarDock tbd;
93 if ( p->mToolBarHor ) { 96 if ( p->mToolBarHor ) {
94 if ( p->mToolBarUp ) 97 if ( p->mToolBarUp )
95 tbd = Bottom; 98 tbd = Bottom;
96 else 99 else
97 tbd = Top; 100 tbd = Top;
98 } 101 }
@@ -192,49 +195,49 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
192 mView->show(); 195 mView->show();
193 delete splash; 196 delete splash;
194 if ( newFile ) 197 if ( newFile )
195 mView->updateConfig(); 198 mView->updateConfig();
196 // qApp->processEvents(); 199 // qApp->processEvents();
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 fillSyncMenu(); 201 fillSyncMenu();
199 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 202 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
200 if ( showWarning ) { 203 if ( showWarning ) {
201 KMessageBox::information( this, 204 KMessageBox::information( this,
202 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 205 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
203 qApp->processEvents(); 206 qApp->processEvents();
204 mView->dialogManager()->showSyncOptions(); 207 mView->dialogManager()->showSyncOptions();
205 } 208 }
206 209
207 //US listen for result adressed from Ka/Pi 210 //US listen for result adressed from Ka/Pi
208#ifndef DESKTOP_VERSION 211#ifndef DESKTOP_VERSION
209 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 212 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
210#endif 213#endif
211} 214}
212MainWindow::~MainWindow() 215MainWindow::~MainWindow()
213{ 216{
214 //qDebug("MainWindow::~MainWindow() "); 217 //qDebug("MainWindow::~MainWindow() ");
215 //save toolbar location 218 //save toolbar location
216 219 delete mServerSocket;
217 delete mCalendar; 220 delete mCalendar;
218 delete KOPrefs::instance(); 221 delete KOPrefs::instance();
219 delete KIncidenceFormatter::instance(); 222 delete KIncidenceFormatter::instance();
220 223
221 224
222} 225}
223void MainWindow::showMaximized () 226void MainWindow::showMaximized ()
224{ 227{
225#ifndef DESKTOP_VERSION 228#ifndef DESKTOP_VERSION
226 if ( ! globalFlagBlockStartup ) 229 if ( ! globalFlagBlockStartup )
227 if ( mClosed ) 230 if ( mClosed )
228 mView->goToday(); 231 mView->goToday();
229#endif 232#endif
230 QWidget::showMaximized () ; 233 QWidget::showMaximized () ;
231 mClosed = false; 234 mClosed = false;
232} 235}
233void MainWindow::closeEvent( QCloseEvent* ce ) 236void MainWindow::closeEvent( QCloseEvent* ce )
234{ 237{
235 238
236 239
237 240
238 if ( ! KOPrefs::instance()->mAskForQuit ) { 241 if ( ! KOPrefs::instance()->mAskForQuit ) {
239 saveOnClose(); 242 saveOnClose();
240 mClosed = true; 243 mClosed = true;
@@ -841,48 +844,57 @@ void MainWindow::initActions()
841 configureToolBarMenu->setItemChecked( 110, true ); 844 configureToolBarMenu->setItemChecked( 110, true );
842 if (p-> mShowIconJournal) 845 if (p-> mShowIconJournal)
843 configureToolBarMenu->setItemChecked( 90, true ); 846 configureToolBarMenu->setItemChecked( 90, true );
844 if (p-> mShowIconWhatsThis) 847 if (p-> mShowIconWhatsThis)
845 configureToolBarMenu->setItemChecked( 300, true ); 848 configureToolBarMenu->setItemChecked( 300, true );
846 849
847 QLabel* dummy = new QLabel( iconToolBar ); 850 QLabel* dummy = new QLabel( iconToolBar );
848 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 851 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
849 if (!p-> mShowIconStretch) 852 if (!p-> mShowIconStretch)
850 iconToolBar->setStretchableWidget ( dummy ) ; 853 iconToolBar->setStretchableWidget ( dummy ) ;
851 else 854 else
852 configureToolBarMenu->setItemChecked( 5, true ); 855 configureToolBarMenu->setItemChecked( 5, true );
853 if (p-> mShowIconWhatsThis) 856 if (p-> mShowIconWhatsThis)
854 QWhatsThis::whatsThisButton ( iconToolBar ); 857 QWhatsThis::whatsThisButton ( iconToolBar );
855 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 858 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
856 configureAgenda( p->mHourSize ); 859 configureAgenda( p->mHourSize );
857 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 860 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
858} 861}
859void MainWindow::fillSyncMenu() 862void MainWindow::fillSyncMenu()
860{ 863{
861 if ( syncMenu->count() ) 864 if ( syncMenu->count() )
862 syncMenu->clear(); 865 syncMenu->clear();
863 syncMenu->insertItem( i18n("Configure..."), 0 ); 866 syncMenu->insertItem( i18n("Configure..."), 0 );
864 syncMenu->insertSeparator(); 867 syncMenu->insertSeparator();
868 if ( mServerSocket == 0 ) {
869 syncMenu->insertItem( i18n("Enable Easy-Pi-Sync"), 2 );
870 } else {
871 syncMenu->insertItem( i18n("Disable Easy-Pi-Sync"), 3 );
872 }
873 syncMenu->insertSeparator();
874 syncMenu->insertItem( i18n("New Easy-Pi-Sync!"), 4 );
875 syncMenu->insertItem( i18n("Quick Easy-Pi-Sync!"), 5 );
876 syncMenu->insertSeparator();
865 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 877 syncMenu->insertItem( i18n("Multiple sync"), 1 );
866 syncMenu->insertSeparator(); 878 syncMenu->insertSeparator();
867 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 879 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
868 config.setGroup("General"); 880 config.setGroup("General");
869 QStringList prof = config.readListEntry("SyncProfileNames"); 881 QStringList prof = config.readListEntry("SyncProfileNames");
870 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 882 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
871 if ( prof.count() < 3 ) { 883 if ( prof.count() < 3 ) {
872 prof.clear(); 884 prof.clear();
873 prof << i18n("Sharp_DTM"); 885 prof << i18n("Sharp_DTM");
874 prof << i18n("Local_file"); 886 prof << i18n("Local_file");
875 prof << i18n("Last_file"); 887 prof << i18n("Last_file");
876 KSyncProfile* temp = new KSyncProfile (); 888 KSyncProfile* temp = new KSyncProfile ();
877 temp->setName( prof[0] ); 889 temp->setName( prof[0] );
878 temp->writeConfig(&config); 890 temp->writeConfig(&config);
879 temp->setName( prof[1] ); 891 temp->setName( prof[1] );
880 temp->writeConfig(&config); 892 temp->writeConfig(&config);
881 temp->setName( prof[2] ); 893 temp->setName( prof[2] );
882 temp->writeConfig(&config); 894 temp->writeConfig(&config);
883 config.setGroup("General"); 895 config.setGroup("General");
884 config.writeEntry("SyncProfileNames",prof); 896 config.writeEntry("SyncProfileNames",prof);
885 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 897 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
886 config.sync(); 898 config.sync();
887 delete temp; 899 delete temp;
888 } 900 }
@@ -975,64 +987,83 @@ void MainWindow::multiSync( bool askforPrefs )
975 return; 987 return;
976 } 988 }
977 mView->setSyncDevice(i18n("Multiple profiles") ); 989 mView->setSyncDevice(i18n("Multiple profiles") );
978 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 990 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
979 if ( askforPrefs ) { 991 if ( askforPrefs ) {
980 mView->edit_sync_options(); 992 mView->edit_sync_options();
981 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 993 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
982 } 994 }
983 setCaption(i18n("Multiple sync started.") ); 995 setCaption(i18n("Multiple sync started.") );
984 qApp->processEvents(); 996 qApp->processEvents();
985 int num = ringSync() ; 997 int num = ringSync() ;
986 if ( num > 1 ) 998 if ( num > 1 )
987 ringSync(); 999 ringSync();
988 mBlockSaveFlag = false; 1000 mBlockSaveFlag = false;
989 if ( num ) 1001 if ( num )
990 save(); 1002 save();
991 if ( num ) 1003 if ( num )
992 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1004 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
993 else 1005 else
994 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1006 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
995 return; 1007 return;
996} 1008}
997void MainWindow::slotSyncMenu( int action ) 1009void MainWindow::slotSyncMenu( int action )
998{ 1010{
999 //qDebug("syncaction %d ", action); 1011 qDebug("syncaction %d ", action);
1000 if ( action == 0 ) { 1012 if ( action == 0 ) {
1001 1013
1002 // seems to be a Qt2 event handling bug 1014 // seems to be a Qt2 event handling bug
1003 // syncmenu.clear causes a segfault at first time 1015 // syncmenu.clear causes a segfault at first time
1004 // when we call it after the main event loop, it is ok 1016 // when we call it after the main event loop, it is ok
1005 // same behaviour when calling OM/Pi via QCOP for the first time 1017 // same behaviour when calling OM/Pi via QCOP for the first time
1006 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1018 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1007 //confSync(); 1019 //confSync();
1008 1020
1009 return; 1021 return;
1010 } 1022 }
1011 if ( action == 1 ) { 1023 if ( action == 1 ) {
1012 multiSync( true ); 1024 multiSync( true );
1013 return; 1025 return;
1014 } 1026 }
1027 if ( action == 2 ) {
1028 enableQuick();
1029 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1030 return;
1031 }
1032 if ( action == 3 ) {
1033 delete mServerSocket;
1034 mServerSocket = 0;
1035 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1036 return;
1037 }
1038 if ( action == 4 ) {
1039 performQuick();
1040 return;
1041 }
1042 if ( action == 5 ) {
1043 performQuickQuick();
1044 return;
1045 }
1015 1046
1016 if (mBlockSaveFlag) 1047 if (mBlockSaveFlag)
1017 return; 1048 return;
1018 mBlockSaveFlag = true; 1049 mBlockSaveFlag = true;
1019 mCurrentSyncProfile = action - 1000 ; 1050 mCurrentSyncProfile = action - 1000 ;
1020 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1051 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1021 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1052 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1022 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1053 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1023 KSyncProfile* temp = new KSyncProfile (); 1054 KSyncProfile* temp = new KSyncProfile ();
1024 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1055 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1025 temp->readConfig(&config); 1056 temp->readConfig(&config);
1026 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1057 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1027 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1058 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1028 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1059 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1029 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1060 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1030 KOPrefs::instance()->mWriteBackInFuture = 0; 1061 KOPrefs::instance()->mWriteBackInFuture = 0;
1031 if ( temp->getWriteBackFuture() ) 1062 if ( temp->getWriteBackFuture() )
1032 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1063 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1033 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1064 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1034 if ( action == 1000 ) { 1065 if ( action == 1000 ) {
1035 syncSharp(); 1066 syncSharp();
1036 1067
1037 } else if ( action == 1001 ) { 1068 } else if ( action == 1001 ) {
1038 syncLocalFile(); 1069 syncLocalFile();
@@ -1839,48 +1870,328 @@ QString MainWindow::getPassword( )
1839{ 1870{
1840 QString retfile = ""; 1871 QString retfile = "";
1841 QDialog dia ( this, "input-dialog", true ); 1872 QDialog dia ( this, "input-dialog", true );
1842 QLineEdit lab ( &dia ); 1873 QLineEdit lab ( &dia );
1843 lab.setEchoMode( QLineEdit::Password ); 1874 lab.setEchoMode( QLineEdit::Password );
1844 QVBoxLayout lay( &dia ); 1875 QVBoxLayout lay( &dia );
1845 lay.setMargin(7); 1876 lay.setMargin(7);
1846 lay.setSpacing(7); 1877 lay.setSpacing(7);
1847 lay.addWidget( &lab); 1878 lay.addWidget( &lab);
1848 dia.setFixedSize( 230,50 ); 1879 dia.setFixedSize( 230,50 );
1849 dia.setCaption( i18n("Enter password") ); 1880 dia.setCaption( i18n("Enter password") );
1850 QPushButton pb ( "OK", &dia); 1881 QPushButton pb ( "OK", &dia);
1851 lay.addWidget( &pb ); 1882 lay.addWidget( &pb );
1852 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1883 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1853 dia.show(); 1884 dia.show();
1854 int res = dia.exec(); 1885 int res = dia.exec();
1855 if ( res ) 1886 if ( res )
1856 retfile = lab.text(); 1887 retfile = lab.text();
1857 dia.hide(); 1888 dia.hide();
1858 qApp->processEvents(); 1889 qApp->processEvents();
1859 return retfile; 1890 return retfile;
1860 1891
1861} 1892}
1862 1893
1894void MainWindow::enableQuick()
1895{
1896 QString retfile = "";
1897 QDialog dia ( this, "input-dialog", true );
1898 QLineEdit lab ( &dia );
1899 QVBoxLayout lay( &dia );
1900 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
1901 lay.setMargin(7);
1902 lay.setSpacing(7);
1903 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
1904 lay.addWidget( &label);
1905 lay.addWidget( &lab);
1906 dia.setFixedSize( 230,80 );
1907 dia.setCaption( i18n("Enter port for Easy-Pi-Sync") );
1908 QPushButton pb ( "OK", &dia);
1909 lay.addWidget( &pb );
1910 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1911 dia.show();
1912 int res = dia.exec();
1913 if ( res )
1914 retfile = lab.text();
1915 else
1916 return;
1917 dia.hide();
1918 qApp->processEvents();
1919 KOPrefs::instance()->mPassiveSyncPort = retfile;
1920 bool ok;
1921 Q_UINT16 port = retfile.toUInt(&ok);
1922 if ( ! ok ) {
1923 qDebug("no valid port ");
1924 return;
1925 }
1926 qDebug("port %d ", port);
1927 mServerSocket = new KServerSocket ( port ,1 );
1928 qDebug("connected ");
1929 if ( !mServerSocket->ok() ) {
1930 qWarning("Failed to bind to port %d", port);
1931 delete mServerSocket;
1932 mServerSocket = 0;
1933 return;
1934 }
1935 connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) );
1936 connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) );
1937}
1938void MainWindow::sendFile(QSocket* socket)
1939{
1940 setCaption( i18n("Received request for file") );
1941 qDebug("MainWindow::sendFile(QSocket* s) ");
1942 mSyncActionDialog = new QDialog ( this, "input-dialog", true );
1943 mSyncActionDialog->setCaption(i18n("KO/Pi - WARNING"));
1944 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use\nthis application!\n"), mSyncActionDialog );
1945 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1946 lay->addWidget( label);
1947 lay->setMargin(7);
1948 lay->setSpacing(7);
1949 mSyncActionDialog->setFixedSize( 200,100 );
1950 mSyncActionDialog->show();
1951 qApp->processEvents();
1952 qDebug("saving ... ");
1953 save();
1954 QString fileName = defaultFileName();
1955 QFile file( fileName );
1956 if (!file.open( IO_ReadOnly ) ) {
1957 setCaption( i18n("Error open file") );
1958 delete mSyncActionDialog;
1959 mSyncActionDialog = 0;
1960 qDebug("error open cal file ");
1961 return ;
1962
1963 }
1964 setCaption( i18n("Sending file...") );
1965 QTextStream ts( &file );
1966 ts.setCodec( QTextCodec::codecForName("utf8") );
1967 QTextStream os( socket );
1968 os.setCodec( QTextCodec::codecForName("utf8") );
1969 //os.setEncoding( QTextStream::UnicodeUTF8 );
1970 while ( ! ts.atEnd() ) {
1971 os << ts.readLine() << "\n";
1972 }
1973 //os << ts.read();
1974 socket->close();
1975 file.close();
1976 setCaption( i18n("File sent. Waiting to get back synced file") );
1977 qDebug("file sent ");
1978}
1979void MainWindow::getFile(QSocket* socket)
1980{
1981 setCaption( i18n("Receiving synced file...") );
1982 qDebug("MainWindow::sendFile(QSocket* s) ");
1983
1984 QString fileName = defaultFileName();
1985 QFile file( fileName );
1986 if (!file.open( IO_WriteOnly ) ) {
1987 setCaption( i18n("Error open file") );
1988 delete mSyncActionDialog;
1989 mSyncActionDialog = 0;
1990 qDebug("error open cal file ");
1991 return ;
1992
1993 }
1994
1995 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1996 QTextStream ts( &file );
1997 ts.setCodec( QTextCodec::codecForName("utf8") );
1998 bool first = true;
1999 while ( socket->canReadLine () || first ) {
2000 first = false;
2001 while ( socket->canReadLine () ) {
2002 ts << socket->readLine ();
2003 }
2004 socket->waitForMore ( 5000 );
2005 }
2006 setCaption( i18n("File received - reloading calendar...") );
2007 file.close();
2008 socket->close();
2009 mView->watchSavedFile();
2010 mView->openCalendar( defaultFileName() );
2011 setCaption( i18n("Easy-Pi-Sync successful!") );
2012 delete mSyncActionDialog;
2013 mSyncActionDialog = 0;
2014
2015
2016}
2017void MainWindow::endConnect()
2018{
2019 setCaption( i18n("No file received - syncing successful") );
2020 delete mSyncActionDialog;
2021 mSyncActionDialog = 0;
2022}
2023void MainWindow::performQuick()
2024{
2025 setCaption( i18n("Please input connection settings") );
2026 QString retfile = "";
2027 QDialog dia ( this, "input-dialog", true );
2028 QLineEdit lab ( &dia );
2029 QVBoxLayout lay( &dia );
2030 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia );
2031 lay.addWidget( &label);
2032 lab.setText( KOPrefs::instance()->mActiveSyncIP );
2033 lay.setMargin(7);
2034 lay.setSpacing(7);
2035 lay.addWidget( &lab);
2036 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia );
2037 lay.addWidget( &label2);
2038 QLineEdit lab2 ( &dia );
2039 lab2.setText( KOPrefs::instance()->mActiveSyncPort );
2040 lay.addWidget( &lab2);
2041 dia.setFixedSize( 230,200 );
2042 dia.setCaption( i18n("Enter port for Easy-Pi-Sync ") );
2043 QPushButton pb ( "OK", &dia);
2044 lay.addWidget( &pb );
2045 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2046 dia.show();
2047 int res = dia.exec();
2048 if ( !res ) {
2049 setCaption( i18n("Syncing cancelled!") );
2050 return;
2051 }
2052 dia.hide();
2053 KOPrefs::instance()->mActiveSyncPort = lab2.text();
2054 KOPrefs::instance()->mActiveSyncIP = lab.text();
2055 qApp->processEvents();
2056 performQuickQuick();
2057}
2058
2059void MainWindow::performQuickQuick()
2060{
2061 // setCaption( i18n("") );
2062
2063 bool ok;
2064 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2065 if ( ! ok ) {
2066 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2067 return;
2068 }
2069 if ( mCommandSocket )
2070 delete mCommandSocket;
2071 mCommandSocket = new QSocket( this );
2072 connect( mCommandSocket, SIGNAL(readyRead()), this, SLOT(readFileFromSocket()) );
2073 QString host = KOPrefs::instance()->mActiveSyncIP;
2074 mCommandSocket->connectToHost( host, port );
2075 QTextStream os( mCommandSocket );
2076 os.setEncoding( QTextStream::UnicodeUTF8 );
2077 os << "GET\r\n";
2078 setCaption( i18n("Sending request for remote file ...") );
2079
2080}
2081void MainWindow::readFileFromSocket()
2082{
2083 setCaption( i18n("Receiving remote file ...") );
2084 qDebug("MainWindow::readFileFromSocket() ");
2085QString fileName;
2086#ifdef _WIN32_
2087 fileName = defaultFileName() +"sync";
2088#else
2089 fileName = "/tmp/kopitempfile.ics";
2090#endif
2091 QFile file( fileName );
2092 if (!file.open( IO_WriteOnly ) ) {
2093 setCaption( i18n("Error: Cannot open temp file for write.") );
2094 qDebug("Error open calender file for writing: %s",fileName.latin1() );
2095 return ;
2096 }
2097
2098 //QTextStream os2( mCommandSocket );
2099 //os2.setEncoding( QTextStream::UnicodeUTF8 );
2100
2101 QTextStream ts( &file );
2102 ts.setCodec( QTextCodec::codecForName("utf8") );
2103 bool first = true;
2104 while ( mCommandSocket->canReadLine () || first) {
2105 first = false;
2106 while ( mCommandSocket->canReadLine () ) {
2107 ts << mCommandSocket->readLine ();
2108 }
2109 mCommandSocket->waitForMore ( 5000 );
2110 }
2111 file.close();
2112 mCommandSocket->close();
2113 delete mCommandSocket;
2114 setCaption( i18n("Remote file saved to temp file.") );
2115 mCommandSocket = 0;
2116 mCurrentSyncProfile = 2 ; // last file
2117 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
2118 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
2119 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2120 KSyncProfile* temp = new KSyncProfile ();
2121 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2122 temp->readConfig(&config);
2123 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2124 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2125 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2126 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2127 KOPrefs::instance()->mWriteBackInFuture = 0;
2128 if ( temp->getWriteBackFuture() )
2129 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2130 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2131
2132 setCaption( i18n("Remote file saved to temp file.") );
2133 if ( ! syncWithFile( fileName , true ) ) {
2134 setCaption( i18n("Syncing failed.") );
2135 qDebug("Syncing failed ");
2136 return;
2137 }
2138
2139 mCommandSocket = new QSocket( this );
2140 QString host = KOPrefs::instance()->mActiveSyncIP;
2141 mCommandSocket->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() );
2142
2143 QFile file2( fileName );
2144 if (!file2.open( IO_ReadOnly ) ) {
2145 setCaption( i18n("Error: Cannot open temp file for read.") );
2146 qDebug("error open cal file ");
2147 return ;
2148
2149 }
2150 setCaption( i18n("Sending back synced file...") );
2151 QTextStream ts2( &file2 );
2152 ts2.setCodec( QTextCodec::codecForName("utf8") );
2153 QTextStream os2( mCommandSocket );
2154 os2.setCodec( QTextCodec::codecForName("utf8") );
2155 //os.setEncoding( QTextStream::UnicodeUTF8 );
2156 if ( KOPrefs::instance()->mWriteBackFile ) {
2157 os2 << "PUT\r\n";
2158 while ( ! ts2.atEnd() ) {
2159 os2 << ts2.readLine() << "\n";
2160 }
2161 } else {
2162 os2 << "STOP\r\n";
2163 }
2164 mCommandSocket->close();
2165 file.close();
2166 delete mCommandSocket;
2167 mCommandSocket = 0;
2168 qDebug("Syncing succesful! ");
2169 setCaption( i18n("Easy-Pi-Sync succesful!") );
2170
2171
2172}
2173
1863void MainWindow::syncLocalFile() 2174void MainWindow::syncLocalFile()
1864{ 2175{
1865 2176
1866 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2177 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1867 2178
1868 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2179 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1869 if ( fn == "" ) 2180 if ( fn == "" )
1870 return; 2181 return;
1871 //mView->setSyncDevice("local-file" ); 2182 //mView->setSyncDevice("local-file" );
1872 if ( syncWithFile( fn, false ) ) { 2183 if ( syncWithFile( fn, false ) ) {
1873 // Event* e = mView->getLastSyncEvent(); 2184 // Event* e = mView->getLastSyncEvent();
1874// e->setReadOnly( false ); 2185// e->setReadOnly( false );
1875// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2186// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1876// e->setReadOnly( true ); 2187// e->setReadOnly( true );
1877 } 2188 }
1878 2189
1879} 2190}
1880 2191
1881bool MainWindow::syncWithFile( QString fn , bool quick ) 2192bool MainWindow::syncWithFile( QString fn , bool quick )
1882{ 2193{
1883 bool ret = false; 2194 bool ret = false;
1884 QFileInfo info; 2195 QFileInfo info;
1885 info.setFile( fn ); 2196 info.setFile( fn );
1886 QString mess; 2197 QString mess;
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 47a7a90..58081f6 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,43 +1,94 @@
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 8
8#include <libkcal/incidence.h> 9#include <libkcal/incidence.h>
9#include "simplealarmclient.h" 10#include "simplealarmclient.h"
10 11
11class QAction; 12class QAction;
12class CalendarView; 13class CalendarView;
13class KSyncProfile; 14class KSyncProfile;
14#ifdef DESKTOP_VERSION 15#ifdef DESKTOP_VERSION
15 16
16#define QPEToolBar QToolBar 17#define QPEToolBar QToolBar
17#define QPEMenuBar QMenuBar 18#define QPEMenuBar QMenuBar
18#endif 19#endif
19class QPEToolBar; 20class QPEToolBar;
21#include <qserversocket.h>
22#include <qsocket.h>
23#include <qnetworkprotocol.h>
24
25class KServerSocket : public QServerSocket
26{
27 Q_OBJECT
28
29public:
30 KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ) :
31 QServerSocket( port, backlog, parent, name ){;};
32 void newConnection ( int socket )
33 {
34 qDebug("KServerSocket:New connection %d ", socket);
35 QSocket* s = new QSocket( this );
36 connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) );
37 connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
38 s->setSocket( socket );
39 }
40
41signals:
42 void sendFile(QSocket*);
43 void getFile(QSocket*);
44 void endConnect();
45private slots:
46 void discardClient()
47 {
48 QSocket* socket = (QSocket*)sender();
49 delete socket;
50 emit endConnect();
51 }
52 void readClient()
53 {
54 qDebug("readClient() ");
55 QSocket* socket = (QSocket*)sender();
56 if ( socket->canReadLine() ) {
57 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() );
58 if ( tokens[0] == "GET" ) {
59 emit sendFile( socket );
60 }
61 if ( tokens[0] == "PUT" ) {
62 emit getFile( socket );
63 }
64 if ( tokens[0] == "STOP" ) {
65 emit endConnect();
66 }
67 }
68 }
69};
70
20 71
21namespace KCal { 72namespace KCal {
22class CalendarLocal; 73class CalendarLocal;
23} 74}
24 75
25using namespace KCal; 76using namespace KCal;
26 77
27class MainWindow : public QMainWindow 78class MainWindow : public QMainWindow
28{ 79{
29 Q_OBJECT 80 Q_OBJECT
30 public: 81 public:
31 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 82 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
32 ~MainWindow(); 83 ~MainWindow();
33 public slots: 84 public slots:
34 virtual void showMaximized (); 85 virtual void showMaximized ();
35 void configureAgenda( int ); 86 void configureAgenda( int );
36 void recieve( const QCString& msg, const QByteArray& data ); 87 void recieve( const QCString& msg, const QByteArray& data );
37 static QString defaultFileName(); 88 static QString defaultFileName();
38 static QString resourcePath(); 89 static QString resourcePath();
39 protected slots: 90 protected slots:
40 void setCaptionToDates(); 91 void setCaptionToDates();
41 int ringSync(); 92 int ringSync();
42 void multiSync( bool askforPrefs = false ); 93 void multiSync( bool askforPrefs = false );
43 void about(); 94 void about();
@@ -67,57 +118,69 @@ class MainWindow : public QMainWindow
67 void printSel(); 118 void printSel();
68 void printCal(); 119 void printCal();
69 void saveCalendar(); 120 void saveCalendar();
70 void loadCalendar(); 121 void loadCalendar();
71 void exportVCalendar(); 122 void exportVCalendar();
72 void fillFilterMenu(); 123 void fillFilterMenu();
73 void selectFilter( int ); 124 void selectFilter( int );
74 125
75 void slotSyncMenu( int ); 126 void slotSyncMenu( int );
76 void syncSSH(); 127 void syncSSH();
77 void confSync(); 128 void confSync();
78 void syncSharp(); 129 void syncSharp();
79 void syncPhone(); 130 void syncPhone();
80 void syncLocalFile(); 131 void syncLocalFile();
81 bool syncWithFile( QString, bool ); 132 bool syncWithFile( QString, bool );
82 void quickSyncLocalFile(); 133 void quickSyncLocalFile();
83 134
84 135
85 protected: 136 protected:
86 void displayText( QString, QString); 137 void displayText( QString, QString);
87 void displayFile( QString, QString); 138 void displayFile( QString, QString);
88 139
89 void enableIncidenceActions( bool ); 140 void enableIncidenceActions( bool );
90 141
142 private slots:
143 void fillSyncMenu();
144 void sendFile(QSocket* s);
145 void getFile(QSocket* socket);
146 void readFileFromSocket();
147 void endConnect();
91 private: 148 private:
149 QSocket* mCommandSocket;
150 KServerSocket * mServerSocket;
92 bool mClosed; 151 bool mClosed;
93 void saveOnClose(); 152 void saveOnClose();
94 int mCurrentSyncProfile; 153 int mCurrentSyncProfile;
154 void enableQuick();
155 void performQuick();
156 void performQuickQuick();
95 void syncRemote( KSyncProfile* , bool ask = true); 157 void syncRemote( KSyncProfile* , bool ask = true);
96 void fillSyncMenu();
97 bool mFlagKeyPressed; 158 bool mFlagKeyPressed;
98 bool mBlockAtStartup; 159 bool mBlockAtStartup;
99 QPEToolBar *iconToolBar; 160 QPEToolBar *iconToolBar;
100 void initActions(); 161 void initActions();
101 void setDefaultPreferences(); 162 void setDefaultPreferences();
102 void keyPressEvent ( QKeyEvent * ) ; 163 void keyPressEvent ( QKeyEvent * ) ;
103 void keyReleaseEvent ( QKeyEvent * ) ; 164 void keyReleaseEvent ( QKeyEvent * ) ;
104 QPopupMenu *configureToolBarMenu; 165 QPopupMenu *configureToolBarMenu;
105 QPopupMenu *selectFilterMenu; 166 QPopupMenu *selectFilterMenu;
106 QPopupMenu *configureAgendaMenu, *syncMenu; 167 QPopupMenu *configureAgendaMenu, *syncMenu;
107 CalendarLocal *mCalendar; 168 CalendarLocal *mCalendar;
108 CalendarView *mView; 169 CalendarView *mView;
109 QString getPassword(); 170 QString getPassword();
110 QAction *mNewSubTodoAction; 171 QAction *mNewSubTodoAction;
111 172
112 QAction *mShowAction; 173 QAction *mShowAction;
113 QAction *mEditAction; 174 QAction *mEditAction;
114 QAction *mDeleteAction; 175 QAction *mDeleteAction;
115 void closeEvent( QCloseEvent* ce ); 176 void closeEvent( QCloseEvent* ce );
116 SimpleAlarmClient mAlarmClient; 177 SimpleAlarmClient mAlarmClient;
117 QTimer mSaveTimer; 178 QTimer mSaveTimer;
118 bool mBlockSaveFlag; 179 bool mBlockSaveFlag;
119 bool mCalendarModifiedFlag; 180 bool mCalendarModifiedFlag;
120 QPixmap loadPixmap( QString ); 181 QPixmap loadPixmap( QString );
182 QDialog * mSyncActionDialog;
121}; 183};
122 184
185
123#endif 186#endif